SUNIL KOTTE 3 days ago committed by GitHub
commit 1859a164ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -350,7 +350,11 @@ func coalesceTablesFullKey(printf printFn, dst, src map[string]any, prefix strin
printf("warning: cannot overwrite table with non table for %s (%v)", fullkey, val)
}
} else if istable(dv) && val != nil {
printf("warning: destination for %s is a table. Ignoring non-table value (%v)", fullkey, val)
// Suppress warning when user supplies an empty map (nil-like);
// still warn for non-map values and non-empty maps.
if m, ok := val.(map[string]any); !ok || len(m) > 0 {
printf("warning: destination for %s is a table. Ignoring non-table value (%v)", fullkey, val)
}
}
}
return dst

@ -926,3 +926,34 @@ func TestCoalesceValuesSubchartNilCleanedWhenUserPartiallyOverrides(t *testing.T
_, ok = keyMapping["password"]
is.False(ok, "Expected keyMapping.password (nil from chart defaults) to be removed even when user partially overrides the map")
}
func TestCoalesceValuesEmptyMapNoWarning(t *testing.T) {
warnings := make([]string, 0)
printf := func(format string, v ...any) {
t.Logf(format, v...)
warnings = append(warnings, fmt.Sprintf(format, v...))
}
// Chart default has a map key "data"
c := &chart.Chart{
Metadata: &chart.Metadata{Name: "test"},
Values: map[string]any{
"data": map[string]any{
"existing": "value",
},
},
}
// User supplies an empty map for "data" should NOT trigger a warning
vals := map[string]any{
"data": map[string]any{},
}
_, err := coalesce(printf, c, vals, "", false)
if err != nil {
t.Fatal(err)
}
if len(warnings) > 0 {
t.Errorf("expected no warnings, but got: %v", warnings)
}
}

Loading…
Cancel
Save