From 854293a59ae9fcf78e539f84ef1ebf7952ef925f Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 29 Apr 2020 11:42:36 +0200 Subject: push: fix push with one argument When doing a `podman push $IMG`, $IMG acts as the source and the destination. Signed-off-by: Valentin Rothberg --- cmd/podman/images/push.go | 1 + 1 file changed, 1 insertion(+) (limited to 'cmd/podman/images') diff --git a/cmd/podman/images/push.go b/cmd/podman/images/push.go index ef2ffd0d7..92a08255c 100644 --- a/cmd/podman/images/push.go +++ b/cmd/podman/images/push.go @@ -98,6 +98,7 @@ func imagePush(cmd *cobra.Command, args []string) error { switch len(args) { case 1: source = args[0] + destination = args[0] case 2: source = args[0] destination = args[1] -- cgit v1.2.3-54-g00ecf From 46b185942ce6297a3e59a048790649571676818b Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 29 Apr 2020 14:14:02 +0200 Subject: push: simplify cmd The indirection via a 2nd variable isn't needed. Signed-off-by: Valentin Rothberg --- cmd/podman/images/push.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'cmd/podman/images') diff --git a/cmd/podman/images/push.go b/cmd/podman/images/push.go index 92a08255c..d6bebb026 100644 --- a/cmd/podman/images/push.go +++ b/cmd/podman/images/push.go @@ -108,22 +108,21 @@ func imagePush(cmd *cobra.Command, args []string) error { return errors.New("push requires at least one image name, or optionally a second to specify a different destination") } - pushOptsAPI := pushOptions.ImagePushOptions // TLS verification in c/image is controlled via a `types.OptionalBool` // which allows for distinguishing among set-true, set-false, unspecified // which is important to implement a sane way of dealing with defaults of // boolean CLI flags. if cmd.Flags().Changed("tls-verify") { - pushOptsAPI.TLSVerify = types.NewOptionalBool(pushOptions.TLSVerifyCLI) + pushOptions.TLSVerify = types.NewOptionalBool(pushOptions.TLSVerifyCLI) } - if pushOptsAPI.Authfile != "" { - if _, err := os.Stat(pushOptsAPI.Authfile); err != nil { - return errors.Wrapf(err, "error getting authfile %s", pushOptsAPI.Authfile) + if pushOptions.Authfile != "" { + if _, err := os.Stat(pushOptions.Authfile); err != nil { + return errors.Wrapf(err, "error getting authfile %s", pushOptions.Authfile) } } // Let's do all the remaining Yoga in the API to prevent us from scattering // logic across (too) many parts of the code. - return registry.ImageEngine().Push(registry.GetContext(), source, destination, pushOptsAPI) + return registry.ImageEngine().Push(registry.GetContext(), source, destination, pushOptions.ImagePushOptions) } -- cgit v1.2.3-54-g00ecf From d6d1e3860c2dec64471d3d9b408e5b90b3c21e4d Mon Sep 17 00:00:00 2001 From: Valentin Rothberg Date: Wed, 29 Apr 2020 14:33:00 +0200 Subject: push: fix --tls-verify Fix --tls-verify parsing and make the associated options reflect the correct logic. Other commands are affected as well but will be fixed later. Signed-off-by: Valentin Rothberg --- cmd/podman/images/push.go | 2 +- pkg/bindings/images/images.go | 6 +++--- pkg/domain/entities/images.go | 4 ++-- pkg/domain/infra/abi/images.go | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) (limited to 'cmd/podman/images') diff --git a/cmd/podman/images/push.go b/cmd/podman/images/push.go index d6bebb026..0b3502d61 100644 --- a/cmd/podman/images/push.go +++ b/cmd/podman/images/push.go @@ -113,7 +113,7 @@ func imagePush(cmd *cobra.Command, args []string) error { // which is important to implement a sane way of dealing with defaults of // boolean CLI flags. if cmd.Flags().Changed("tls-verify") { - pushOptions.TLSVerify = types.NewOptionalBool(pushOptions.TLSVerifyCLI) + pushOptions.SkipTLSVerify = types.NewOptionalBool(!pushOptions.TLSVerifyCLI) } if pushOptions.Authfile != "" { diff --git a/pkg/bindings/images/images.go b/pkg/bindings/images/images.go index 2305e0101..ff49ca914 100644 --- a/pkg/bindings/images/images.go +++ b/pkg/bindings/images/images.go @@ -310,9 +310,9 @@ func Push(ctx context.Context, source string, destination string, options entiti params := url.Values{} params.Set("credentials", options.Credentials) params.Set("destination", destination) - if options.TLSVerify != types.OptionalBoolUndefined { - val := bool(options.TLSVerify == types.OptionalBoolTrue) - params.Set("tlsVerify", strconv.FormatBool(val)) + if options.SkipTLSVerify != types.OptionalBoolUndefined { + val := bool(options.SkipTLSVerify == types.OptionalBoolTrue) + params.Set("tlsVerify", strconv.FormatBool(!val)) } path := fmt.Sprintf("/images/%s/push", source) diff --git a/pkg/domain/entities/images.go b/pkg/domain/entities/images.go index 707937a44..442b2cf3c 100644 --- a/pkg/domain/entities/images.go +++ b/pkg/domain/entities/images.go @@ -183,8 +183,8 @@ type ImagePushOptions struct { // SignBy adds a signature at the destination using the specified key. // Ignored for remote calls. SignBy string - // TLSVerify to enable/disable HTTPS and certificate verification. - TLSVerify types.OptionalBool + // SkipTLSVerify to skip HTTPS and certificate verification. + SkipTLSVerify types.OptionalBool } // ImageSearchOptions are the arguments for searching images. diff --git a/pkg/domain/infra/abi/images.go b/pkg/domain/infra/abi/images.go index 7c63276e5..d1245a45c 100644 --- a/pkg/domain/infra/abi/images.go +++ b/pkg/domain/infra/abi/images.go @@ -221,7 +221,7 @@ func (ir *ImageEngine) Push(ctx context.Context, source string, destination stri dockerRegistryOptions := image.DockerRegistryOptions{ DockerRegistryCreds: registryCreds, DockerCertPath: options.CertDir, - DockerInsecureSkipTLSVerify: options.TLSVerify, + DockerInsecureSkipTLSVerify: options.SkipTLSVerify, } signOptions := image.SigningOptions{ -- cgit v1.2.3-54-g00ecf