diff --git a/cmd/chart/upgrade.go b/cmd/chart/upgrade.go index 0ed7b5ce1..fca0e8cb4 100644 --- a/cmd/chart/upgrade.go +++ b/cmd/chart/upgrade.go @@ -200,6 +200,13 @@ func updateImages(iName string, v bool) (bool, string, error) { func tagIsUpgradeable(currentTag, latestTag string) bool { - return latestTag != currentTag && !strings.Contains(strings.ToLower(latestTag), "-rc") && !strings.EqualFold(currentTag, "latest") + if strings.EqualFold(currentTag, "latest") { + return false + } + + currentSemVer, _ := semver.NewVersion(currentTag) + latestSemVer, _ := semver.NewVersion(latestTag) + + return latestSemVer.Compare(currentSemVer) == 1 && latestSemVer.Prerelease() == currentSemVer.Prerelease() } diff --git a/cmd/chart/upgrade_test.go b/cmd/chart/upgrade_test.go index 8ac070937..a50ba3541 100644 --- a/cmd/chart/upgrade_test.go +++ b/cmd/chart/upgrade_test.go @@ -35,12 +35,60 @@ func Test_tagIsUpgradable(t *testing.T) { latest: "1.0.0-rc", expected: false, }, + { + title: "current is rootless", + current: "1.0.0-rootless", + latest: "1.1.0", + expected: false, + }, + { + title: "latest is rootless", + current: "1.0.0", + latest: "1.1.0-rootless", + expected: false, + }, { title: "current is 'latest'", current: "latest", latest: "1.0.0", expected: false, }, + { + title: "both are rootless different version'", + current: "1.0.0-rootless", + latest: "1.0.1-rootless", + expected: true, + }, + { + title: "both are rootless same version'", + current: "1.0.0-rootless", + latest: "1.0.0-rootless", + expected: false, + }, + { + title: "both are rc same version'", + current: "1.0.0-rc", + latest: "1.0.0-rc", + expected: false, + }, + { + title: "both are rc different version'", + current: "1.0.0-rc", + latest: "1.0.1-rc", + expected: true, + }, + { + title: "both are rc with suffix & same version'", + current: "1.0.0-rc1", + latest: "1.0.0-rc2", + expected: false, + }, + { + title: "both are rc with suffix & different version'", + current: "1.0.0-rc1", + latest: "1.0.1-rc2", + expected: false, + }, } for _, tc := range tests { diff --git a/go.mod b/go.mod index cc83dfc4f..368869aeb 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/alexellis/arkade -go 1.22 +go 1.22.0 require ( github.com/Masterminds/semver v1.5.0 diff --git a/pkg/get/get_test.go b/pkg/get/get_test.go index 85d0b7ccb..8f4b8c7fd 100644 --- a/pkg/get/get_test.go +++ b/pkg/get/get_test.go @@ -5927,38 +5927,38 @@ func Test_DownloaClusterawsadm(t *testing.T) { tool := getTool(name, tools) - const toolVersion = "v2.0.2" + const toolVersion = "v2.6.1" tests := []test{ { os: "linux", arch: arch64bit, version: toolVersion, - url: `https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.0.2/clusterawsadm_v2.0.2_linux_amd64`, + url: `https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.6.1/clusterawsadm-linux-amd64`, }, { os: "darwin", arch: arch64bit, version: toolVersion, - url: `https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.0.2/clusterawsadm_v2.0.2_darwin_amd64`, + url: `https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.6.1/clusterawsadm-darwin-amd64`, }, { os: "linux", arch: archARM64, version: toolVersion, - url: `https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.0.2/clusterawsadm_v2.0.2_linux_arm64`, + url: `https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.6.1/clusterawsadm-linux-arm64`, }, { os: "darwin", arch: archDarwinARM64, version: toolVersion, - url: `https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.0.2/clusterawsadm_v2.0.2_darwin_arm64`, + url: `https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.6.1/clusterawsadm-darwin-arm64`, }, { os: "ming", arch: arch64bit, version: toolVersion, - url: `https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.0.2/clusterawsadm_v2.0.2_windows_amd64.exe`, + url: `https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.6.1/clusterawsadm-windows-amd64.exe`, }, } diff --git a/pkg/get/tools.go b/pkg/get/tools.go index 53d07400a..c9d50666c 100644 --- a/pkg/get/tools.go +++ b/pkg/get/tools.go @@ -3344,11 +3344,9 @@ https://github.com/{{.Owner}}/{{.Repo}}/releases/download/{{.Version}}/{{.Name}} {{$ext = ".exe"}} {{- end -}} - clusterawsadm_{{.Version}}_{{$os}}_{{$arch}}{{$ext}} + clusterawsadm-{{$os}}-{{$arch}}{{$ext}} `, }) - // https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.5.0/clusterawsadm-v2.5.0-linux_amd64 - // https://github.com/kubernetes-sigs/cluster-api-provider-aws/releases/download/v2.5.0/clusterawsadm_v2.5.0_linux_amd64 tools = append(tools, Tool{ Owner: "schollz",