Skip to content

Commit

Permalink
Move Hashicorp tools to GH Version Strategy
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Gee <[email protected]>
  • Loading branch information
rgee0 authored and alexellis committed May 14, 2024
1 parent 43a085f commit d930984
Show file tree
Hide file tree
Showing 2 changed files with 103 additions and 29 deletions.
78 changes: 74 additions & 4 deletions pkg/get/get_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,64 @@ func Test_DownloadK9s(t *testing.T) {
}
}

func Test_DownloadPopeye(t *testing.T) {
tools := MakeTools()
name := "popeye"

tool := getTool(name, tools)

const toolVersion = "v0.21.2"

tests := []test{
{
os: "ming",
arch: arch64bit,
version: toolVersion,
url: "https://github.com/derailed/popeye/releases/download/" + toolVersion + "/popeye_Windows_amd64.tar.gz",
},
{
os: "linux",
arch: arch64bit,
version: toolVersion,
url: "https://github.com/derailed/popeye/releases/download/" + toolVersion + "/popeye_Linux_amd64.tar.gz",
},
{
os: "darwin",
arch: arch64bit,
version: toolVersion,
url: "https://github.com/derailed/popeye/releases/download/" + toolVersion + "/popeye_Darwin_amd64.tar.gz",
},
{
os: "darwin",
arch: archDarwinARM64,
version: toolVersion,
url: "https://github.com/derailed/popeye/releases/download/" + toolVersion + "/popeye_Darwin_arm64.tar.gz",
},
{
os: "linux",
arch: archARM64,
version: toolVersion,
url: "https://github.com/derailed/popeye/releases/download/" + toolVersion + "/popeye_Linux_arm64.tar.gz",
},
{
os: "linux",
arch: archARM7,
version: toolVersion,
url: "https://github.com/derailed/popeye/releases/download/" + toolVersion + "/popeye_Linux_armv7.tar.gz",
},
}

for _, tc := range tests {
got, err := tool.GetURL(tc.os, tc.arch, tc.version, false)
if err != nil {
t.Fatal(err)
}
if got != tc.url {
t.Errorf("\nwant: %s, \n got: %s", tc.url, got)
}
}
}

func Test_DownloadEtcd(t *testing.T) {
tools := MakeTools()
name := "etcd"
Expand Down Expand Up @@ -6762,20 +6820,32 @@ func Test_DownloadAtuin(t *testing.T) {

tool := getTool(name, tools)

const toolVersion = "v15.0.0"
const toolVersion = "v18.2.0"

tests := []test{
{
os: "darwin",
arch: archDarwinARM64,
version: toolVersion,
url: "https://github.com/atuinsh/atuin/releases/download/" + toolVersion + "/atuin-" + toolVersion + "-aarch64-apple-darwin.tar.gz",
},
{
os: "linux",
arch: archARM64,
version: toolVersion,
url: "https://github.com/atuinsh/atuin/releases/download/" + toolVersion + "/atuin-" + toolVersion + "-aarch64-unknown-linux-gnu.tar.gz",
},
{
os: "linux",
arch: arch64bit,
version: toolVersion,
url: `https://github.com/atuinsh/atuin/releases/download/v15.0.0/atuin-v15.0.0-x86_64-unknown-linux-gnu.tar.gz`,
url: "https://github.com/atuinsh/atuin/releases/download/" + toolVersion + "/atuin-" + toolVersion + "-x86_64-unknown-linux-gnu.tar.gz",
},
{
os: "darwin",
arch: arch64bit,
version: toolVersion,
url: `https://github.com/atuinsh/atuin/releases/download/v15.0.0/atuin-v15.0.0-x86_64-apple-darwin.tar.gz`,
url: "https://github.com/atuinsh/atuin/releases/download/" + toolVersion + "/atuin-" + toolVersion + "-x86_64-apple-darwin.tar.gz",
},
}

Expand All @@ -6785,7 +6855,7 @@ func Test_DownloadAtuin(t *testing.T) {
t.Fatal(err)
}
if got != tc.url {
t.Errorf("want: %s, got: %s", tc.url, got)
t.Errorf("\nwant: %s, \n got: %s", tc.url, got)
}
}

Expand Down
54 changes: 29 additions & 25 deletions pkg/get/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,8 @@ https://github.com/inlets/inletsctl/releases/download/{{.Version}}/{{$fileName}}
{{ $arch = "arm64" }}
{{- else if eq .Arch "x86_64" -}}
{{ $arch = "amd64" }}
{{- else if eq .Arch "armv7l" -}}
{{ $arch = "armv7" }}
{{- end -}}
{{.Version}}/{{.Name}}_{{ $os }}_{{ $arch }}.tar.gz`,
Expand Down Expand Up @@ -819,11 +821,11 @@ https://github.com/inlets/inletsctl/releases/download/{{.Version}}/{{$fileName}}

tools = append(tools,
Tool{
Owner: "hashicorp",
Repo: "terraform",
Name: "terraform",
Version: "1.7.4",
Description: "Infrastructure as Code for major cloud providers.",
Owner: "hashicorp",
Repo: "terraform",
Name: "terraform",
VersionStrategy: GitHubVersionStrategy,
Description: "Infrastructure as Code for major cloud providers.",
URLTemplate: `
{{$arch := ""}}
{{- if eq .Arch "x86_64" -}}
Expand All @@ -841,7 +843,7 @@ https://github.com/inlets/inletsctl/releases/download/{{.Version}}/{{$fileName}}
{{$os = "windows"}}
{{- end -}}
https://releases.hashicorp.com/{{.Name}}/{{.Version}}/{{.Name}}_{{.Version}}_{{$os}}_{{$arch}}.zip`,
https://releases.hashicorp.com/{{.Name}}/{{.VersionNumber}}/{{.Name}}_{{.VersionNumber}}_{{$os}}_{{$arch}}.zip`,
})

tools = append(tools,
Expand Down Expand Up @@ -959,16 +961,16 @@ https://github.com/inlets/inletsctl/releases/download/{{.Version}}/{{$fileName}}

tools = append(tools,
Tool{
Owner: "hashicorp",
Repo: "packer",
Name: "packer",
Version: "1.10.1",
Description: "Build identical machine images for multiple platforms from a single source configuration.",
Owner: "hashicorp",
Repo: "packer",
Name: "packer",
VersionStrategy: GitHubVersionStrategy,
Description: "Build identical machine images for multiple platforms from a single source configuration.",
URLTemplate: `
{{$arch := ""}}
{{- if eq .Arch "x86_64" -}}
{{$arch = "amd64"}}
{{- else if eq .Arch "aarch64" -}}
{{- else if or (eq .Arch "aarch64") (eq .Arch "arm64") -}}
{{$arch = "arm64"}}
{{- else if eq .Arch "armv7l" -}}
{{$arch = "arm"}}
Expand All @@ -979,16 +981,16 @@ https://github.com/inlets/inletsctl/releases/download/{{.Version}}/{{$fileName}}
{{$os = "windows"}}
{{- end -}}
https://releases.hashicorp.com/{{.Name}}/{{.Version}}/{{.Name}}_{{.Version}}_{{$os}}_{{$arch}}.zip`,
https://releases.hashicorp.com/{{.Name}}/{{.VersionNumber}}/{{.Name}}_{{.VersionNumber}}_{{$os}}_{{$arch}}.zip`,
})

tools = append(tools,
Tool{
Owner: "hashicorp",
Repo: "waypoint",
Name: "waypoint",
Version: "0.11.4",
Description: "Easy application deployment for Kubernetes and Amazon ECS",
Owner: "hashicorp",
Repo: "waypoint",
Name: "waypoint",
VersionStrategy: GitHubVersionStrategy,
Description: "Easy application deployment for Kubernetes and Amazon ECS",
URLTemplate: `
{{$arch := .Arch}}
{{- if eq .Arch "x86_64" -}}
Expand All @@ -1004,7 +1006,7 @@ https://github.com/inlets/inletsctl/releases/download/{{.Version}}/{{$fileName}}
{{$os = "windows"}}
{{- end -}}
https://releases.hashicorp.com/{{.Name}}/{{.Version}}/{{.Name}}_{{.Version}}_{{$os}}_{{$arch}}.zip`})
https://releases.hashicorp.com/{{.Name}}/{{.VersionNumber}}/{{.Name}}_{{.VersionNumber}}_{{$os}}_{{$arch}}.zip`})

tools = append(tools,
Tool{
Expand Down Expand Up @@ -2954,11 +2956,11 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Repo}}

tools = append(tools,
Tool{
Owner: "hashicorp",
Repo: "vault",
Name: "vault",
Version: "1.11.2",
Description: "A tool for secrets management, encryption as a service, and privileged access management.",
Owner: "hashicorp",
Repo: "vault",
Name: "vault",
VersionStrategy: GitHubVersionStrategy,
Description: "A tool for secrets management, encryption as a service, and privileged access management.",
URLTemplate: `
{{$arch := ""}}
{{- if eq .Arch "x86_64" -}}
Expand All @@ -2976,7 +2978,7 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Repo}}
{{$os = "windows"}}
{{- end -}}
https://releases.hashicorp.com/{{.Name}}/{{.Version}}/{{.Name}}_{{.Version}}_{{$os}}_{{$arch}}.zip`,
https://releases.hashicorp.com/{{.Name}}/{{.VersionNumber}}/{{.Name}}_{{.VersionNumber}}_{{$os}}_{{$arch}}.zip`,
})

tools = append(tools,
Expand Down Expand Up @@ -3831,6 +3833,8 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Repo}}
{{- if (or (eq .Arch "x86_64") (eq .Arch "amd64")) -}}
{{$arch = "x86_64"}}
{{- else if (or (eq .Arch "aarch64") (eq .Arch "arm64")) -}}
{{$arch = "aarch64"}}
{{- end -}}
https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Name}}-{{.Version}}-{{$arch}}-{{$os}}.{{$ext}}`,
Expand Down

0 comments on commit d930984

Please sign in to comment.