Skip to content

Commit d475a67

Browse files
committed
fix: Do not retrieve metadata for all tags with digest strategy (#337)
* fix: Only fetch metadata for constraint tag in digest strategx Signed-off-by: jannfis <[email protected]> * fix: Only fetch metadata for constraint tag in digest strategx Signed-off-by: jannfis <[email protected]> * fix: Only fetch metadata for constraint tag in digest strategx Signed-off-by: jannfis <[email protected]>
1 parent 13ac11d commit d475a67

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

pkg/registry/registry.go

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,16 @@ func (endpoint *RegistryEndpoint) GetTags(img *image.ContainerImage, regClient R
5151

5252
tags := []string{}
5353

54-
// Loop through tags, removing those we do not want
55-
if vc.MatchFunc != nil || len(vc.IgnoreList) > 0 {
54+
// For digest strategy, we do require a version constraint
55+
if vc.SortMode == image.VersionSortDigest && vc.Constraint == "" {
56+
return nil, fmt.Errorf("cannot use digest strategy for image %s without a version constraint", img.Original())
57+
}
58+
59+
// Loop through tags, removing those we do not want. If update strategy is
60+
// digest, all but the constraint tag are ignored.
61+
if vc.MatchFunc != nil || len(vc.IgnoreList) > 0 || vc.SortMode == image.VersionSortDigest {
5662
for _, t := range tTags {
57-
if (vc.MatchFunc != nil && !vc.MatchFunc(t, vc.MatchArgs)) || vc.IsTagIgnored(t) {
63+
if (vc.MatchFunc != nil && !vc.MatchFunc(t, vc.MatchArgs)) || vc.IsTagIgnored(t) || (vc.SortMode == image.VersionSortDigest && t != vc.Constraint) {
5864
log.Tracef("Removing tag %s because it either didn't match defined pattern or is ignored", t)
5965
} else {
6066
tags = append(tags, t)

0 commit comments

Comments
 (0)