Merge pull request #107688 from liggitt/prune-array

Fix regression pruning array fields with x-kubernetes-preserve-unknown-fields: true
This commit is contained in:
Kubernetes Prow Robot 2022-01-21 19:55:52 -08:00 committed by GitHub
commit 05701a1309
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -189,7 +189,7 @@ func skipPrune(x interface{}, s *structuralschema.Structural, opts *PruneOptions
case []interface{}:
for i, v := range x {
opts.appendIndex(i)
prune(v, s.Items, opts)
skipPrune(v, s.Items, opts)
opts.parentPath = opts.parentPath[:origPathLen]
}
default:

View File

@ -88,7 +88,8 @@ func TestPrune(t *testing.T) {
"unspecified": "bar",
"unspecifiedObject": {"unspecified": "bar"},
"pruning": {"unspecified": "bar"},
"preserving": {"unspecified": "bar"}
"preserving": {"unspecified": "bar"},
"preservingUnknownType": [{"foo":true},{"bar":true}]
},
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
"foo": {
@ -129,6 +130,10 @@ func TestPrune(t *testing.T) {
Generic: structuralschema.Generic{Type: "object"},
Extensions: structuralschema.Extensions{XPreserveUnknownFields: true},
},
"preservingUnknownType": {
Generic: structuralschema.Generic{Type: ""},
Extensions: structuralschema.Extensions{XPreserveUnknownFields: true},
},
"pruning": {
Generic: structuralschema.Generic{Type: "object"},
},
@ -177,7 +182,8 @@ func TestPrune(t *testing.T) {
"unspecified": "bar",
"unspecifiedObject": {"unspecified": "bar"},
"pruning": {},
"preserving": {"unspecified": "bar"}
"preserving": {"unspecified": "bar"},
"preservingUnknownType": [{"foo":true},{"bar":true}]
},
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
"foo": {