push: simplify cmd

The indirection via a 2nd variable isn't needed.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg
2020-04-29 14:14:02 +02:00
parent 854293a59a
commit 46b185942c

View File

@ -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") 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` // TLS verification in c/image is controlled via a `types.OptionalBool`
// which allows for distinguishing among set-true, set-false, unspecified // which allows for distinguishing among set-true, set-false, unspecified
// which is important to implement a sane way of dealing with defaults of // which is important to implement a sane way of dealing with defaults of
// boolean CLI flags. // boolean CLI flags.
if cmd.Flags().Changed("tls-verify") { if cmd.Flags().Changed("tls-verify") {
pushOptsAPI.TLSVerify = types.NewOptionalBool(pushOptions.TLSVerifyCLI) pushOptions.TLSVerify = types.NewOptionalBool(pushOptions.TLSVerifyCLI)
} }
if pushOptsAPI.Authfile != "" { if pushOptions.Authfile != "" {
if _, err := os.Stat(pushOptsAPI.Authfile); err != nil { if _, err := os.Stat(pushOptions.Authfile); err != nil {
return errors.Wrapf(err, "error getting authfile %s", pushOptsAPI.Authfile) 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 // Let's do all the remaining Yoga in the API to prevent us from scattering
// logic across (too) many parts of the code. // 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)
} }