-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
✨ Added methods to intercept calls to a k8s client #2248
✨ Added methods to intercept calls to a k8s client #2248
Conversation
Welcome @ludydoo! |
Hi @ludydoo. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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. |
/ok-to-test |
/retest |
I like it, simple, stupid and maximum flexibility. Thoughts @joelanford @vincepri @sbueringer ? |
Hi @alvaroaleman , thanks a lot for your quick review! What's your opinion about: would it make more sense to put this into the |
@alvaroaleman @inteon please let me know if there is anything I should tweak or modify |
@ludydoo we had a lot of discussion about fakeclient changes like this, which is why I can't just merge without some of the other maintainers approving and two of them are on PTO unfortunately. So this will take a bit of time, but there is nothing expected from you at this point. Sorry about that. |
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 looks like a good way to allow some mocking to happen in the fake client, I'm personally +1, but would like to hear @sbueringer's opinion as well.
Just back from PTO, will take a look ASAP, not sure if it will be before KubeCon |
Looks good to me as well. Looks like it needs a rebase to pick up the change to the golangci-lint action. One thought (similar to: #2248 (comment)): as this functionality is probably often used together with fake client, but it can also be used with a regular client, should we move it out of the fake package? I was thinking about maybe a new package like pkg/client/interceptor. Has the benefit to keep it clearly separate from the fake client and if we rename the func we could make it e.g. interceptor.NewClient instead of fake.Interceptor. |
If we move this into a distinct package, can we make this discoverable by integrating with the fake client builder by adding a With method for each of the interceptor methods that sets them? |
edit ... or simply remove the dependency on I've moved the interception to the |
/retest |
@alvaroaleman @sbueringer just pinging you for feedback on the changes when you have some time |
@ludydoo Can you please drop the merge commits, squash and rebase to main? (I assume you probably kept them for easier reviews, but the delta of this PR would be easier to see without the merge commits) |
commit 3b534a4 Merge: f264518 a24b949 Author: Ludovic Cleroux <[email protected]> Date: Tue Apr 25 12:58:42 2023 +0200 Merge branch 'kubernetes-sigs:main' into add-fake-client-interception commit f264518 Author: Ludovic Cleroux <[email protected]> Date: Tue Apr 25 12:57:18 2023 +0200 PR comments commit e358be3 Author: Ludovic Cleroux <[email protected]> Date: Sun Apr 16 10:38:37 2023 +0200 Allow the interceptor to be discovered from the fake ClientBuilder commit bf25854 Author: Ludovic Cleroux <[email protected]> Date: Sun Apr 16 10:21:37 2023 +0200 Remove dependency on fake client commit 6063435 Author: Ludovic Cleroux <[email protected]> Date: Sun Apr 16 10:02:42 2023 +0200 Cleanup commit b66b57a Author: Ludovic Cleroux <[email protected]> Date: Sun Apr 16 10:02:05 2023 +0200 Cleanup commit 483deea Author: Ludovic Cleroux <[email protected]> Date: Sun Apr 16 10:00:39 2023 +0200 Cleanup commit 9c3df6a Author: Ludovic Cleroux <[email protected]> Date: Sun Apr 16 09:59:19 2023 +0200 Slight refactor commit 4fb67c0 Author: Ludovic Cleroux <[email protected]> Date: Sun Apr 16 09:56:24 2023 +0200 Slight refactor & lint commit 5221233 Author: Ludovic Cleroux <[email protected]> Date: Sun Apr 16 09:30:52 2023 +0200 Move interceptor to new package commit d74b869 Merge: 9642a63 d989e66 Author: Ludovic Cleroux <[email protected]> Date: Sun Apr 16 09:21:31 2023 +0200 Merge branch 'kubernetes-sigs:main' into add-fake-client-interception commit 9642a63 Author: Ludovic Cleroux <[email protected]> Date: Wed Mar 29 09:34:28 2023 +0200 Fixed SubResource/Status calling logic commit 00597ac Author: Ludovic Cleroux <[email protected]> Date: Tue Mar 28 09:44:36 2023 +0200 Remove unnecessary Status() intercept commit cd8451c Author: Ludovic Cleroux <[email protected]> Date: Mon Mar 27 15:52:40 2023 +0200 Fix goimports commit c80013e Author: Ludovic Cleroux <[email protected]> Date: Mon Mar 27 15:42:45 2023 +0200 Fix missing comments commit fe27862 Author: Ludovic Cleroux <[email protected]> Date: Mon Mar 27 15:30:13 2023 +0200 Added methods to intercept calls to a fake k8s client
3b534a4
to
c143c83
Compare
@sbueringer just addressed your comments, and squashed & rebased to main. Please let me know if you think there should be some more changes. |
@ludydoo Thank you very much!! /lgtm /assign @vincepri @alvaroaleman |
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.
Thanks!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, ludydoo 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 |
Thanks a lot for this @ludydoo ! This makes injecting custom beheavior into the fakeclient for tests much easier :) |
Thank you for your reviews and advices @alvaroaleman @sbueringer @inteon @vincepri ! |
This PR adds some methods to allow consumers of the k8s client to intercept kubernetes api calls to inject custom logic, which is helpful while testing e.g. expected behavior upon certain types of failures.