mirror of
https://github.com/containers/skopeo.git
synced 2025-08-06 09:03:54 +00:00
Merge 0f7339901e
into 0f95b2bff9
This commit is contained in:
commit
fe422ee5b0
@ -53,7 +53,8 @@ func copyCmd(global *globalOptions) *cobra.Command {
|
|||||||
srcFlags, srcOpts := imageFlags(global, sharedOpts, deprecatedTLSVerifyOpt, "src-", "screds")
|
srcFlags, srcOpts := imageFlags(global, sharedOpts, deprecatedTLSVerifyOpt, "src-", "screds")
|
||||||
destFlags, destOpts := imageDestFlags(global, sharedOpts, deprecatedTLSVerifyOpt, "dest-", "dcreds")
|
destFlags, destOpts := imageDestFlags(global, sharedOpts, deprecatedTLSVerifyOpt, "dest-", "dcreds")
|
||||||
retryFlags, retryOpts := retryFlags()
|
retryFlags, retryOpts := retryFlags()
|
||||||
opts := copyOptions{global: global,
|
opts := copyOptions{
|
||||||
|
global: global,
|
||||||
deprecatedTLSVerify: deprecatedTLSVerifyOpt,
|
deprecatedTLSVerify: deprecatedTLSVerifyOpt,
|
||||||
srcImage: srcOpts,
|
srcImage: srcOpts,
|
||||||
destImage: destOpts,
|
destImage: destOpts,
|
||||||
@ -102,22 +103,31 @@ See skopeo(1) section "IMAGE NAMES" for the expected format
|
|||||||
|
|
||||||
// parseMultiArch parses the list processing selection
|
// parseMultiArch parses the list processing selection
|
||||||
// It returns the copy.ImageListSelection to use with image.Copy option
|
// It returns the copy.ImageListSelection to use with image.Copy option
|
||||||
func parseMultiArch(multiArch string) (copy.ImageListSelection, error) {
|
func parseMultiArch(multiArch string) (copy.ImageListSelection, []manifest.Schema2PlatformSpec, error) {
|
||||||
switch multiArch {
|
switch multiArch {
|
||||||
case "system":
|
case "system":
|
||||||
return copy.CopySystemImage, nil
|
return copy.CopySystemImage, nil, nil
|
||||||
case "all":
|
case "all":
|
||||||
return copy.CopyAllImages, nil
|
return copy.CopyAllImages, nil, nil
|
||||||
// There is no CopyNoImages value in copy.ImageListSelection, but because we
|
// There is no CopyNoImages value in copy.ImageListSelection, but because we
|
||||||
// don't provide an option to select a set of images to copy, we can use
|
// don't provide an option to select a set of images to copy, we can use
|
||||||
// CopySpecificImages.
|
// CopySpecificImages.
|
||||||
case "index-only":
|
case "index-only":
|
||||||
return copy.CopySpecificImages, nil
|
return copy.CopySpecificImages, nil, nil
|
||||||
// We don't expose CopySpecificImages other than index-only above, because
|
|
||||||
// we currently don't provide an option to choose the images to copy. That
|
|
||||||
// could be added in the future.
|
|
||||||
default:
|
default:
|
||||||
return copy.CopySystemImage, fmt.Errorf("unknown multi-arch option %q. Choose one of the supported options: 'system', 'all', or 'index-only'", multiArch)
|
platformsArr := strings.Split(multiArch, ",")
|
||||||
|
platforms := []manifest.Schema2PlatformSpec{}
|
||||||
|
for _, platform := range platformsArr {
|
||||||
|
parts := strings.SplitN(platform, "/", 2)
|
||||||
|
if len(parts) != 2 {
|
||||||
|
return copy.CopySystemImage, nil, fmt.Errorf("invalid platform format %q: expected os/arch", platform)
|
||||||
|
}
|
||||||
|
|
||||||
|
os := parts[0]
|
||||||
|
arch := parts[1]
|
||||||
|
platforms = append(platforms, manifest.Schema2PlatformSpec{OS: os, Architecture: arch})
|
||||||
|
}
|
||||||
|
return copy.CopyCustomArchImages, platforms, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,11 +198,12 @@ func (opts *copyOptions) run(args []string, stdout io.Writer) (retErr error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
imageListSelection := copy.CopySystemImage
|
imageListSelection := copy.CopySystemImage
|
||||||
|
imageListPlatforms := []manifest.Schema2PlatformSpec{}
|
||||||
if opts.multiArch.Present() && opts.all {
|
if opts.multiArch.Present() && opts.all {
|
||||||
return fmt.Errorf("Cannot use --all and --multi-arch flags together")
|
return fmt.Errorf("Cannot use --all and --multi-arch flags together")
|
||||||
}
|
}
|
||||||
if opts.multiArch.Present() {
|
if opts.multiArch.Present() {
|
||||||
imageListSelection, err = parseMultiArch(opts.multiArch.Value())
|
imageListSelection, imageListPlatforms, err = parseMultiArch(opts.multiArch.Value())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -303,6 +314,7 @@ func (opts *copyOptions) run(args []string, stdout io.Writer) (retErr error) {
|
|||||||
OciEncryptLayers: encLayers,
|
OciEncryptLayers: encLayers,
|
||||||
OciEncryptConfig: encConfig,
|
OciEncryptConfig: encConfig,
|
||||||
MaxParallelDownloads: opts.imageParallelCopies,
|
MaxParallelDownloads: opts.imageParallelCopies,
|
||||||
|
ImageListPlatforms: imageListPlatforms,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -312,7 +324,7 @@ func (opts *copyOptions) run(args []string, stdout io.Writer) (retErr error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err = os.WriteFile(opts.digestFile, []byte(manifestDigest.String()), 0644); err != nil {
|
if err = os.WriteFile(opts.digestFile, []byte(manifestDigest.String()), 0o644); err != nil {
|
||||||
return fmt.Errorf("Failed to write digest to file %q: %w", opts.digestFile, err)
|
return fmt.Errorf("Failed to write digest to file %q: %w", opts.digestFile, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,7 @@ Options:
|
|||||||
- system: Copy only the image that matches the system architecture
|
- system: Copy only the image that matches the system architecture
|
||||||
- all: Copy the full multi-architecture image
|
- all: Copy the full multi-architecture image
|
||||||
- index-only: Copy only the index
|
- index-only: Copy only the index
|
||||||
|
- targetPlatforms: Copy only the images that match the specified platforms (e.g. linux/amd64,linux/arm64)
|
||||||
|
|
||||||
The index-only option usually fails unless the referenced per-architecture images are already present in the destination, or the target registry supports sparse indexes.
|
The index-only option usually fails unless the referenced per-architecture images are already present in the destination, or the target registry supports sparse indexes.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user