-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Switch to use .DeepCopy() instead of kapi.Scheme.DeepCopy() #17444
Switch to use .DeepCopy() instead of kapi.Scheme.DeepCopy() #17444
Conversation
/assign sttts |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
@bparees tagging you because this is interesting change and you also used DeepCopy() in many places. |
e8e7b56
to
eab83cc
Compare
/retest |
for _, r := range tc.Rules { | ||
rPtr := &r | ||
copy := rPtr.DeepCopy() | ||
originalRules = append(originalRules, *copy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit:
originalRules := make([]authorizationapi.PolicyRule, len(tc.Rules))
...
rPtr.DeepCopyInto(&originalRules[i])
previousTagHistoryCopy := map[string]imageapi.TagEventList{} | ||
for k, v := range previousTagHistory { | ||
ptrVal := v.DeepCopy() | ||
previousTagHistory[k] = *ptrVal |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: *v.DeepCopy()
err.Field = "spec.template." + err.Field | ||
allErrs = append(allErrs, err) | ||
} | ||
templatePtr := &templateInstance.Spec.Template |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is that Ptr var really necessary? Go should be clever enough to infer that.
return field.ErrorList{field.InternalError(field.NewPath(""), err)} | ||
} | ||
oldTemplateInstance := oldcopy.(*templateapi.TemplateInstance) | ||
oldTemplateInstanceCopy := old.DeepCopyObject() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can old be nil?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i don't think it can be nil, but I will double check
eab83cc
to
ff3c080
Compare
@sttts comments addressed, thanks |
continue | ||
originalRules := make([]authorizationapi.PolicyRule, len(tc.Rules)) | ||
for i, r := range tc.Rules { | ||
rPtr := &r |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this line is not necessary anymore I guess.
} | ||
err = r.ImageChanged(test.obj, fakeTagRetriever(test.tags)) | ||
initial := test.obj.DeepCopy() | ||
err := r.ImageChanged(test.obj, fakeTagRetriever(test.tags)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is odd. The r.ImageChanged func mutates test.obj?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think the test guards against mutation (see the line below)
@sttts updated |
ff3c080
to
d485992
Compare
/hold Realized there is also kapi.Scheme.Copy()... |
/hold cancel |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mfojtik, sttts The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/retest |
/refresh |
/retest Please review the full test history for this PR and help us cut down flakes. |
8 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
@mfojtik: The following test failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Automatic merge from submit-queue. |
The later will not work in k8s 1.9 (@sttts to confirm). The first commit is just mechanical update.
The second commit is needed because image trigger controller used DeepCopy on interface{}.
@smarterclayton I switched that to be
runtime.Object
and nothing seems to be complaining. PTAL.