mirror of
https://github.com/containers/skopeo.git
synced 2025-08-29 11:32:45 +00:00
Add the --tls-verify option to (skopeo logout)
The current implementation can actually contact the registry (if logout fails with "not logged in" but there are .docker/config.json credentials present), so provide a non-deprecated way to disable TLS. Signed-off-by: Miloslav Trmač <mitr@redhat.com>
This commit is contained in:
parent
bd309aed2a
commit
a6cf2f4293
@ -4,12 +4,14 @@ import (
|
|||||||
"io"
|
"io"
|
||||||
|
|
||||||
"github.com/containers/common/pkg/auth"
|
"github.com/containers/common/pkg/auth"
|
||||||
|
"github.com/containers/image/v5/types"
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
)
|
)
|
||||||
|
|
||||||
type logoutOptions struct {
|
type logoutOptions struct {
|
||||||
global *globalOptions
|
global *globalOptions
|
||||||
logoutOpts auth.LogoutOptions
|
logoutOpts auth.LogoutOptions
|
||||||
|
tlsVerify optionalBool
|
||||||
}
|
}
|
||||||
|
|
||||||
func logoutCmd(global *globalOptions) *cobra.Command {
|
func logoutCmd(global *globalOptions) *cobra.Command {
|
||||||
@ -24,12 +26,17 @@ func logoutCmd(global *globalOptions) *cobra.Command {
|
|||||||
Example: `skopeo logout quay.io`,
|
Example: `skopeo logout quay.io`,
|
||||||
}
|
}
|
||||||
adjustUsage(cmd)
|
adjustUsage(cmd)
|
||||||
cmd.Flags().AddFlagSet(auth.GetLogoutFlags(&opts.logoutOpts))
|
flags := cmd.Flags()
|
||||||
|
optionalBoolFlag(flags, &opts.tlsVerify, "tls-verify", "require HTTPS and verify certificates when accessing the registry")
|
||||||
|
flags.AddFlagSet(auth.GetLogoutFlags(&opts.logoutOpts))
|
||||||
return cmd
|
return cmd
|
||||||
}
|
}
|
||||||
|
|
||||||
func (opts *logoutOptions) run(args []string, stdout io.Writer) error {
|
func (opts *logoutOptions) run(args []string, stdout io.Writer) error {
|
||||||
opts.logoutOpts.Stdout = stdout
|
opts.logoutOpts.Stdout = stdout
|
||||||
sys := opts.global.newSystemContext()
|
sys := opts.global.newSystemContext()
|
||||||
|
if opts.tlsVerify.present {
|
||||||
|
sys.DockerInsecureSkipTLSVerify = types.NewOptionalBool(!opts.tlsVerify.value)
|
||||||
|
}
|
||||||
return auth.Logout(sys, &opts.logoutOpts, args)
|
return auth.Logout(sys, &opts.logoutOpts, args)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user