Skip to content

Commit

Permalink
Fix subchart values not being deleted by setting value to nil in pare…
Browse files Browse the repository at this point in the history
…nt chart's values

Signed-off-by: Stefan Deitmer <stefan.deitmer@gec.io>
  • Loading branch information
Stefan Deitmer committed Jul 25, 2019
1 parent 8cacb2c commit e53613d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions pkg/chartutil/testdata/moby/charts/spouter/values.yaml
@@ -1 +1,2 @@
scope: spouter
foo: bar
4 changes: 4 additions & 0 deletions pkg/chartutil/testdata/moby/values.yaml
Expand Up @@ -22,3 +22,7 @@ web:
httpGet:
path: /api/v1/info
port: atc

# for testing deleting default values in sub charts
spouter:
foo: null
5 changes: 1 addition & 4 deletions pkg/chartutil/values.go
Expand Up @@ -170,10 +170,7 @@ func CoalesceValues(chrt *chart.Chart, vals *chart.Config) (Values, error) {
if err != nil {
return cvals, err
}
cvals, err = coalesce(chrt, evals)
if err != nil {
return cvals, err
}
return coalesce(chrt, evals)
}

return coalesceDeps(chrt, cvals)
Expand Down
27 changes: 27 additions & 0 deletions pkg/chartutil/values_test.go
Expand Up @@ -475,6 +475,33 @@ func TestCoalesceTables(t *testing.T) {
t.Errorf("Expected boat string, got %v", dst["boat"])
}
}

func TestCoalesceSubchart(t *testing.T) {
tchart := "testdata/moby"
c, err := LoadDir(tchart)
if err != nil {
t.Fatal(err)
}

tvals := &chart.Config{}

v, err := CoalesceValues(c, tvals)
if err != nil {
t.Fatal(err)
}
j, _ := json.MarshalIndent(v, "", " ")
t.Logf("Coalesced Values: %s", string(j))

subchartValues, ok := v["spouter"].(map[string]interface{})
if !ok {
t.Errorf("Subchart values not found")
}

if _, ok := subchartValues["foo"]; ok {
t.Errorf("Expected key foo to be removed, still present")
}
}

func TestPathValue(t *testing.T) {
doc := `
title: "Moby Dick"
Expand Down

0 comments on commit e53613d

Please sign in to comment.