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

Commit

Permalink
utils: Fix case version check for stable releases
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jcvenegas committed May 8, 2020
1 parent c2b6978 commit c7fa5dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 7 additions & 0 deletions cli/kata-check_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -959,6 +959,13 @@ func TestCheckVersionConsistencyInComponents(t *testing.T) {
"",
"0.2.0-rc0",
},
{
false,
false,
"kata-shim version 0.2.0-xxxxxxxxxxxxx",
"",
"0.2.0",
},
}

origVersion := version
Expand Down
10 changes: 8 additions & 2 deletions cli/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,13 @@ func constructVersionInfo(version string) VersionInfo {
return unknownVersionInfo
}

pres := strings.Split(sv.Pre[0].VersionStr, "-")
var pres string
if len(sv.Pre) > 0 {
presSplit := strings.Split(sv.Pre[0].VersionStr, "-")
if len(presSplit) > 2 {
pres = presSplit[1]
}
}

// version contains Commit info.
if len(pres) > 1 {
Expand All @@ -170,7 +176,7 @@ func constructVersionInfo(version string) VersionInfo {
Major: sv.Major,
Minor: sv.Minor,
Patch: sv.Patch,
Commit: pres[1],
Commit: pres,
}
}

Expand Down

0 comments on commit c7fa5dc

Please sign in to comment.