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.
Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
... | ... |
@@ -334,18 +334,18 @@ func (p *v2Puller) pullV2Tag(ctx context.Context, ref reference.Named) (tagUpdat |
334 | 334 |
manifest distribution.Manifest |
335 | 335 |
tagOrDigest string // Used for logging/progress only |
336 | 336 |
) |
337 |
- if tagged, isTagged := ref.(reference.NamedTagged); isTagged { |
|
338 |
- manifest, err = manSvc.Get(ctx, "", distribution.WithTag(tagged.Tag())) |
|
339 |
- if err != nil { |
|
340 |
- return false, allowV1Fallback(err) |
|
341 |
- } |
|
342 |
- tagOrDigest = tagged.Tag() |
|
343 |
- } else if digested, isDigested := ref.(reference.Canonical); isDigested { |
|
337 |
+ if digested, isDigested := ref.(reference.Canonical); isDigested { |
|
344 | 338 |
manifest, err = manSvc.Get(ctx, digested.Digest()) |
345 | 339 |
if err != nil { |
346 | 340 |
return false, err |
347 | 341 |
} |
348 | 342 |
tagOrDigest = digested.Digest().String() |
343 |
+ } else if tagged, isTagged := ref.(reference.NamedTagged); isTagged { |
|
344 |
+ manifest, err = manSvc.Get(ctx, "", distribution.WithTag(tagged.Tag())) |
|
345 |
+ if err != nil { |
|
346 |
+ return false, allowV1Fallback(err) |
|
347 |
+ } |
|
348 |
+ tagOrDigest = tagged.Tag() |
|
349 | 349 |
} else { |
350 | 350 |
return false, fmt.Errorf("internal error: reference has neither a tag nor a digest: %s", reference.FamiliarString(ref)) |
351 | 351 |
} |