Prefer digest over tag on pull
If a reference passed to the pull code contains both a tag and a digest,
currently the tag is used instead of the digest in the request to the
registry. This is the wrong behavior. Change it to favor the digest.
@@ -334,18 +334,18 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named) (tagUpdat
manifest distribution.Manifest
tagOrDigest string // Used for logging/progress only
)
- if tagged, isTagged := ref.(reference.NamedTagged); isTagged {
- manifest, err = manSvc.Get(ctx, "", distribution.WithTag(tagged.Tag()))
- if err != nil {
- return false, allowV1Fallback(err)
- }
- tagOrDigest = tagged.Tag()
- } else if digested, isDigested := ref.(reference.Canonical); isDigested {
+ if digested, isDigested := ref.(reference.Canonical); isDigested {
manifest, err = manSvc.Get(ctx, digested.Digest())
if err != nil {
return false, err
}
tagOrDigest = digested.Digest().String()
+ } else if tagged, isTagged := ref.(reference.NamedTagged); isTagged {
+ manifest, err = manSvc.Get(ctx, "", distribution.WithTag(tagged.Tag()))
+ if err != nil {
+ return false, allowV1Fallback(err)
+ }
+ tagOrDigest = tagged.Tag()
} else {
return false, fmt.Errorf("internal error: reference has neither a tag nor a digest: %s", reference.FamiliarString(ref))
}
