Merge pull request #1063 from devth/feat/value-merging

Include values from both --set and --values when specified on install
pull/1073/head
Matt Butcher 8 years ago committed by GitHub
commit 3181f70790

@ -147,13 +147,28 @@ func (i *installCmd) run() error {
} }
func (i *installCmd) vals() ([]byte, error) { func (i *installCmd) vals() ([]byte, error) {
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)
}
// User specified value pairs via --set
// These override any values in the specified file
if len(i.values.pairs) > 0 { if len(i.values.pairs) > 0 {
return i.values.yaml() bytes, err := i.values.yaml()
if err != nil {
return []byte{}, err
} }
if i.valuesFile == "" { buffer.Write(bytes)
return []byte{}, nil
} }
return ioutil.ReadFile(i.valuesFile)
return buffer.Bytes(), nil
} }
func (i *installCmd) printRelease(rel *release.Release) { func (i *installCmd) printRelease(rel *release.Release) {

@ -121,6 +121,23 @@ sailor: sinbad
if vobj.String() != y { if vobj.String() != y {
t.Errorf("Expected String() to be \n%s\nGot\n%s\n", y, out) 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 { type nameTemplateTestCase struct {

Loading…
Cancel
Save