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 <rothberg@redhat.com>
This commit is contained in:
Valentin Rothberg 2020-04-29 14:33:00 +02:00
parent 46b185942c
commit d6d1e3860c
4 changed files with 7 additions and 7 deletions

View File

@ -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 != "" {

View File

@ -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)

View File

@ -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.

View File

@ -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{