diff options
| author | jannfis <jann@mistrust.net> | 2021-06-18 09:59:58 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-18 09:59:58 +0200 |
| commit | 4e88c62dc71e17bedcd9809a42a0795a4e735155 (patch) | |
| tree | 2c61a4a74cebffe52cee7d392a24992278010d7c /pkg | |
| parent | 1d19e6a2f5dc5658c4c6539cf8a4518a1233bb4e (diff) | |
fix: Don't return original tag if no tag was considered (#219)
Signed-off-by: jannfis <jann@mistrust.net>
Diffstat (limited to 'pkg')
| -rw-r--r-- | pkg/image/version.go | 8 | ||||
| -rw-r--r-- | pkg/image/version_test.go | 3 |
2 files changed, 5 insertions, 6 deletions
diff --git a/pkg/image/version.go b/pkg/image/version.go index bb8ea74..8461e17 100644 --- a/pkg/image/version.go +++ b/pkg/image/version.go @@ -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 diff --git a/pkg/image/version_test.go b/pkg/image/version_test.go index 009662f..a3c35d9 100644 --- a/pkg/image/version_test.go +++ b/pkg/image/version_test.go @@ -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) { |
