Skip to content

Commit

Permalink
Merge pull request #119510 from jpbetz/fix-mutation
Browse files Browse the repository at this point in the history
Fix XValidations deepcopy to copy contents of nested pointers

Kubernetes-commit: 5f380d5be242f6d6e5f60644c6d7a8692897cd09
  • Loading branch information
k8s-publishing-bot committed Jul 21, 2023
2 parents 33bfdc8 + b1b1775 commit ce3ed21
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
8 changes: 5 additions & 3 deletions pkg/apis/apiextensions/deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,11 @@ func (in *JSONSchemaProps) DeepCopy() *JSONSchemaProps {
}

if in.XValidations != nil {
in, out := &in.XValidations, &out.XValidations
*out = make([]ValidationRule, len(*in))
copy(*out, *in)
inValidations, outValidations := &in.XValidations, &out.XValidations
*outValidations = make([]ValidationRule, len(*inValidations))
for i := range *inValidations {
in.XValidations[i].DeepCopyInto(&out.XValidations[i])
}
}

return out
Expand Down
8 changes: 5 additions & 3 deletions pkg/apis/apiextensions/v1/deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,9 +251,11 @@ func (in *JSONSchemaProps) DeepCopy() *JSONSchemaProps {
}

if in.XValidations != nil {
in, out := &in.XValidations, &out.XValidations
*out = make([]ValidationRule, len(*in))
copy(*out, *in)
inValidations, outValidations := &in.XValidations, &out.XValidations
*outValidations = make([]ValidationRule, len(*inValidations))
for i := range *inValidations {
in.XValidations[i].DeepCopyInto(&out.XValidations[i])
}
}

return out
Expand Down
8 changes: 5 additions & 3 deletions pkg/apis/apiextensions/v1beta1/deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,11 @@ func (in *JSONSchemaProps) DeepCopy() *JSONSchemaProps {
}

if in.XValidations != nil {
in, out := &in.XValidations, &out.XValidations
*out = make([]ValidationRule, len(*in))
copy(*out, *in)
inValidations, outValidations := &in.XValidations, &out.XValidations
*outValidations = make([]ValidationRule, len(*inValidations))
for i := range *inValidations {
in.XValidations[i].DeepCopyInto(&out.XValidations[i])
}
}

return out
Expand Down

0 comments on commit ce3ed21

Please sign in to comment.