You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add the ability to strip non-copied instances from manifest lists when
using CopySpecificImages. This implements the functionality originally
proposed in containers/image#1707.
When copying a subset of images from a multi-architecture manifest list
using CopySpecificImages, the current behavior always produces a sparse
manifest list - a manifest list that references platforms that weren't
actually copied. While this maintains the original digest, many
registries reject sparse manifests with "blob unknown to registry"
errors.
This commit adds a new SparseManifestListAction option that gives users
control over this behavior:
- KeepSparseManifestList (default): Preserves the manifest list as-is,
even when some instances aren't copied. Some registries may not
support sparse manifest lists.
- StripSparseManifestList (new): Removes instances that are not being copied
from the destination manifest list. This changes the digest but
ensures compatibility with all registries.
Based on original work by @bertbaron and @mtrmac in
containers/image#1707, adapted for the container-libs monorepo
structure.
Relates to #227
Signed-off-by: Alex Guidi <aguidi@redhat.com>
// StripSparseManifestList will strip missing images from the manifest
88
+
// list. When images are stripped the digest will differ from the original.
89
+
StripSparseManifestList
90
+
)
91
+
92
+
// SparseManifestListAction is one of KeepSparseManifestList or StripSparseManifestList
93
+
// to control the behavior when only a subset of images from a manifest list is copied
94
+
typeSparseManifestListActionint
95
+
80
96
// Options allows supplying non-default configuration modifying the behavior of CopyImage.
81
97
typeOptionsstruct {
82
98
RemoveSignaturesbool// Remove any pre-existing signatures. Signers and SignBy… will still add a new signature.
99
+
// RemoveListSignatures removes the manifest list signature while preserving per-instance signatures.
100
+
// If RemoveSignatures is also true, RemoveSignatures takes precedence.
101
+
RemoveListSignaturesbool
83
102
// Signers to use to add signatures during the copy.
84
103
// Callers are still responsible for closing these Signer objects; they can be reused for multiple copy.Image operations in a row.
85
104
Signers []*signer.Signer
@@ -102,6 +121,9 @@ type Options struct {
102
121
ImageListSelectionImageListSelection// set to either CopySystemImage (the default), CopyAllImages, or CopySpecificImages to control which instances we copy when the source reference is a list; ignored if the source reference is not a list
103
122
Instances []digest.Digest// if ImageListSelection is CopySpecificImages, copy only these instances, instances matching the InstancePlatforms list, and the list itself
104
123
InstancePlatforms []InstancePlatformFilter// if ImageListSelection is CopySpecificImages, copy instances with matching OS/Architecture (all variants and compressions), it also copies the index/manifest_list instance.
124
+
// When only a subset of images of a list is copied, this action indicates if the manifest should be kept or stripped.
125
+
// See CopySpecificImages.
126
+
SparseManifestListActionSparseManifestListAction
105
127
// Give priority to pulling gzip images if multiple images are present when configured to OptionalBoolTrue,
106
128
// prefers the best compression if this is configured as OptionalBoolFalse. Choose automatically (and the choice may change over time)
107
129
// if this is set to OptionalBoolUndefined (which is the default behavior, and recommended for most callers).
// If we were asked to copy multiple images and can't, that's an error.
366
390
if!supportsMultipleImages(c.dest) {
367
391
returnnil, fmt.Errorf("copying multiple images: destination transport %q does not support copying multiple images as a group", destRef.Transport().Name())
returnnil, fmt.Errorf("Manifest list must be converted to type %q to be written to destination, but we cannot modify it: %q", selectedListType, cannotModifyManifestListReason)
303
+
returnnil, fmt.Errorf("Manifest list must be converted to type %q to be written to destination, but we cannot modify it: %s", selectedListType, cannotModifyManifestListReason)
276
304
}
277
305
}
278
306
279
307
// Copy each image, or just the ones we want to copy, in turn.
0 commit comments