-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
🐛 Fakeclient: Don't return items on invalid selector #3022
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman 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 |
4b3d7f8
to
fafee8c
Compare
Would a returned list from a field selector produce an error? I am under the assumption that a list call returns no error and an empty list, making the call successful but resulting in the items being empty. |
pkg/client/fake/client.go
Outdated
zero(obj) | ||
if err := json.Unmarshal(j, obj); err != nil { | ||
objCopy := obj.DeepCopyObject().(client.ObjectList) | ||
zero(objCopy) |
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.
Are we missing something by not zero'ing obj anymore?
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.
Not sure why I did it this way, changed it to just keep zeroing obj
instead, ptal
I am not sure I follow the question, are you asking if an error is returned if the selector is invalid? If so, then yeah it is: controller-runtime/pkg/client/fake/client_test.go Line 1324 in fafee8c
|
Currently, if a List call to the fake client references an invalid fieldSelector, we will return an error and put all items into the passed List. Avoid putting anything into the passed list if the selector is invalid.
fafee8c
to
c49e843
Compare
Currently, if a List call to the fake client references an invalid fieldSelector, we will return an error and put all items into the passed List. Avoid putting anything into the passed list if the selector is invalid.