Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@

## Unreleased

### Fixed

- Fixed `valueYamlFiles` entries containing an empty list (`[]`) being silently dropped when `allowNullValues` is false (the default), causing Helm to fall back to chart defaults instead of honouring the override.

### Added

- [#2280](https://github.com/pulumi/pulumi-kubernetes/issues/2280) Add `enablePatchForce` provider config option to force SSA patch conflicts on a per-stack basis.
Expand Down
2 changes: 1 addition & 1 deletion provider/pkg/provider/helm_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -1418,7 +1418,7 @@ func excludeNulls(in any) any {
}
return out
case reflect.Slice, reflect.Array:
var out []any
out := make([]any, 0)
s := in.([]any)
for _, i := range s {
if i != nil {
Expand Down
43 changes: 43 additions & 0 deletions provider/pkg/provider/helm_release_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,34 @@ func Test_MergeMaps(t *testing.T) {
"list": []any{},
},
},
{
// Confirm that a key absent from src leaves the dest value intact (i.e. our
// fix to excludeNulls does not accidentally introduce spurious empty-list keys).
name: "key absent from src leaves dest list intact with allowNil=false",
allowNil: false,
dest: map[string]any{
"list": []any{"default"},
},
src: map[string]any{},
expected: map[string]any{
"list": []any{"default"},
},
},
{
// Bug: excludeNulls returns nil (not []any{}) for an empty slice, causing the
// empty-list override to be indistinguishable from a missing key.
name: "empty list overrides non-empty list with allowNil=false",
allowNil: false,
dest: map[string]any{
"list": []any{1, 2, 3},
},
src: map[string]any{
"list": []any{},
},
expected: map[string]any{
"list": []any{},
},
},
{
name: "allow nil doesn't clear objects",
allowNil: true,
Expand Down Expand Up @@ -333,6 +361,21 @@ images: ["bitnami/nginx"]
},
},
},
{
// Bug: valueYamlFiles containing an empty list should override the chart default,
// but excludeNulls collapses []any{} to nil, making it disappear as if unset.
name: "valueYamlFiles with empty list is preserved (allowNullValues=false)",
given: resource.PropertyMap{
"valueYamlFiles": resource.NewArrayProperty([]resource.PropertyValue{
resource.NewAssetProperty(&asset.Asset{Text: "items: []\n"}),
}),
},
want: &Release{
Values: map[string]any{
"items": []any{},
},
},
},
{
name: "valueYamlFiles provided, but is nil",
given: resource.PropertyMap{
Expand Down
Loading