Skip to content

Commit

Permalink
copy/copy: fail copySingleImage cases on EnsureCompressionVariantsExist
Browse files Browse the repository at this point in the history
EnsureCompressionVariantsExist is only valid when working with a
manifest list.

Signed-off-by: Aditya R <[email protected]>
  • Loading branch information
flouthoc committed Jul 25, 2023
1 parent 0748e31 commit 03fe2ca
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions copy/copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,13 +262,19 @@ func Image(ctx context.Context, policyContext *signature.PolicyContext, destRef,
}

if !multiImage {
if len(options.EnsureCompressionVariantsExist) > 0 {
return nil, fmt.Errorf("EnsureCompressionVariantsExist is not implemented for copySingleImage")
}
// The simple case: just copy a single image.
single, err := c.copySingleImage(ctx, c.unparsedToplevel, nil, copySingleImageOptions{requireCompressionFormatMatch: false})
if err != nil {
return nil, err
}
copiedManifest = single.manifest
} else if c.options.ImageListSelection == CopySystemImage {
if len(options.EnsureCompressionVariantsExist) > 0 {
return nil, fmt.Errorf("EnsureCompressionVariantsExist is not implemented for copySingleImage")
}
// This is a manifest list, and we weren't asked to copy multiple images. Choose a single image that
// matches the current system to copy, and copy it.
mfest, manifestType, err := c.unparsedToplevel.Manifest(ctx)
Expand Down

0 comments on commit 03fe2ca

Please sign in to comment.