mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +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{}:
|
case []interface{}:
|
||||||
for i, v := range x {
|
for i, v := range x {
|
||||||
opts.appendIndex(i)
|
opts.appendIndex(i)
|
||||||
prune(v, s.Items, opts)
|
skipPrune(v, s.Items, opts)
|
||||||
opts.parentPath = opts.parentPath[:origPathLen]
|
opts.parentPath = opts.parentPath[:origPathLen]
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -88,7 +88,8 @@ func TestPrune(t *testing.T) {
|
|||||||
"unspecified": "bar",
|
"unspecified": "bar",
|
||||||
"unspecifiedObject": {"unspecified": "bar"},
|
"unspecifiedObject": {"unspecified": "bar"},
|
||||||
"pruning": {"unspecified": "bar"},
|
"pruning": {"unspecified": "bar"},
|
||||||
"preserving": {"unspecified": "bar"}
|
"preserving": {"unspecified": "bar"},
|
||||||
|
"preservingUnknownType": [{"foo":true},{"bar":true}]
|
||||||
},
|
},
|
||||||
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
|
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
|
||||||
"foo": {
|
"foo": {
|
||||||
@ -129,6 +130,10 @@ func TestPrune(t *testing.T) {
|
|||||||
Generic: structuralschema.Generic{Type: "object"},
|
Generic: structuralschema.Generic{Type: "object"},
|
||||||
Extensions: structuralschema.Extensions{XPreserveUnknownFields: true},
|
Extensions: structuralschema.Extensions{XPreserveUnknownFields: true},
|
||||||
},
|
},
|
||||||
|
"preservingUnknownType": {
|
||||||
|
Generic: structuralschema.Generic{Type: ""},
|
||||||
|
Extensions: structuralschema.Extensions{XPreserveUnknownFields: true},
|
||||||
|
},
|
||||||
"pruning": {
|
"pruning": {
|
||||||
Generic: structuralschema.Generic{Type: "object"},
|
Generic: structuralschema.Generic{Type: "object"},
|
||||||
},
|
},
|
||||||
@ -177,7 +182,8 @@ func TestPrune(t *testing.T) {
|
|||||||
"unspecified": "bar",
|
"unspecified": "bar",
|
||||||
"unspecifiedObject": {"unspecified": "bar"},
|
"unspecifiedObject": {"unspecified": "bar"},
|
||||||
"pruning": {},
|
"pruning": {},
|
||||||
"preserving": {"unspecified": "bar"}
|
"preserving": {"unspecified": "bar"},
|
||||||
|
"preservingUnknownType": [{"foo":true},{"bar":true}]
|
||||||
},
|
},
|
||||||
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
|
"preservingAdditionalPropertiesNotInheritingXPreserveUnknownFields": {
|
||||||
"foo": {
|
"foo": {
|
||||||
|
Loading…
Reference in New Issue
Block a user