File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed
internal/controllers/topology/cluster/structuredmerge Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -79,6 +79,7 @@ func filterIntent(ctx *filterIntentInput) bool {
7979 // Ensure we are not leaving empty maps around.
8080 if v , ok := fieldCtx .value .(map [string ]interface {}); ok && len (v ) == 0 {
8181 delete (value , field )
82+ gotDeletions = true
8283 }
8384 }
8485 }
Original file line number Diff line number Diff line change @@ -167,6 +167,27 @@ func Test_filterIgnoredPaths(t *testing.T) {
167167 // we are filtering out spec.foo and then spec given that it is an empty map
168168 },
169169 },
170+ {
171+ name : "Cleanup empty nested maps" ,
172+ ctx : & filterIntentInput {
173+ path : contract.Path {},
174+ value : map [string ]interface {}{
175+ "spec" : map [string ]interface {}{
176+ "bar" : map [string ]interface {}{
177+ "foo" : "123" ,
178+ },
179+ },
180+ },
181+ shouldFilter : isIgnorePath (
182+ []contract.Path {
183+ {"spec" , "bar" , "foo" },
184+ },
185+ ),
186+ },
187+ wantValue : map [string ]interface {}{
188+ // we are filtering out spec.bar.foo and then spec given that it is an empty map
189+ },
190+ },
170191 }
171192 for _ , tt := range tests {
172193 t .Run (tt .name , func (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments