From dacc4013c178d48962bb5c898848b518e33db806 Mon Sep 17 00:00:00 2001 From: Trevor Hartman Date: Tue, 16 Aug 2016 18:07:51 -0600 Subject: [PATCH 1/2] Include values from both --set and --values when specified on install --- cmd/helm/install.go | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/cmd/helm/install.go b/cmd/helm/install.go index b526ea090..b41669d24 100644 --- a/cmd/helm/install.go +++ b/cmd/helm/install.go @@ -147,13 +147,28 @@ func (i *installCmd) run() error { } func (i *installCmd) vals() ([]byte, error) { - if len(i.values.pairs) > 0 { - return i.values.yaml() + var buffer bytes.Buffer + + // User specified a values file via -f/--values + if i.valuesFile != "" { + bytes, err := ioutil.ReadFile(i.valuesFile) + if err != nil { + return []byte{}, err + } + buffer.Write(bytes) } - if i.valuesFile == "" { - return []byte{}, nil + + // User specified value pairs via --set + // These override any values in the specified file + if len(i.values.pairs) > 0 { + bytes, err := i.values.yaml() + if err != nil { + return []byte{}, err + } + buffer.Write(bytes) } - return ioutil.ReadFile(i.valuesFile) + + return buffer.Bytes(), nil } func (i *installCmd) printRelease(rel *release.Release) { From edd6fd7465c012ccefa8524a9679602a7d2393d5 Mon Sep 17 00:00:00 2001 From: Trevor Hartman Date: Wed, 17 Aug 2016 12:47:40 -0600 Subject: [PATCH 2/2] Test overriding a property in TestValues --- cmd/helm/install_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cmd/helm/install_test.go b/cmd/helm/install_test.go index 7043eee6d..7bc44702e 100644 --- a/cmd/helm/install_test.go +++ b/cmd/helm/install_test.go @@ -121,6 +121,23 @@ sailor: sinbad if vobj.String() != y { t.Errorf("Expected String() to be \n%s\nGot\n%s\n", y, out) } + + // Combined case, overriding a property + vals["sailor"] = "pisti" + updated_yaml := `good: true +port: + destination: basrah + source: baghdad +sailor: pisti +` + new_out, err := vobj.yaml() + if err != nil { + t.Fatal(err) + } + if string(new_out) != updated_yaml { + t.Errorf("Expected YAML to be \n%s\nGot\n%s\n", updated_yaml, new_out) + } + } type nameTemplateTestCase struct {