-
Notifications
You must be signed in to change notification settings - Fork 1.4k
⚠️ Change ClusterResourceSetBinding Bindings field from []*ResourceSetBinding to []ResourceSetBinding #12476
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
Conversation
/test pull-cluster-api-e2e-main |
/assign @fabriziopandini @JoelSpeed @sivchari @mboersma |
a711313
to
55cf6dc
Compare
/test pull-cluster-api-e2e-main |
[]*ResourceSetBinding to []ResourceSetBinding Signed-off-by: Stefan Büringer buringerst@vmware.com
/test pull-cluster-api-e2e-main |
@sbueringer: 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-sigs/prow repository. I understand the commands that are listed here. |
/override pull-cluster-api-e2e-main |
@sbueringer: Overrode contexts on behalf of sbueringer: pull-cluster-api-e2e-main In response to this:
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-sigs/prow repository. |
/lgtm |
LGTM label has been added. Git tree hash: b972e176da7c4ea4cb7bc6ea93a35f42dabe55aa
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: JoelSpeed The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold do we want anyone else to check on this first? |
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
I left nit, but if you decide to go with it, feel free to merge.
for _, binding := range c.Spec.Bindings { | ||
if binding.ClusterResourceSetName == clusterResourceSet.Name { | ||
return binding | ||
for i := range c.Spec.Bindings { |
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've read the discussion and commented.
I can confirm that the copyloopvar linter is already in place and the original code is fine.
but it's certainly a good idea to keep it this way in terms of visualization.
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.
The original code was not fine, that's why I changed it :) (tests broke)
The original code with the pointer change returned a copy of the binding and not the same binding that is part of the c.Spec.Bindings slice
The code is fine for the linter, but that doesn't mean it works as expected :)
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.
Interesting. Surely the only this codes aren't problem, but considering about entire code base, the copy element might be invalid. This case is good example.
Thanks!
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.
To give some more context.
The previous problem (a few Go versions ago) with returning a pointer to a loop var was that the pointer was basically always referring to the last element that was stored in the loop var.
Then they changed it in go so a pointer to the loop var refers to the correct element.
But the loop var is a copy of the slice element not the actual element
c.Spec.Bindings = append(c.Spec.Bindings, binding) | ||
return binding | ||
return &c.Spec.Bindings[len(c.Spec.Bindings)-1] |
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.
return &c.Spec.Bindings[len(c.Spec.Bindings)-1] | |
return &binding |
I think it's simpler but is this to make the format consistent with the above?
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.
Simpler but it's not necessarily correct. I'm sure about the case above, I'm not entirely sure if binding here is the same element as in the slice (probably both would work here in this case, but I want to play it safe)
Fine to let Fabrizio review as well pre-merge |
/lgtm |
/hold cancel |
Signed-off-by: Stefan Büringer buringerst@vmware.com
What this PR does / why we need it:
One of the more interesting conversion PRs..
Which issue(s) this PR fixes (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)
format, will close the issue(s) when PR gets merged):Part of #10852