fix(values): preserve nil values when chart default is empty map#31644
fix(values): preserve nil values when chart default is empty map#31644
Conversation
Only delete nil user values when overriding a non-nil chart default.
When chart has empty map or no default for a key, preserve user's nil.
| Scenario | Result |
|----------|--------|
| User sets `baz: ~`, chart has `baz: "value"` | Key deleted |
| User sets `baz: ~`, chart has empty map `{}` | Nil preserved |
| User sets `baz: ~`, chart has `baz: ~` | Nil preserved |
Fixes helm#31643
Signed-off-by: Evans Mungai <mbuevans@gmail.com>
Signed-off-by: Evans Mungai <mbuevans@gmail.com>
Signed-off-by: Evans Mungai <mbuevans@gmail.com>
| // otherwise the values are coalesced. | ||
| CoalesceTables(dst, src) | ||
|
|
||
| is.Equal("Ishmael", dst["name"], "Unexpected name: %s", dst["name"]) |
There was a problem hiding this comment.
Would it be okay to split this refactoring of conditional logic to assert into a new PR. Why assert (IMHO) is much better for test readability, it is difficult here to review any logic changes (due to any changes in the code logic)
| if !ok { | ||
| t.Fatal("Address went away.") | ||
| } | ||
| t.Run("case 1", func(t *testing.T) { |
There was a problem hiding this comment.
Perhaps this and the below t.Run(... separate test cases?
(but see my comment below about creating a new PR for these refactoring changes)
Co-authored-by: George Jenkins <gvjenkins@gmail.com> Signed-off-by: Evans Mungai <mbuevans@gmail.com>
Signed-off-by: Evans Mungai <mbuevans@gmail.com>
Signed-off-by: Evans Mungai <mbuevans@gmail.com>
|
@gjenkins8 I removed all the test refactoring changes and left the unit test validating the reported bug |
|
I have verified the fix for my use case and it appears to work. |
|
Could you please merge this into 3.20 branch too? We could build that ourselves then for our testing. |
Three test cases that cover the regression scenarios introduced by the helm#31644 nil preservation fix: - subchart default nils should be cleaned up when parent doesn't set those keys (helm#31919) - user-supplied null should erase subchart defaults (helm#31919) - subchart default nil should not shadow global values via pluck (helm#31971) Tests are expected to fail until the regression is fixed.
Three test cases that cover the regression scenarios introduced by the helm#31644 nil preservation fix: - subchart default nils should be cleaned up when parent doesn't set those keys (helm#31919) - user-supplied null should erase subchart defaults (helm#31919) - subchart default nil should not shadow global values via pluck (helm#31971) Tests are expected to fail until the regression is fixed.
Three test cases that cover the regression scenarios introduced by the helm#31644 nil preservation fix: - subchart default nils should be cleaned up when parent doesn't set those keys (helm#31919) - user-supplied null should erase subchart defaults (helm#31919) - subchart default nil should not shadow global values via pluck (helm#31971) Tests are expected to fail until the regression is fixed.
Three test cases that cover the regression scenarios introduced by the helm#31644 nil preservation fix: - subchart default nils should be cleaned up when parent doesn't set those keys (helm#31919) - user-supplied null should erase subchart defaults (helm#31919) - subchart default nil should not shadow global values via pluck (helm#31971) Tests are expected to fail until the regression is fixed.
Three test cases that cover the regression scenarios introduced by the helm#31644 nil preservation fix: - subchart default nils should be cleaned up when parent doesn't set those keys (helm#31919) - user-supplied null should erase subchart defaults (helm#31919) - subchart default nil should not shadow global values via pluck (helm#31971) Tests are expected to fail until the regression is fixed. Signed-off-by: Johannes Lohmer <jojo.dev@lohmer.com>
Three test cases that cover the regression scenarios introduced by the helm#31644 nil preservation fix: - subchart default nils should be cleaned up when parent doesn't set those keys (helm#31919) - user-supplied null should erase subchart defaults (helm#31919) - subchart default nil should not shadow global values via pluck (helm#31971) Tests are expected to fail until the regression is fixed. Signed-off-by: Johannes Lohmer <jojo.dev@lohmer.com>
What this PR does / why we need it:
Only delete nil user values when overriding a non-nil chart default. When chart has empty map or no default for a key, preserve user's nil.
baz: ~, chart hasbaz: "value"baz: ~, chart has empty map{}baz: ~, chart hasbaz: ~Fixes #31643
Special notes for your reviewer:
If applicable:
docs neededlabel should be applied if so)