Skip to content

Commit 4e88c62

Browse files
authored
fix: Don't return original tag if no tag was considered (#219)
Signed-off-by: jannfis <[email protected]>
1 parent 1d19e6a commit 4e88c62

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

pkg/image/version.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,13 @@ func (img *ContainerImage) GetNewestVersionFromTags(vc *VersionConstraint, tagLi
134134

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

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

146146
// IsTagIgnored matches tag against the patterns in IgnoreList and returns true if one of them matches

pkg/image/version_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ func Test_LatestVersion(t *testing.T) {
6363
vc := VersionConstraint{Constraint: "~1.0"}
6464
newTag, err := img.GetNewestVersionFromTags(&vc, tagList)
6565
require.NoError(t, err)
66-
require.NotNil(t, newTag)
67-
assert.Equal(t, "1.0", newTag.TagName)
66+
require.Nil(t, newTag)
6867
})
6968

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

0 commit comments

Comments
 (0)