From 03f59803cd69f8d105088a09b6005057817cff01 Mon Sep 17 00:00:00 2001 From: Richard Gee Date: Thu, 9 May 2024 20:29:26 +0100 Subject: [PATCH] update and add tests for stern Signed-off-by: Richard Gee --- .DEREK.yml | 1 + pkg/get/get_test.go | 84 +++++++++++++++++++++++++++++++++++++++++++++ pkg/get/tools.go | 4 ++- 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/.DEREK.yml b/.DEREK.yml index 195e8b27a..3a25666aa 100644 --- a/.DEREK.yml +++ b/.DEREK.yml @@ -4,6 +4,7 @@ curators: - welteki - nitishkumar71 - Jasstkn + - rgee0 features: - dco_check diff --git a/pkg/get/get_test.go b/pkg/get/get_test.go index dc18a3965..2f23b1b1c 100644 --- a/pkg/get/get_test.go +++ b/pkg/get/get_test.go @@ -1751,6 +1751,90 @@ func Test_DownloadMinikube(t *testing.T) { } } +func Test_DownloadStern(t *testing.T) { + tools := MakeTools() + name := "stern" + version := "v1.29.0" + + tool := getTool(name, tools) + + tests := []test{ + { + os: "darwin", + arch: "amd64", + version: version, + url: `https://github.com/stern/stern/releases/download/v1.29.0/stern_1.29.0_darwin_amd64.tar.gz`, + }, + { + os: "darwin", + arch: arch64bit, + version: version, + url: `https://github.com/stern/stern/releases/download/v1.29.0/stern_1.29.0_darwin_amd64.tar.gz`, + }, + { + os: "darwin", + arch: archDarwinARM64, + version: version, + url: `https://github.com/stern/stern/releases/download/v1.29.0/stern_1.29.0_darwin_arm64.tar.gz`, + }, + { + os: "linux", + arch: "amd64", + version: version, + url: `https://github.com/stern/stern/releases/download/v1.29.0/stern_1.29.0_linux_amd64.tar.gz`, + }, + { + os: "linux", + arch: arch64bit, + version: version, + url: `https://github.com/stern/stern/releases/download/v1.29.0/stern_1.29.0_linux_amd64.tar.gz`, + }, + { + os: "linux", + arch: archARM7, + version: version, + url: `https://github.com/stern/stern/releases/download/v1.29.0/stern_1.29.0_linux_arm.tar.gz`, + }, + { + os: "linux", + arch: archARM64, + version: version, + url: `https://github.com/stern/stern/releases/download/v1.29.0/stern_1.29.0_linux_arm64.tar.gz`, + }, + { + os: "ming", + arch: arch64bit, + version: version, + url: `https://github.com/stern/stern/releases/download/v1.29.0/stern_1.29.0_windows_amd64.tar.gz`, + }, + { + os: "ming", + arch: archARM7, + version: version, + url: `https://github.com/stern/stern/releases/download/v1.29.0/stern_1.29.0_windows_arm.tar.gz`, + }, + { + os: "ming", + arch: archARM64, + version: version, + url: `https://github.com/stern/stern/releases/download/v1.29.0/stern_1.29.0_windows_arm64.tar.gz`, + }, + } + + for _, tc := range tests { + t.Run(tc.os+" "+tc.arch+" "+tc.version, func(t *testing.T) { + + 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_DownloadMinio(t *testing.T) { tools := MakeTools() name := "mc" diff --git a/pkg/get/tools.go b/pkg/get/tools.go index d926aec5d..38821ebe4 100644 --- a/pkg/get/tools.go +++ b/pkg/get/tools.go @@ -1244,12 +1244,14 @@ https://github.com/inlets/inletsctl/releases/download/{{.Version}}/{{$fileName}} Repo: "stern", Name: "stern", Description: "Multi pod and container log tailing for Kubernetes.", - BinaryTemplate: `{{$arch := "arm"}} + BinaryTemplate: `{{$arch := .Arch}} {{- if eq .Arch "aarch64" -}} {{$arch = "arm64"}} {{- else if eq .Arch "x86_64" -}} {{$arch = "amd64"}} +{{- else if eq .Arch "armv7l" -}} +{{$arch = "arm"}} {{- end -}} {{$os := .OS}}