mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
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:
commit
05701a1309
@ -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:
|
||||
|
@ -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": {
|
||||
|
Loading…
Reference in New Issue
Block a user