Skip to content

Commit

Permalink
Merge pull request #6796 from k8s-infra-cherrypick-robot/cherry-pick-…
Browse files Browse the repository at this point in the history
…6785-to-release-1.2

[release-1.2] 🐛 fix structuredmerge filterintent to cleanup nested empty maps
  • Loading branch information
k8s-ci-robot authored Jun 30, 2022
2 parents 67c4f9f + d8aad53 commit 33ba099
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ func filterIntent(ctx *filterIntentInput) bool {
// Ensure we are not leaving empty maps around.
if v, ok := fieldCtx.value.(map[string]interface{}); ok && len(v) == 0 {
delete(value, field)
gotDeletions = true
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,27 @@ func Test_filterIgnoredPaths(t *testing.T) {
// we are filtering out spec.foo and then spec given that it is an empty map
},
},
{
name: "Cleanup empty nested maps",
ctx: &filterIntentInput{
path: contract.Path{},
value: map[string]interface{}{
"spec": map[string]interface{}{
"bar": map[string]interface{}{
"foo": "123",
},
},
},
shouldFilter: isIgnorePath(
[]contract.Path{
{"spec", "bar", "foo"},
},
),
},
wantValue: map[string]interface{}{
// we are filtering out spec.bar.foo and then spec given that it is an empty map
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 33ba099

Please sign in to comment.