✨ Add TypedInformer source#3520
Conversation
This mimicks the existing pattern of having a typed version of each source.
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: cezarsa The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Welcome @cezarsa! |
|
Hi @cezarsa. 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 Tip We noticed you've done this a few times! Consider joining the org to skip this step and gain Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
/ok-to-test |
|
|
||
| // EventHandler adapts a handler.EventHandler interface to a cache.ResourceEventHandler interface. | ||
| type EventHandler[object client.Object, request comparable] struct { | ||
| type EventHandler[object any, request comparable] struct { |
There was a problem hiding this comment.
Why is this being changed?
There was a problem hiding this comment.
Because the definition of handler.TypedEventHandler doesn't constrain the object and allows any, neither does any of the source generic types. Without that change, the TypedInformer definition would also have to be constrained to client.Object which wouldn't be desirable, and it would limit its use.
There was a problem hiding this comment.
Why would it limit its use? What use-case exists where TypedInformer is typed to something that does not satisfy client.Object?
There was a problem hiding this comment.
It's possible to use cache.SharedIndexInformer{}.SetTransform() to transform the original object into an instance that doesn't satisfy client.Object.
|
@cezarsa: 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. DetailsInstructions 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. |
This PR mimics the existing pattern of having a typed version of each source. This small change would help users avoid having to write their own version of
TypedInformer.For an example of a use-case, see: https://github.com/kubernetes-sigs/aws-load-balancer-controller/pull/4678/changes#diff-aeaa3ed265c13311667100ad572f071fc3928d07227e8320322116bfee2a0e90