diff --git a/cmd/skopeo/main.go b/cmd/skopeo/main.go index df608063..72123ccc 100644 --- a/cmd/skopeo/main.go +++ b/cmd/skopeo/main.go @@ -25,6 +25,7 @@ type globalOptions struct { registriesDirPath string // Path to a "registries.d" registry configuration directory overrideArch string // Architecture to use for choosing images, instead of the runtime one overrideOS string // OS to use for choosing images, instead of the runtime one + overrideVariant string // Architecture variant to use for choosing images, instead of the runtime one commandTimeout time.Duration // Timeout for the command execution registriesConfPath string // Path to the "registries.conf" file } @@ -79,6 +80,11 @@ func createApp() (*cli.App, *globalOptions) { Usage: "use `OS` instead of the running OS for choosing images", Destination: &opts.overrideOS, }, + cli.StringFlag{ + Name: "override-variant", + Usage: "use `VARIANT` instead of the running architecture variant for choosing images", + Destination: &opts.overrideVariant, + }, cli.DurationFlag{ Name: "command-timeout", Usage: "timeout for the command execution", diff --git a/cmd/skopeo/utils.go b/cmd/skopeo/utils.go index f66cfc35..6fb800ef 100644 --- a/cmd/skopeo/utils.go +++ b/cmd/skopeo/utils.go @@ -136,6 +136,7 @@ func (opts *imageOptions) newSystemContext() (*types.SystemContext, error) { RegistriesDirPath: opts.global.registriesDirPath, ArchitectureChoice: opts.global.overrideArch, OSChoice: opts.global.overrideOS, + VariantChoice: opts.global.overrideVariant, DockerCertPath: opts.dockerCertPath, OCISharedBlobDirPath: opts.sharedBlobDir, AuthFilePath: opts.shared.authFilePath, diff --git a/cmd/skopeo/utils_test.go b/cmd/skopeo/utils_test.go index e4c8a77a..3ba14b1e 100644 --- a/cmd/skopeo/utils_test.go +++ b/cmd/skopeo/utils_test.go @@ -52,6 +52,7 @@ func TestImageOptionsNewSystemContext(t *testing.T) { "--registries.d", "/srv/registries.d", "--override-arch", "overridden-arch", "--override-os", "overridden-os", + "--override-variant", "overridden-variant", }, []string{ "--authfile", "/srv/authfile", "--dest-cert-dir", "/srv/cert-dir", @@ -67,6 +68,7 @@ func TestImageOptionsNewSystemContext(t *testing.T) { AuthFilePath: "/srv/authfile", ArchitectureChoice: "overridden-arch", OSChoice: "overridden-os", + VariantChoice: "overridden-variant", OCISharedBlobDirPath: "/srv/shared-blob-dir", DockerCertPath: "/srv/cert-dir", DockerInsecureSkipTLSVerify: types.OptionalBoolTrue, @@ -149,6 +151,7 @@ func TestImageDestOptionsNewSystemContext(t *testing.T) { "--registries.d", "/srv/registries.d", "--override-arch", "overridden-arch", "--override-os", "overridden-os", + "--override-variant", "overridden-variant", }, []string{ "--authfile", "/srv/authfile", "--dest-cert-dir", "/srv/cert-dir", @@ -165,6 +168,7 @@ func TestImageDestOptionsNewSystemContext(t *testing.T) { AuthFilePath: "/srv/authfile", ArchitectureChoice: "overridden-arch", OSChoice: "overridden-os", + VariantChoice: "overridden-variant", OCISharedBlobDirPath: "/srv/shared-blob-dir", DockerCertPath: "/srv/cert-dir", DockerInsecureSkipTLSVerify: types.OptionalBoolTrue, diff --git a/completions/bash/skopeo b/completions/bash/skopeo index c5e664c2..0bbd8591 100644 --- a/completions/bash/skopeo +++ b/completions/bash/skopeo @@ -150,6 +150,7 @@ _skopeo_skopeo() { --registries.d --override-arch --override-os + --override-variant --command-timeout " local boolean_options=" @@ -161,7 +162,7 @@ _skopeo_skopeo() { case "$prev" in # XXX: Changes here need to be refleceted in $options_with_args as well. - --policy|--registries.d|--override-arch|--override-os|--command-timeout) + --policy|--registries.d|--override-arch|--override-os|--override-variant|--command-timeout) return ;; esac diff --git a/integration/copy_test.go b/integration/copy_test.go index 707293a5..cf39d291 100644 --- a/integration/copy_test.go +++ b/integration/copy_test.go @@ -469,7 +469,7 @@ func (s *CopySuite) TestCopyFailsWhenImageOSDoesntMatchRuntimeOS(c *check.C) { c.Assert(err, check.IsNil) defer os.RemoveAll(storage) storage = fmt.Sprintf("[vfs@%s/root+%s/runroot]", storage, storage) - assertSkopeoFails(c, `.*no image found in manifest list for architecture .*, OS .*`, "copy", knownWindowsOnlyImage, "containers-storage:"+storage+"test") + assertSkopeoFails(c, `.*no image found in manifest list for architecture .*, variant .*, OS .*`, "copy", knownWindowsOnlyImage, "containers-storage:"+storage+"test") } func (s *CopySuite) TestCopySucceedsWhenImageDoesntMatchRuntimeButWeOverride(c *check.C) {