Skip to content
This repository was archived by the owner on May 12, 2021. It is now read-only.

Commit c7fa5dc

Browse files
committed
utils: Fix case version check for stable releases
For stable versions the format used `x.y.z`. kata-env was failing trying to make a new release from 1.11.0-rc to 1.11.0 This fix kata-env for releases 1.11+ where this regression was introduced. Fixes: #2674 Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
1 parent c2b6978 commit c7fa5dc

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

cli/kata-check_test.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,13 @@ func TestCheckVersionConsistencyInComponents(t *testing.T) {
959959
"",
960960
"0.2.0-rc0",
961961
},
962+
{
963+
false,
964+
false,
965+
"kata-shim version 0.2.0-xxxxxxxxxxxxx",
966+
"",
967+
"0.2.0",
968+
},
962969
}
963970

964971
origVersion := version

cli/utils.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,13 @@ func constructVersionInfo(version string) VersionInfo {
161161
return unknownVersionInfo
162162
}
163163

164-
pres := strings.Split(sv.Pre[0].VersionStr, "-")
164+
var pres string
165+
if len(sv.Pre) > 0 {
166+
presSplit := strings.Split(sv.Pre[0].VersionStr, "-")
167+
if len(presSplit) > 2 {
168+
pres = presSplit[1]
169+
}
170+
}
165171

166172
// version contains Commit info.
167173
if len(pres) > 1 {
@@ -170,7 +176,7 @@ func constructVersionInfo(version string) VersionInfo {
170176
Major: sv.Major,
171177
Minor: sv.Minor,
172178
Patch: sv.Patch,
173-
Commit: pres[1],
179+
Commit: pres,
174180
}
175181
}
176182

0 commit comments

Comments
 (0)