@@ -18,10 +18,8 @@ package handler
1818
1919import (
2020"context"
21- "reflect"
2221"time"
2322
24- "k8s.io/apimachinery/pkg/types"
2523"k8s.io/client-go/util/workqueue"
2624"sigs.k8s.io/controller-runtime/pkg/client"
2725"sigs.k8s.io/controller-runtime/pkg/controller/priorityqueue"
@@ -113,22 +111,7 @@ type TypedFuncs[object any, request comparable] struct {
113111// Create implements EventHandler.
114112func (h TypedFuncs [object , request ]) Create (ctx context.Context , e event.TypedCreateEvent [object ], q workqueue.TypedRateLimitingInterface [request ]) {
115113if h .CreateFunc != nil {
116- if reflect .TypeFor [request ]() != reflect .TypeOf (reconcile.Request {}) || ! reflect .TypeFor [object ]().Implements (reflect .TypeFor [client.Object ]()) {
117- h .CreateFunc (ctx , e , q )
118- }
119-
120- wq , ok := q .(workqueue.TypedRateLimitingInterface [reconcile.Request ])
121- if ok {
122- evt , ok := any (e ).(event.TypedCreateEvent [client.Object ])
123- if ok {
124- item := reconcile.Request {NamespacedName : types.NamespacedName {
125- Name : evt .Object .GetName (),
126- Namespace : evt .Object .GetNamespace (),
127- }}
128- addToQueueCreate (wq , evt , item )
129- }
130- h .CreateFunc (ctx , e , q )
131- }
114+ h .CreateFunc (ctx , e , q )
132115}
133116}
134117
@@ -142,33 +125,7 @@ func (h TypedFuncs[object, request]) Delete(ctx context.Context, e event.TypedDe
142125// Update implements EventHandler.
143126func (h TypedFuncs [object , request ]) Update (ctx context.Context , e event.TypedUpdateEvent [object ], q workqueue.TypedRateLimitingInterface [request ]) {
144127if h .UpdateFunc != nil {
145- if reflect .TypeFor [request ]() != reflect .TypeOf (reconcile.Request {}) || ! reflect .TypeFor [object ]().Implements (reflect .TypeFor [client.Object ]()) {
146- h .UpdateFunc (ctx , e , q )
147- }
148-
149- wq , ok := q .(workqueue.TypedRateLimitingInterface [reconcile.Request ])
150- if ok {
151- evt , ok := any (e ).(event.TypedUpdateEvent [client.Object ])
152- if ok {
153- switch {
154- case ! isNil (evt .ObjectNew ):
155- item := reconcile.Request {NamespacedName : types.NamespacedName {
156- Name : evt .ObjectNew .GetName (),
157- Namespace : evt .ObjectNew .GetNamespace (),
158- }}
159- addToQueueUpdate (wq , evt , item )
160- case ! isNil (evt .ObjectOld ):
161- item := reconcile.Request {NamespacedName : types.NamespacedName {
162- Name : evt .ObjectOld .GetName (),
163- Namespace : evt .ObjectOld .GetNamespace (),
164- }}
165- addToQueueUpdate (wq , evt , item )
166- default :
167- enqueueLog .Error (nil , "UpdateEvent received with no metadata" , "event" , evt )
168- }
169- }
170- h .UpdateFunc (ctx , e , q )
171- }
128+ h .UpdateFunc (ctx , e , q )
172129}
173130}
174131
0 commit comments