mirror of
https://github.com/helm/helm.git
synced 2026-06-30 19:57:48 +00:00
Added insecure option to login subcommand
Signed-off-by: Andrew Block <andy.block@gmail.com>
This commit is contained in:
@@ -43,6 +43,7 @@ type registryLoginOptions struct {
|
||||
certFile string
|
||||
keyFile string
|
||||
caFile string
|
||||
insecure bool
|
||||
}
|
||||
|
||||
func newRegistryLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Command {
|
||||
@@ -65,7 +66,8 @@ func newRegistryLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Comman
|
||||
return action.NewRegistryLogin(cfg).Run(out, hostname, username, password,
|
||||
action.WithCertFile(o.certFile),
|
||||
action.WithKeyFile(o.keyFile),
|
||||
action.WithCAFile(o.caFile))
|
||||
action.WithCAFile(o.caFile),
|
||||
action.WithInsecure(o.insecure))
|
||||
},
|
||||
}
|
||||
|
||||
@@ -73,6 +75,7 @@ func newRegistryLoginCmd(cfg *action.Configuration, out io.Writer) *cobra.Comman
|
||||
f.StringVarP(&o.username, "username", "u", "", "registry username")
|
||||
f.StringVarP(&o.password, "password", "p", "", "registry password or identity token")
|
||||
f.BoolVarP(&o.passwordFromStdinOpt, "password-stdin", "", false, "read password or identity token from stdin")
|
||||
f.BoolVarP(&o.insecure, "insecure", "", false, "allow connections to TLS registry without certs")
|
||||
f.StringVar(&o.certFile, "cert-file", "", "identify registry client using this SSL certificate file")
|
||||
f.StringVar(&o.keyFile, "key-file", "", "identify registry client using this SSL key file")
|
||||
f.StringVar(&o.caFile, "ca-file", "", "verify certificates of HTTPS-enabled servers using this CA bundle")
|
||||
|
||||
@@ -28,6 +28,7 @@ type RegistryLogin struct {
|
||||
certFile string
|
||||
keyFile string
|
||||
caFile string
|
||||
insecure bool
|
||||
}
|
||||
|
||||
type RegistryLoginOpt func(*RegistryLogin) error
|
||||
@@ -40,6 +41,14 @@ func WithCertFile(certFile string) RegistryLoginOpt {
|
||||
}
|
||||
}
|
||||
|
||||
// WithKeyFile specifies whether to very certificates when communicating.
|
||||
func WithInsecure(insecure bool) RegistryLoginOpt {
|
||||
return func(r *RegistryLogin) error {
|
||||
r.insecure = insecure
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
// WithKeyFile specifies the path to the key file to use for TLS.
|
||||
func WithKeyFile(keyFile string) RegistryLoginOpt {
|
||||
return func(r *RegistryLogin) error {
|
||||
@@ -74,5 +83,6 @@ func (a *RegistryLogin) Run(out io.Writer, hostname string, username string, pas
|
||||
return a.cfg.RegistryClient.Login(
|
||||
hostname,
|
||||
registry.LoginOptBasicAuth(username, password),
|
||||
registry.LoginOptInsecure(a.insecure),
|
||||
registry.LoginOptTLSClientConfig(a.certFile, a.keyFile, a.caFile))
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ func TestOCIGetter(t *testing.T) {
|
||||
ca, pub, priv := join(cd, "rootca.crt"), join(cd, "crt.pem"), join(cd, "key.pem")
|
||||
timeout := time.Second * 5
|
||||
transport := &http.Transport{}
|
||||
insecureSkipTLSverify := false
|
||||
|
||||
// Test with options
|
||||
g, err = NewOCIGetter(
|
||||
@@ -46,6 +47,7 @@ func TestOCIGetter(t *testing.T) {
|
||||
WithTLSClientConfig(pub, priv, ca),
|
||||
WithTimeout(timeout),
|
||||
WithTransport(transport),
|
||||
WithInsecureSkipVerifyTLS(insecureSkipTLSverify),
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
|
||||
Reference in New Issue
Block a user