Skip to content

Commit 2fb58a4

Browse files
rgee0alexellis
authored andcommitted
Change upgradeable logic based on feedback
Signed-off-by: Richard Gee <[email protected]>
1 parent 763c2de commit 2fb58a4

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

Diff for: cmd/chart/upgrade.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,6 @@ func tagIsUpgradeable(currentTag, latestTag string) bool {
207207
currentSemVer, _ := semver.NewVersion(currentTag)
208208
latestSemVer, _ := semver.NewVersion(latestTag)
209209

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

212212
}

Diff for: cmd/chart/upgrade_test.go

+36
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,42 @@ func Test_tagIsUpgradable(t *testing.T) {
5353
latest: "1.0.0",
5454
expected: false,
5555
},
56+
{
57+
title: "both are rootless different version'",
58+
current: "1.0.0-rootless",
59+
latest: "1.0.1-rootless",
60+
expected: true,
61+
},
62+
{
63+
title: "both are rootless same version'",
64+
current: "1.0.0-rootless",
65+
latest: "1.0.0-rootless",
66+
expected: false,
67+
},
68+
{
69+
title: "both are rc same version'",
70+
current: "1.0.0-rc",
71+
latest: "1.0.0-rc",
72+
expected: false,
73+
},
74+
{
75+
title: "both are rc different version'",
76+
current: "1.0.0-rc",
77+
latest: "1.0.1-rc",
78+
expected: true,
79+
},
80+
{
81+
title: "both are rc with suffix & same version'",
82+
current: "1.0.0-rc1",
83+
latest: "1.0.0-rc2",
84+
expected: false,
85+
},
86+
{
87+
title: "both are rc with suffix & different version'",
88+
current: "1.0.0-rc1",
89+
latest: "1.0.1-rc2",
90+
expected: false,
91+
},
5692
}
5793

5894
for _, tc := range tests {

0 commit comments

Comments
 (0)