From 6ba898f74fd4b434369ae24917b9528d8f5b02eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Mon, 4 Nov 2024 17:28:26 +0100 Subject: [PATCH] HACK: Only return an image ID from ReportResolvedReference for c/storage MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miloslav Trmač --- copy/copy.go | 1 + storage/storage_dest.go | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/copy/copy.go b/copy/copy.go index 75d6b8234..5b26abb09 100644 --- a/copy/copy.go +++ b/copy/copy.go @@ -146,6 +146,7 @@ type Options struct { // // For the containers-storage: transport, the reference contains an image ID, // so that storage.ResolveReference returns exactly the created image. + // WARNING: It is unspecified whether the reference also contains a reference.Named element. ReportResolvedReference *types.ImageReference } diff --git a/storage/storage_dest.go b/storage/storage_dest.go index ce66bccec..51fac71e4 100644 --- a/storage/storage_dest.go +++ b/storage/storage_dest.go @@ -1344,7 +1344,15 @@ func (s *storageImageDestination) CommitWithOptions(ctx context.Context, options logrus.Debugf("added name %q to image %q", name, img.ID) } if options.ReportResolvedReference != nil { - resolved, err := newReference(s.imageRef.transport, s.imageRef.named, intendedID) + // FIXME? This is using nil for the named reference. + // It would be better to also use s.imageRef.named, because that allows us to resolve to the right + // digest / manifest (and corresponding signatures). + // The problem with that is that resolving such a reference fails if the s.imageRef.named name is moved to a different image + // (because it is a tag that moved, or because we have pulled “the same” image for a different architecture). + // Right now (2024-11), ReportResolvedReference is only used in c/common/libimage, where the caller only extracts the image ID, + // so the name does not matter; to give us options, copy.Options.ReportResolvedReference is explicitly refusing to document + // whether the value contains a name. + resolved, err := newReference(s.imageRef.transport, nil, intendedID) if err != nil { return fmt.Errorf("creating a resolved reference for (%s, %s): %w", s.imageRef.StringWithinTransport(), intendedID, err) }