Skip to content

Commit 30226e6

Browse files
authored
Merge pull request kubernetes#127435 from sttts/sttts-getmanagedfields-nocopy
unstructured: avoid deepcopying managedFields
2 parents 24a447e + 9705cbe commit 30226e6

File tree

1 file changed

+5
-1
lines changed
  • staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured

1 file changed

+5
-1
lines changed

staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured/unstructured.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,10 +450,14 @@ func (u *Unstructured) SetFinalizers(finalizers []string) {
450450
}
451451

452452
func (u *Unstructured) GetManagedFields() []metav1.ManagedFieldsEntry {
453-
items, found, err := NestedSlice(u.Object, "metadata", "managedFields")
453+
v, found, err := NestedFieldNoCopy(u.Object, "metadata", "managedFields")
454454
if !found || err != nil {
455455
return nil
456456
}
457+
items, ok := v.([]interface{})
458+
if !ok {
459+
return nil
460+
}
457461
managedFields := []metav1.ManagedFieldsEntry{}
458462
for _, item := range items {
459463
m, ok := item.(map[string]interface{})

0 commit comments

Comments
 (0)