diff --git a/pkg/chart/v2/util/coalesce.go b/pkg/chart/v2/util/coalesce.go index a3e0f5ae8..9699faf75 100644 --- a/pkg/chart/v2/util/coalesce.go +++ b/pkg/chart/v2/util/coalesce.go @@ -300,7 +300,7 @@ func coalesceTablesFullKey(printf printFn, dst, src map[string]interface{}, pref } else { printf("warning: cannot overwrite table with non table for %s (%v)", fullkey, val) } - } else if istable(dv) && val != nil { + } else if istable(dv) && val != nil && len(dv.(map[string]interface{})) > 0 { printf("warning: destination for %s is a table. Ignoring non-table value (%v)", fullkey, val) } } diff --git a/pkg/chart/v2/util/coalesce_test.go b/pkg/chart/v2/util/coalesce_test.go index e2c45a435..5ba66ce6d 100644 --- a/pkg/chart/v2/util/coalesce_test.go +++ b/pkg/chart/v2/util/coalesce_test.go @@ -717,6 +717,38 @@ func TestCoalesceValuesWarnings(t *testing.T) { } +func TestCoalesceValuesWarningsWithEmptyDefaultMaps(t *testing.T) { + + c := withDeps(&chart.Chart{ + Metadata: &chart.Metadata{Name: "level1"}, + Values: map[string]interface{}{ + "something": map[string]interface{}{ + "somethingElse": []interface{}{}, + }, + }, + }) + + vals := map[string]interface{}{ + "something": map[string]interface{}{ + "somethingElse": map[string]interface{}{}, + }, + } + + warnings := make([]string, 0) + printf := func(format string, v ...interface{}) { + t.Logf(format, v...) + warnings = append(warnings, fmt.Sprintf(format, v...)) + } + + _, err := coalesce(printf, c, vals, "", false) + if err != nil { + t.Fatal(err) + } + + t.Logf("vals: %v", vals) + assert.NotContains(t, warnings, "warning: destination for level1.something.somethingElse is a table. Ignoring non-table value ([])") +} + func TestConcatPrefix(t *testing.T) { assert.Equal(t, "b", concatPrefix("", "b")) assert.Equal(t, "a.b", concatPrefix("a", "b"))