From 028eab9ebb1e896c915db4826f2914d7f5c672e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Tue, 18 Jul 2023 12:33:17 +0200 Subject: [PATCH] c8d/inspect: Don't duplicate digested ref MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If image name is already an untagged digested reference, don't produce additional digested ref. Signed-off-by: Paweł Gronowski --- daemon/containerd/image.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/daemon/containerd/image.go b/daemon/containerd/image.go index 5383428c97..65c268e060 100644 --- a/daemon/containerd/image.go +++ b/daemon/containerd/image.go @@ -112,7 +112,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) { @@ -137,6 +137,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