c8d/inspect: Don't duplicate digested ref
If image name is already an untagged digested reference, don't produce
additional digested ref.
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 028eab9ebb
)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
parent
8ab6d025f6
commit
572de8764e
1 changed files with 6 additions and 1 deletions
|
@ -130,7 +130,7 @@ func (i *ImageService) GetImage(ctx context.Context, refOrID string, options ima
|
|||
return nil, err
|
||||
}
|
||||
|
||||
// Each image will result in 2 references (named and digested).
|
||||
// Usually each image will result in 2 references (named and digested).
|
||||
refs := make([]reference.Named, 0, len(tagged)*2)
|
||||
for _, i := range tagged {
|
||||
if i.UpdatedAt.After(lastUpdated) {
|
||||
|
@ -155,6 +155,11 @@ func (i *ImageService) GetImage(ctx context.Context, refOrID string, options ima
|
|||
}
|
||||
refs = append(refs, name)
|
||||
|
||||
if _, ok := name.(reference.Digested); ok {
|
||||
// Image name already contains a digest, so no need to create a digested reference.
|
||||
continue
|
||||
}
|
||||
|
||||
digested, err := reference.WithDigest(reference.TrimNamed(name), desc.Target.Digest)
|
||||
if err != nil {
|
||||
// This could only happen if digest is invalid, but considering that
|
||||
|
|
Loading…
Reference in a new issue