mirror of
https://github.com/helm/helm.git
synced 2026-05-28 04:35:48 -04:00
Merge pull request #1063 from devth/feat/value-merging
Include values from both --set and --values when specified on install
This commit is contained in:
commit
3181f70790
2 changed files with 37 additions and 5 deletions
|
|
@ -147,13 +147,28 @@ func (i *installCmd) run() 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 {
|
||||
return i.values.yaml()
|
||||
bytes, err := i.values.yaml()
|
||||
if err != nil {
|
||||
return []byte{}, err
|
||||
}
|
||||
buffer.Write(bytes)
|
||||
}
|
||||
if i.valuesFile == "" {
|
||||
return []byte{}, nil
|
||||
}
|
||||
return ioutil.ReadFile(i.valuesFile)
|
||||
|
||||
return buffer.Bytes(), nil
|
||||
}
|
||||
|
||||
func (i *installCmd) printRelease(rel *release.Release) {
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue