diff --git a/cmd/skopeo/utils.go b/cmd/skopeo/utils.go index 3fdd3715..79240306 100644 --- a/cmd/skopeo/utils.go +++ b/cmd/skopeo/utils.go @@ -93,10 +93,10 @@ func dockerImageFlags(global *globalOptions, shared *sharedImageOptions, flagPre f := fs.VarPF(newOptionalStringValue(&flags.credsOption), credsOptionAlias, "", "Use `USERNAME[:PASSWORD]` for accessing the registry") f.Hidden = true } + fs.Var(newOptionalStringValue(&flags.registryToken), flagPrefix+"registry-token", "Provide a Bearer token for accessing the registry") fs.StringVar(&flags.dockerCertPath, flagPrefix+"cert-dir", "", "use certificates at `PATH` (*.crt, *.cert, *.key) to connect to the registry or daemon") optionalBoolFlag(&fs, &flags.tlsVerify, flagPrefix+"tls-verify", "require HTTPS and verify certificates when talking to the container registry or daemon (defaults to true)") fs.BoolVar(&flags.noCreds, flagPrefix+"no-creds", false, "Access the registry anonymously") - fs.Var(newOptionalStringValue(&flags.registryToken), flagPrefix+"registry-token", "Provide a Bearer token for accessing the registry") return fs, &flags } @@ -133,9 +133,6 @@ func (opts *imageOptions) newSystemContext() (*types.SystemContext, error) { ctx.AuthFilePath = opts.shared.authFilePath ctx.DockerDaemonHost = opts.dockerDaemonHost ctx.DockerDaemonCertPath = opts.dockerCertPath - if opts.registryToken.present { - ctx.DockerBearerRegistryToken = opts.registryToken.value - } if opts.dockerImageOptions.authFilePath.present { ctx.AuthFilePath = opts.dockerImageOptions.authFilePath.value } @@ -155,6 +152,9 @@ func (opts *imageOptions) newSystemContext() (*types.SystemContext, error) { return nil, err } } + if opts.registryToken.present { + ctx.DockerBearerRegistryToken = opts.registryToken.value + } if opts.noCreds { ctx.DockerAuthConfig = &types.DockerAuthConfig{} } diff --git a/cmd/skopeo/utils_test.go b/cmd/skopeo/utils_test.go index a030cfd4..db003106 100644 --- a/cmd/skopeo/utils_test.go +++ b/cmd/skopeo/utils_test.go @@ -68,11 +68,11 @@ func TestImageOptionsNewSystemContext(t *testing.T) { DockerCertPath: "/srv/cert-dir", DockerInsecureSkipTLSVerify: types.OptionalBoolTrue, DockerAuthConfig: &types.DockerAuthConfig{Username: "creds-user", Password: "creds-password"}, + DockerBearerRegistryToken: "faketoken", DockerDaemonCertPath: "/srv/cert-dir", DockerDaemonHost: "daemon-host.example.com", DockerDaemonInsecureSkipTLSVerify: true, BigFilesTemporaryDir: "/srv", - DockerBearerRegistryToken: "faketoken", }, res) // Global/per-command tlsVerify behavior @@ -180,12 +180,12 @@ func TestImageDestOptionsNewSystemContext(t *testing.T) { DockerCertPath: "/srv/cert-dir", DockerInsecureSkipTLSVerify: types.OptionalBoolTrue, DockerAuthConfig: &types.DockerAuthConfig{Username: "creds-user", Password: "creds-password"}, + DockerBearerRegistryToken: "faketoken", DockerDaemonCertPath: "/srv/cert-dir", DockerDaemonHost: "daemon-host.example.com", DockerDaemonInsecureSkipTLSVerify: true, DirForceCompress: true, BigFilesTemporaryDir: "/srv", - DockerBearerRegistryToken: "faketoken", }, res) // Invalid option values in imageOptions diff --git a/completions/bash/skopeo b/completions/bash/skopeo index 65fc8281..05bfa6dd 100644 --- a/completions/bash/skopeo +++ b/completions/bash/skopeo @@ -140,11 +140,14 @@ _skopeo_delete() { _skopeo_layers() { local options_with_args=" + --authfile --creds --cert-dir + --registry-token " local boolean_options=" --tls-verify + --no-creds " _complete_ "$options_with_args" "$boolean_options" }