From 9b17c84ac8dac72f19436debb6e4a3e6246e09e6 Mon Sep 17 00:00:00 2001 From: Richard Gee Date: Fri, 10 May 2024 12:29:51 +0100 Subject: [PATCH] convert popeye to github VersionStrategy Signed-off-by: Richard Gee --- pkg/get/get_test.go | 58 +++++++++++++++++++++++++++++++++++++++++++++ pkg/get/tools.go | 11 +++++---- 2 files changed, 65 insertions(+), 4 deletions(-) diff --git a/pkg/get/get_test.go b/pkg/get/get_test.go index 2f23b1b1c..8f8354bda 100644 --- a/pkg/get/get_test.go +++ b/pkg/get/get_test.go @@ -1159,6 +1159,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/v0.21.2/popeye_Windows_amd64.tar.gz`, + }, + { + os: "linux", + arch: arch64bit, + version: toolVersion, + url: `https://github.com/derailed/popeye/releases/download/v0.21.2/popeye_Linux_amd64.tar.gz`, + }, + { + os: "darwin", + arch: arch64bit, + version: toolVersion, + url: `https://github.com/derailed/popeye/releases/download/v0.21.2/popeye_Darwin_amd64.tar.gz`, + }, + { + os: "darwin", + arch: archDarwinARM64, + version: toolVersion, + url: `https://github.com/derailed/popeye/releases/download/v0.21.2/popeye_Darwin_arm64.tar.gz`, + }, + { + os: "linux", + arch: archARM64, + version: toolVersion, + url: `https://github.com/derailed/popeye/releases/download/v0.21.2/popeye_Linux_arm64.tar.gz`, + }, + { + os: "linux", + arch: archARM7, + version: toolVersion, + url: `https://github.com/derailed/popeye/releases/download/v0.21.2/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" diff --git a/pkg/get/tools.go b/pkg/get/tools.go index 38821ebe4..feddfa299 100644 --- a/pkg/get/tools.go +++ b/pkg/get/tools.go @@ -759,10 +759,11 @@ https://github.com/inlets/inletsctl/releases/download/{{.Version}}/{{$fileName}} tools = append(tools, Tool{ - Owner: "derailed", - Repo: "popeye", - Name: "popeye", - Description: "Scans live Kubernetes cluster and reports potential issues with deployed resources and configurations.", + Owner: "derailed", + Repo: "popeye", + Name: "popeye", + VersionStrategy: "github", + Description: "Scans live Kubernetes cluster and reports potential issues with deployed resources and configurations.", BinaryTemplate: ` {{ $os := .OS }} {{ $arch := .Arch }} @@ -779,6 +780,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`,