Skip to content

Commit

Permalink
HACK: Only return an image ID from ReportResolvedReference for c/storage
Browse files Browse the repository at this point in the history
Signed-off-by: Miloslav Trmač <mitr@redhat.com>
  • Loading branch information
mtrmac committed Nov 4, 2024
1 parent 125f862 commit 6ba898f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions copy/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
10 changes: 9 additions & 1 deletion storage/storage_dest.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 6ba898f

Please # to comment.