@@ -17,6 +17,8 @@ limitations under the License.
1717package handler
1818
1919import (
20+ "context"
21+
2022 "k8s.io/client-go/util/workqueue"
2123 "sigs.k8s.io/controller-runtime/pkg/event"
2224)
@@ -41,17 +43,17 @@ import (
4143// Most users shouldn't need to implement their own EventHandler.
4244type EventHandler interface {
4345 // Create is called in response to an create event - e.g. Pod Creation.
44- Create (event.CreateEvent , workqueue.RateLimitingInterface )
46+ Create (context. Context , event.CreateEvent , workqueue.RateLimitingInterface )
4547
4648 // Update is called in response to an update event - e.g. Pod Updated.
47- Update (event.UpdateEvent , workqueue.RateLimitingInterface )
49+ Update (context. Context , event.UpdateEvent , workqueue.RateLimitingInterface )
4850
4951 // Delete is called in response to a delete event - e.g. Pod Deleted.
50- Delete (event.DeleteEvent , workqueue.RateLimitingInterface )
52+ Delete (context. Context , event.DeleteEvent , workqueue.RateLimitingInterface )
5153
5254 // Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
5355 // external trigger request - e.g. reconcile Autoscaling, or a Webhook.
54- Generic (event.GenericEvent , workqueue.RateLimitingInterface )
56+ Generic (context. Context , event.GenericEvent , workqueue.RateLimitingInterface )
5557}
5658
5759var _ EventHandler = Funcs {}
@@ -60,45 +62,45 @@ var _ EventHandler = Funcs{}
6062type Funcs struct {
6163 // Create is called in response to an add event. Defaults to no-op.
6264 // RateLimitingInterface is used to enqueue reconcile.Requests.
63- CreateFunc func (event.CreateEvent , workqueue.RateLimitingInterface )
65+ CreateFunc func (context. Context , event.CreateEvent , workqueue.RateLimitingInterface )
6466
6567 // Update is called in response to an update event. Defaults to no-op.
6668 // RateLimitingInterface is used to enqueue reconcile.Requests.
67- UpdateFunc func (event.UpdateEvent , workqueue.RateLimitingInterface )
69+ UpdateFunc func (context. Context , event.UpdateEvent , workqueue.RateLimitingInterface )
6870
6971 // Delete is called in response to a delete event. Defaults to no-op.
7072 // RateLimitingInterface is used to enqueue reconcile.Requests.
71- DeleteFunc func (event.DeleteEvent , workqueue.RateLimitingInterface )
73+ DeleteFunc func (context. Context , event.DeleteEvent , workqueue.RateLimitingInterface )
7274
7375 // GenericFunc is called in response to a generic event. Defaults to no-op.
7476 // RateLimitingInterface is used to enqueue reconcile.Requests.
75- GenericFunc func (event.GenericEvent , workqueue.RateLimitingInterface )
77+ GenericFunc func (context. Context , event.GenericEvent , workqueue.RateLimitingInterface )
7678}
7779
7880// Create implements EventHandler.
79- func (h Funcs ) Create (e event.CreateEvent , q workqueue.RateLimitingInterface ) {
81+ func (h Funcs ) Create (ctx context. Context , e event.CreateEvent , q workqueue.RateLimitingInterface ) {
8082 if h .CreateFunc != nil {
81- h .CreateFunc (e , q )
83+ h .CreateFunc (ctx , e , q )
8284 }
8385}
8486
8587// Delete implements EventHandler.
86- func (h Funcs ) Delete (e event.DeleteEvent , q workqueue.RateLimitingInterface ) {
88+ func (h Funcs ) Delete (ctx context. Context , e event.DeleteEvent , q workqueue.RateLimitingInterface ) {
8789 if h .DeleteFunc != nil {
88- h .DeleteFunc (e , q )
90+ h .DeleteFunc (ctx , e , q )
8991 }
9092}
9193
9294// Update implements EventHandler.
93- func (h Funcs ) Update (e event.UpdateEvent , q workqueue.RateLimitingInterface ) {
95+ func (h Funcs ) Update (ctx context. Context , e event.UpdateEvent , q workqueue.RateLimitingInterface ) {
9496 if h .UpdateFunc != nil {
95- h .UpdateFunc (e , q )
97+ h .UpdateFunc (ctx , e , q )
9698 }
9799}
98100
99101// Generic implements EventHandler.
100- func (h Funcs ) Generic (e event.GenericEvent , q workqueue.RateLimitingInterface ) {
102+ func (h Funcs ) Generic (ctx context. Context , e event.GenericEvent , q workqueue.RateLimitingInterface ) {
101103 if h .GenericFunc != nil {
102- h .GenericFunc (e , q )
104+ h .GenericFunc (ctx , e , q )
103105 }
104106}
0 commit comments