@@ -21,41 +21,28 @@ const (
2121var (
2222 settings helm_env.EnvSettings
2323 DefaultHelmHome = filepath .Join (homedir .HomeDir (), ".helm" )
24-
25- tlsCaCertFile string // path to TLS CA certificate file
26- tlsCertFile string // path to TLS certificate file
27- tlsKeyFile string // path to TLS key file
28- tlsVerify bool // enable TLS and verify remote certificates
29- tlsEnable bool // enable TLS
3024)
3125
3226func addCommonCmdOptions (f * flag.FlagSet ) {
33- f .StringVar (& tlsCaCertFile , "tls-ca-cert" , tlsCaCertDefault , "path to TLS CA certificate file" )
34- f .StringVar (& tlsCertFile , "tls-cert" , tlsCertDefault , "path to TLS certificate file" )
35- f .StringVar (& tlsKeyFile , "tls-key" , tlsKeyDefault , "path to TLS key file" )
36- f .BoolVar (& tlsVerify , "tls-verify" , false , "enable TLS for request and verify remote" )
37- f .BoolVar (& tlsEnable , "tls" , false , "enable TLS for request" )
27+ settings .AddFlagsTLS (f )
28+ settings .InitTLS (f )
3829
3930 f .StringVar ((* string )(& settings .Home ), "home" , DefaultHelmHome , "location of your Helm config. Overrides $HELM_HOME" )
4031}
4132
4233func createHelmClient () helm.Interface {
4334 options := []helm.Option {helm .Host (os .Getenv ("TILLER_HOST" )), helm .ConnectTimeout (int64 (30 ))}
4435
45- if tlsVerify || tlsEnable {
46- if tlsCaCertFile == "" {
47- tlsCaCertFile = settings .Home .TLSCaCert ()
48- }
49- if tlsCertFile == "" {
50- tlsCertFile = settings .Home .TLSCert ()
51- }
52- if tlsKeyFile == "" {
53- tlsKeyFile = settings .Home .TLSKey ()
36+ if settings .TLSVerify || settings .TLSEnable {
37+ tlsopts := tlsutil.Options {
38+ ServerName : settings .TLSServerName ,
39+ KeyFile : settings .TLSKeyFile ,
40+ CertFile : settings .TLSCertFile ,
41+ InsecureSkipVerify : true ,
5442 }
5543
56- tlsopts := tlsutil.Options {KeyFile : tlsKeyFile , CertFile : tlsCertFile , InsecureSkipVerify : true }
57- if tlsVerify {
58- tlsopts .CaCertFile = tlsCaCertFile
44+ if settings .TLSVerify {
45+ tlsopts .CaCertFile = settings .TLSCaCertFile
5946 tlsopts .InsecureSkipVerify = false
6047 }
6148
@@ -72,7 +59,7 @@ func createHelmClient() helm.Interface {
7259}
7360
7461func expandTLSPaths () {
75- tlsCaCertFile = os .ExpandEnv (tlsCaCertFile )
76- tlsCertFile = os .ExpandEnv (tlsCertFile )
77- tlsKeyFile = os .ExpandEnv (tlsKeyFile )
62+ settings . TLSCaCertFile = os .ExpandEnv (settings . TLSCaCertFile )
63+ settings . TLSCertFile = os .ExpandEnv (settings . TLSCertFile )
64+ settings . TLSKeyFile = os .ExpandEnv (settings . TLSKeyFile )
7865}
0 commit comments