Fix subchart value deletion

Signed-off-by: Mingxiang Xue <mingxiangxue@gmail.com>
pull/7743/head
Mingxiang Xue 6 years ago
parent c0058b53ec
commit 5cc96454f7

@ -47,10 +47,7 @@ func CoalesceValues(chrt *chart.Chart, vals map[string]interface{}) (Values, err
if valsCopy == nil {
valsCopy = make(map[string]interface{})
}
if _, err := coalesce(chrt, valsCopy); err != nil {
return valsCopy, err
}
return coalesceDeps(chrt, valsCopy)
return coalesce(chrt, valsCopy)
}
// coalesce coalesces the dest values and the chart values, giving priority to the dest values.

@ -49,6 +49,10 @@ pequod:
sail: true
ahab:
scope: whale
boat: null
nested:
foo: true
bar: null
`)
func TestCoalesceValues(t *testing.T) {
@ -88,6 +92,7 @@ func TestCoalesceValues(t *testing.T) {
{"{{.pequod.name}}", "pequod"},
{"{{.pequod.ahab.name}}", "ahab"},
{"{{.pequod.ahab.scope}}", "whale"},
{"{{.pequod.ahab.nested.foo}}", "true"},
{"{{.pequod.ahab.global.name}}", "Ishmael"},
{"{{.pequod.ahab.global.subject}}", "Queequeg"},
{"{{.pequod.ahab.global.harpooner}}", "Tashtego"},
@ -120,6 +125,15 @@ func TestCoalesceValues(t *testing.T) {
t.Error("Expected nested boat key to be removed, still present")
}
subchart := v["pequod"].(map[string]interface{})["ahab"].(map[string]interface{})
if _, ok := subchart["boat"]; ok {
t.Error("Expected subchart boat key to be removed, still present")
}
if _, ok := subchart["nested"].(map[string]interface{})["bar"]; ok {
t.Error("Expected subchart nested bar key to be removed, still present")
}
// CoalesceValues should not mutate the passed arguments
is.Equal(valsCopy, vals)
}

@ -1,2 +1,6 @@
scope: ahab
name: ahab
boat: true
nested:
foo: false
bar: true

Loading…
Cancel
Save