Skip to content

Commit

Permalink
runtime: Fix linter errors in release files
Browse files Browse the repository at this point in the history
Fix the linter errors caught in the `runtime` repos `master` branch [1],
but not in the `2.0-dev` branch [2]. See [3] for further details.

[1] - kata-containers/runtime#2976
[2] - kata-containers#735
[3] - kata-containers/tests#2870

Fixes: kata-containers#783.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel authored and egernst committed Oct 2, 2020
1 parent 01df3c1 commit a4075f0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 20 deletions.
14 changes: 5 additions & 9 deletions src/runtime/cli/release.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ func makeRelease(release map[string]interface{}) (version string, details releas
key := "tag_name"

version, ok := release[key].(string)
if ok != true {
if !ok {
return "", details, fmt.Errorf("failed to find key %s in release data", key)
}

Expand All @@ -144,7 +144,7 @@ func makeRelease(release map[string]interface{}) (version string, details releas
key = "assets"

assetsArray, ok := release[key].([]interface{})
if ok != true {
if !ok {
return "", details, fmt.Errorf("failed to find key %s in release version %q data", key, version)
}

Expand All @@ -163,7 +163,7 @@ func makeRelease(release map[string]interface{}) (version string, details releas
key = "browser_download_url"

downloadURL, ok = assets.(map[string]interface{})[key].(string)
if ok != true {
if !ok {
return "", details, fmt.Errorf("failed to find key %s in release version %q asset data", key, version)
}

Expand All @@ -174,7 +174,7 @@ func makeRelease(release map[string]interface{}) (version string, details releas
key = "name"

filename, ok = assets.(map[string]interface{})[key].(string)
if ok != true {
if !ok {
return "", details, fmt.Errorf("failed to find key %s in release version %q asset data", key, version)
}

Expand All @@ -185,7 +185,7 @@ func makeRelease(release map[string]interface{}) (version string, details releas
key = "created_at"

createDate, ok = assets.(map[string]interface{})[key].(string)
if ok != true {
if !ok {
return "", details, fmt.Errorf("failed to find key %s in release version %q asset data", key, version)
}

Expand Down Expand Up @@ -402,9 +402,5 @@ func HandleReleaseVersions(cmd ReleaseCmd, currentVersion string, includeAll boo
return fmt.Errorf("Release %v has no details", newest)
}

if err != nil {
return err
}

return showLatestRelease(output, currentSemver, details)
}
22 changes: 11 additions & 11 deletions src/runtime/cli/release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,11 @@ func TestFindNewestRelease(t *testing.T) {
assert := assert.New(t)

type testData struct {
currentVer semver.Version
versions []semver.Version
expectAvailable bool
currentVer semver.Version
expectVersion semver.Version
expectError bool
expectAvailable bool
}

ver1, err := semver.Make("1.11.1")
Expand All @@ -414,15 +414,15 @@ func TestFindNewestRelease(t *testing.T) {
assert.NoError(err)

data := []testData{
{semver.Version{}, []semver.Version{}, false, semver.Version{}, true},
{ver1, []semver.Version{}, false, semver.Version{}, true},
{ver1, []semver.Version{ver1}, false, semver.Version{}, false},
{ver2, []semver.Version{ver1}, false, semver.Version{}, false},
{ver1, []semver.Version{ver2}, true, ver2, false},
{ver1, []semver.Version{ver3}, true, ver3, false},
{ver1, []semver.Version{ver2, ver3}, true, ver3, false},
{ver2, []semver.Version{ver1, ver3}, true, ver3, false},
{ver2, []semver.Version{ver1}, false, semver.Version{}, false},
{[]semver.Version{}, semver.Version{}, semver.Version{}, true, false},
{[]semver.Version{}, ver1, semver.Version{}, true, false},
{[]semver.Version{ver1}, ver1, semver.Version{}, false, false},
{[]semver.Version{ver1}, ver2, semver.Version{}, false, false},
{[]semver.Version{ver2}, ver1, ver2, false, true},
{[]semver.Version{ver3}, ver1, ver3, false, true},
{[]semver.Version{ver2, ver3}, ver1, ver3, false, true},
{[]semver.Version{ver1, ver3}, ver2, ver3, false, true},
{[]semver.Version{ver1}, ver2, semver.Version{}, false, false},
}

for i, d := range data {
Expand Down

0 comments on commit a4075f0

Please sign in to comment.