Skip to content

Commit

Permalink
fix: PR review
Browse files Browse the repository at this point in the history
Signed-off-by: Jesús Fernández <[email protected]>
  • Loading branch information
fernandezcuesta committed Sep 11, 2024
1 parent 2b0e216 commit d3254dd
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 17 deletions.
91 changes: 80 additions & 11 deletions pkg/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6861,24 +6861,93 @@ func Test_Crossplane(t *testing.T) {

tool := getTool(name, tools)

const toolVersion = ""
const currentVersion = ""
const toolVersion = "v1.17.0"

test := test{
os: "linux",
arch: arch64bit,
version: toolVersion,
url: `https://releases.crossplane.io/stable/current/bin/linux_amd64/crank`,
tests := []test{
{
os: "darwin",
arch: arch64bit,
version: currentVersion,
url: `https://releases.crossplane.io/stable/current/bin/darwin_amd64/crank`,
},
{
os: "darwin",
arch: arch64bit,
version: toolVersion,
url: `https://releases.crossplane.io/stable/v1.17.0/bin/darwin_amd64/crank`,
},
{
os: "darwin",
arch: archDarwinARM64,
version: currentVersion,
url: `https://releases.crossplane.io/stable/current/bin/darwin_arm64/crank`,
},
{
os: "darwin",
arch: archDarwinARM64,
version: toolVersion,
url: `https://releases.crossplane.io/stable/v1.17.0/bin/darwin_arm64/crank`,
},
{
os: "linux",
arch: arch64bit,
version: currentVersion,
url: `https://releases.crossplane.io/stable/current/bin/linux_amd64/crank`,
},
{
os: "linux",
arch: arch64bit,
version: toolVersion,
url: `https://releases.crossplane.io/stable/v1.17.0/bin/linux_amd64/crank`,
},
{
os: "linux",
arch: archARM64,
version: currentVersion,
url: `https://releases.crossplane.io/stable/current/bin/linux_arm64/crank`,
},
{
os: "linux",
arch: archARM64,
version: toolVersion,
url: `https://releases.crossplane.io/stable/v1.17.0/bin/linux_arm64/crank`,
},
{
os: "linux",
arch: archARM7,
version: currentVersion,
url: `https://releases.crossplane.io/stable/current/bin/linux_arm/crank`,
},
{
os: "linux",
arch: archARM7,
version: toolVersion,
url: `https://releases.crossplane.io/stable/v1.17.0/bin/linux_arm/crank`,
},
{
os: "ming",
arch: arch64bit,
version: currentVersion,
url: `https://releases.crossplane.io/stable/current/bin/windows_amd64/`,
},
{
os: "ming",
arch: arch64bit,
version: toolVersion,
url: `https://releases.crossplane.io/stable/v1.17.0/bin/windows_amd64/`,
},
}

t.Run(test.os+" "+test.arch+" "+test.version, func(r *testing.T) {
got, err := tool.GetURL(test.os, test.arch, test.version, false)
for _, tc := range tests {
got, err := tool.GetURL(tc.os, tc.arch, tc.version, false)
if err != nil {
t.Fatal(err)
}
if got != test.url {
t.Errorf("want: %s, got: %s", test.url, got)
if got != tc.url {
t.Errorf("want: %s, got: %s", tc.url, got)
}
})
}

}

Expand Down
20 changes: 14 additions & 6 deletions pkg/get/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -3812,12 +3812,14 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Name}}

tools = append(tools,
Tool{
Owner: "crossplane",
Repo: "crossplane",
Name: "crossplane",
Description: "Simplify some development and administration aspects of Crossplane.",
Owner: "crossplane",
Repo: "crossplane",
Name: "crossplane",
VersionStrategy: GitHubVersionStrategy,
Description: "Simplify some development and administration aspects of Crossplane.",
URLTemplate: `
{{$arch := .Arch}}
{{$ext := "" }}
{{$version := .Version}}
{{- if eq .Version "" -}}
Expand All @@ -3830,8 +3832,14 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Name}}
{{- else if eq .Arch "armv7l" -}}
{{ $arch = "arm" }}
{{- end -}}
https://releases.crossplane.io/stable/{{$version}}/bin/{{.OS}}_{{$arch}}/crank`,
{{$os := .OS}}
{{ if HasPrefix .OS "ming" -}}
{{$ext = ".exe" }}
{{$os = "windows"}}
{{- end -}}
https://releases.crossplane.io/stable/{{$version}}/bin/{{$os}}_{{$arch}}/crank{{$ext}}`,
})

tools = append(tools,
Expand Down

0 comments on commit d3254dd

Please sign in to comment.