Support values files on remote servers with self-signed certs / client cert authentication (#4003)

* support tls for values file access

- uses --ca-file / --cert-file / --key-file

* also for upgrade command
pull/3973/merge
Doug Winter 7 years ago committed by Matt Butcher
parent 26943763a1
commit 32bd9d82e8

@ -220,7 +220,7 @@ func (i *installCmd) run() error {
i.namespace = defaultNamespace() i.namespace = defaultNamespace()
} }
rawVals, err := vals(i.valueFiles, i.values, i.stringValues) rawVals, err := vals(i.valueFiles, i.values, i.stringValues, i.certFile, i.keyFile, i.caFile)
if err != nil { if err != nil {
return err return err
} }
@ -335,7 +335,7 @@ func mergeValues(dest map[string]interface{}, src map[string]interface{}) map[st
// vals merges values from files specified via -f/--values and // vals merges values from files specified via -f/--values and
// directly via --set or --set-string, marshaling them to YAML // directly via --set or --set-string, marshaling them to YAML
func vals(valueFiles valueFiles, values []string, stringValues []string) ([]byte, error) { func vals(valueFiles valueFiles, values []string, stringValues []string, CertFile, KeyFile, CAFile string) ([]byte, error) {
base := map[string]interface{}{} base := map[string]interface{}{}
// User specified a values files via -f/--values // User specified a values files via -f/--values
@ -347,7 +347,7 @@ func vals(valueFiles valueFiles, values []string, stringValues []string) ([]byte
if strings.TrimSpace(filePath) == "-" { if strings.TrimSpace(filePath) == "-" {
bytes, err = ioutil.ReadAll(os.Stdin) bytes, err = ioutil.ReadAll(os.Stdin)
} else { } else {
bytes, err = readFile(filePath) bytes, err = readFile(filePath, CertFile, KeyFile, CAFile)
} }
if err != nil { if err != nil {
@ -512,7 +512,7 @@ func checkDependencies(ch *chart.Chart, reqs *chartutil.Requirements) error {
} }
//readFile load a file from the local directory or a remote file with a url. //readFile load a file from the local directory or a remote file with a url.
func readFile(filePath string) ([]byte, error) { func readFile(filePath, CertFile, KeyFile, CAFile string) ([]byte, error) {
u, _ := url.Parse(filePath) u, _ := url.Parse(filePath)
p := getter.All(settings) p := getter.All(settings)
@ -523,7 +523,7 @@ func readFile(filePath string) ([]byte, error) {
return ioutil.ReadFile(filePath) return ioutil.ReadFile(filePath)
} }
getter, err := getterConstructor(filePath, "", "", "") getter, err := getterConstructor(filePath, CertFile, KeyFile, CAFile)
if err != nil { if err != nil {
return []byte{}, err return []byte{}, err
} }

@ -130,7 +130,7 @@ func (t *templateCmd) run(cmd *cobra.Command, args []string) error {
t.namespace = defaultNamespace() t.namespace = defaultNamespace()
} }
// get combined values and create config // get combined values and create config
rawVals, err := vals(t.valueFiles, t.values, t.stringValues) rawVals, err := vals(t.valueFiles, t.values, t.stringValues, "", "", "")
if err != nil { if err != nil {
return err return err
} }

@ -195,7 +195,7 @@ func (u *upgradeCmd) run() error {
} }
} }
rawVals, err := vals(u.valueFiles, u.values, u.stringValues) rawVals, err := vals(u.valueFiles, u.values, u.stringValues, u.certFile, u.keyFile, u.caFile)
if err != nil { if err != nil {
return err return err
} }

Loading…
Cancel
Save