pull/32176/merge
SUNIL KOTTE 3 months ago committed by GitHub
commit 6f6dd466ad
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) 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 {
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 return dst

@ -932,3 +932,34 @@ func TestCoalesceValuesSubchartNilCleanedWhenUserPartiallyOverrides(t *testing.T
_, ok = keyMapping["password"] _, ok = keyMapping["password"]
is.False(ok, "Expected keyMapping.password (nil from chart defaults) to be removed even when user partially overrides the map") 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