Skip to content

Commit

Permalink
fix: Don't return original tag if no tag was considered
Browse files Browse the repository at this point in the history
Signed-off-by: jannfis <jann@mistrust.net>
  • Loading branch information
jannfis committed Jun 18, 2021
1 parent 1d19e6a commit 885ed0b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pkg/image/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ func (img *ContainerImage) GetNewestVersionFromTags(vc *VersionConstraint, tagLi

logCtx.Debugf("found %d from %d tags eligible for consideration", len(considerTags), len(availableTags))

// Sort update candidates and return the most recent version in its original
// form, so we can later fetch it from the registry.
// If we found tags to consider, return the most recent tag found according
// to the update strategy.
if len(considerTags) > 0 {
return considerTags[len(considerTags)-1], nil
} else {
return img.ImageTag, nil
}

return nil, nil
}

// IsTagIgnored matches tag against the patterns in IgnoreList and returns true if one of them matches
Expand Down
3 changes: 1 addition & 2 deletions pkg/image/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ func Test_LatestVersion(t *testing.T) {
vc := VersionConstraint{Constraint: "~1.0"}
newTag, err := img.GetNewestVersionFromTags(&vc, tagList)
require.NoError(t, err)
require.NotNil(t, newTag)
assert.Equal(t, "1.0", newTag.TagName)
require.Nil(t, newTag)
})

t.Run("Find the latest version with a semver constraint that is invalid", func(t *testing.T) {
Expand Down

0 comments on commit 885ed0b

Please sign in to comment.