Skip to content

Commit

Permalink
Change upgradeable logic based on feedback
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Gee <richard@technologee.co.uk>
  • Loading branch information
rgee0 authored and alexellis committed Aug 8, 2024
1 parent 763c2de commit 2fb58a4
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/chart/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,6 @@ func tagIsUpgradeable(currentTag, latestTag string) bool {
currentSemVer, _ := semver.NewVersion(currentTag)
latestSemVer, _ := semver.NewVersion(latestTag)

return latestTag != currentTag && len(latestSemVer.Prerelease()) == 0 && len(currentSemVer.Prerelease()) == 0
return latestSemVer.Compare(currentSemVer) == 1 && latestSemVer.Prerelease() == currentSemVer.Prerelease()

}
36 changes: 36 additions & 0 deletions cmd/chart/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,42 @@ func Test_tagIsUpgradable(t *testing.T) {
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 {
Expand Down

0 comments on commit 2fb58a4

Please sign in to comment.