Skip to content

Commit 02eb440

Browse files
Update typed/remove.go
Co-authored-by: Joe Betz <[email protected]>
1 parent 52f5ac0 commit 02eb440

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

typed/remove.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,13 @@ func (w *removingWalker) doList(t *schema.List) (errs ValidationErrors) {
8080
path, _ := fieldpath.MakePath(pe)
8181
// save items on the path when we shouldExtract
8282
// but ignore them when we are removing (i.e. !w.shouldExtract)
83+
itemsInToRemoveSubpaths := !w.toRemove.WithPrefix(pe).Empty()
8384
if w.shouldExtract {
84-
if w.toRemove.Has(path) || !w.toRemove.WithPrefix(pe).Empty() {
85-
if !w.toRemove.WithPrefix(pe).Empty() {
86-
// Continue if there are subset paths
87-
item = removeItemsWithSchema(item, w.toRemove.WithPrefix(pe), w.schema, t.ElementType, w.shouldExtract)
88-
}
85+
if itemInToRemoveSubpaths {
86+
// Continue if there are subset paths
87+
item = removeItemsWithSchema(item, w.toRemove.WithPrefix(pe), w.schema, t.ElementType, w.shouldExtract)
88+
}
89+
if w.toRemove.Has(path) || itemInToRemoveSubpaths {
8990
newItems = append(newItems, item.Unstructured())
9091
}
9192
} else {

0 commit comments

Comments
 (0)