From 222beaf4c7603b7e827682f896384a0d0f9dc361 Mon Sep 17 00:00:00 2001 From: Jirka Chadima Date: Wed, 1 Jan 2020 13:46:19 +0100 Subject: [PATCH 1/2] Adds the --override-variant command line flag Signed-off-by: Jirka Chadima --- cmd/skopeo/main.go | 6 ++++++ cmd/skopeo/utils.go | 1 + cmd/skopeo/utils_test.go | 4 ++++ completions/bash/skopeo | 3 ++- integration/copy_test.go | 2 +- 5 files changed, 14 insertions(+), 2 deletions(-) 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) { From c6a731bb2e9cf7a643649da2985b5a48f279f01e Mon Sep 17 00:00:00 2001 From: Jirka Chadima Date: Thu, 2 Jan 2020 17:04:48 +0100 Subject: [PATCH 2/2] Adds override-variant to man pages Signed-off-by: Jirka Chadima --- docs/skopeo-copy.1.md | 2 +- docs/skopeo.1.md | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/skopeo-copy.1.md b/docs/skopeo-copy.1.md index 5efd7441..c6ff933a 100644 --- a/docs/skopeo-copy.1.md +++ b/docs/skopeo-copy.1.md @@ -20,7 +20,7 @@ Uses the system's trust policy to validate images, rejects images not trusted by **--all** If _source-image_ refers to a list of images, instead of copying just the image which matches the current OS and -architecture (subject to the use of the global --override-os and --override-arch options), attempt to copy all of +architecture (subject to the use of the global --override-os, --override-arch and --override-variant options), attempt to copy all of the images in the list, and the list itself. **--authfile** _path_ diff --git a/docs/skopeo.1.md b/docs/skopeo.1.md index dca05ec6..af99e7a4 100644 --- a/docs/skopeo.1.md +++ b/docs/skopeo.1.md @@ -58,6 +58,8 @@ Most commands refer to container images, using a _transport_`:`_details_ format. **--override-os** _OS_ Use _OS_ instead of the running OS for choosing images. + **--override-variant** _VARIANT_ Use _VARIANT_ instead of the running architecture variant for choosing images. + **--command-timeout** _duration_ Timeout for the command execution. **--help**|**-h** Show help