@@ -21,41 +21,28 @@ const (
21
21
var (
22
22
settings helm_env.EnvSettings
23
23
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
30
24
)
31
25
32
26
func 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 )
38
29
39
30
f .StringVar ((* string )(& settings .Home ), "home" , DefaultHelmHome , "location of your Helm config. Overrides $HELM_HOME" )
40
31
}
41
32
42
33
func createHelmClient () helm.Interface {
43
34
options := []helm.Option {helm .Host (os .Getenv ("TILLER_HOST" )), helm .ConnectTimeout (int64 (30 ))}
44
35
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 ,
54
42
}
55
43
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
59
46
tlsopts .InsecureSkipVerify = false
60
47
}
61
48
@@ -72,7 +59,7 @@ func createHelmClient() helm.Interface {
72
59
}
73
60
74
61
func 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 )
78
65
}
0 commit comments