Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 13 additions & 26 deletions cmd/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,41 +21,28 @@ const (
var (
settings helm_env.EnvSettings
DefaultHelmHome = filepath.Join(homedir.HomeDir(), ".helm")

tlsCaCertFile string // path to TLS CA certificate file
tlsCertFile string // path to TLS certificate file
tlsKeyFile string // path to TLS key file
tlsVerify bool // enable TLS and verify remote certificates
tlsEnable bool // enable TLS
)

func addCommonCmdOptions(f *flag.FlagSet) {
f.StringVar(&tlsCaCertFile, "tls-ca-cert", tlsCaCertDefault, "path to TLS CA certificate file")
f.StringVar(&tlsCertFile, "tls-cert", tlsCertDefault, "path to TLS certificate file")
f.StringVar(&tlsKeyFile, "tls-key", tlsKeyDefault, "path to TLS key file")
f.BoolVar(&tlsVerify, "tls-verify", false, "enable TLS for request and verify remote")
f.BoolVar(&tlsEnable, "tls", false, "enable TLS for request")
settings.AddFlagsTLS(f)
settings.InitTLS(f)

f.StringVar((*string)(&settings.Home), "home", DefaultHelmHome, "location of your Helm config. Overrides $HELM_HOME")
}

func createHelmClient() helm.Interface {
options := []helm.Option{helm.Host(os.Getenv("TILLER_HOST")), helm.ConnectTimeout(int64(30))}

if tlsVerify || tlsEnable {
if tlsCaCertFile == "" {
tlsCaCertFile = settings.Home.TLSCaCert()
}
if tlsCertFile == "" {
tlsCertFile = settings.Home.TLSCert()
}
if tlsKeyFile == "" {
tlsKeyFile = settings.Home.TLSKey()
if settings.TLSVerify || settings.TLSEnable {
tlsopts := tlsutil.Options{
ServerName: settings.TLSServerName,
KeyFile: settings.TLSKeyFile,
CertFile: settings.TLSCertFile,
InsecureSkipVerify: true,
}

tlsopts := tlsutil.Options{KeyFile: tlsKeyFile, CertFile: tlsCertFile, InsecureSkipVerify: true}
if tlsVerify {
tlsopts.CaCertFile = tlsCaCertFile
if settings.TLSVerify {
tlsopts.CaCertFile = settings.TLSCaCertFile
tlsopts.InsecureSkipVerify = false
}

Expand All @@ -72,7 +59,7 @@ func createHelmClient() helm.Interface {
}

func expandTLSPaths() {
tlsCaCertFile = os.ExpandEnv(tlsCaCertFile)
tlsCertFile = os.ExpandEnv(tlsCertFile)
tlsKeyFile = os.ExpandEnv(tlsKeyFile)
settings.TLSCaCertFile = os.ExpandEnv(settings.TLSCaCertFile)
settings.TLSCertFile = os.ExpandEnv(settings.TLSCertFile)
settings.TLSKeyFile = os.ExpandEnv(settings.TLSKeyFile)
}