@@ -17,6 +17,8 @@ limitations under the License.
17
17
package handler
18
18
19
19
import (
20
+ "context"
21
+
20
22
"k8s.io/client-go/util/workqueue"
21
23
"sigs.k8s.io/controller-runtime/pkg/event"
22
24
)
@@ -41,17 +43,17 @@ import (
41
43
// Most users shouldn't need to implement their own EventHandler.
42
44
type EventHandler interface {
43
45
// 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 )
45
47
46
48
// 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 )
48
50
49
51
// 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 )
51
53
52
54
// Generic is called in response to an event of an unknown type or a synthetic event triggered as a cron or
53
55
// external trigger request - e.g. reconcile Autoscaling, or a Webhook.
54
- Generic (event.GenericEvent , workqueue.RateLimitingInterface )
56
+ Generic (context. Context , event.GenericEvent , workqueue.RateLimitingInterface )
55
57
}
56
58
57
59
var _ EventHandler = Funcs {}
@@ -60,45 +62,45 @@ var _ EventHandler = Funcs{}
60
62
type Funcs struct {
61
63
// Create is called in response to an add event. Defaults to no-op.
62
64
// RateLimitingInterface is used to enqueue reconcile.Requests.
63
- CreateFunc func (event.CreateEvent , workqueue.RateLimitingInterface )
65
+ CreateFunc func (context. Context , event.CreateEvent , workqueue.RateLimitingInterface )
64
66
65
67
// Update is called in response to an update event. Defaults to no-op.
66
68
// RateLimitingInterface is used to enqueue reconcile.Requests.
67
- UpdateFunc func (event.UpdateEvent , workqueue.RateLimitingInterface )
69
+ UpdateFunc func (context. Context , event.UpdateEvent , workqueue.RateLimitingInterface )
68
70
69
71
// Delete is called in response to a delete event. Defaults to no-op.
70
72
// RateLimitingInterface is used to enqueue reconcile.Requests.
71
- DeleteFunc func (event.DeleteEvent , workqueue.RateLimitingInterface )
73
+ DeleteFunc func (context. Context , event.DeleteEvent , workqueue.RateLimitingInterface )
72
74
73
75
// GenericFunc is called in response to a generic event. Defaults to no-op.
74
76
// RateLimitingInterface is used to enqueue reconcile.Requests.
75
- GenericFunc func (event.GenericEvent , workqueue.RateLimitingInterface )
77
+ GenericFunc func (context. Context , event.GenericEvent , workqueue.RateLimitingInterface )
76
78
}
77
79
78
80
// 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 ) {
80
82
if h .CreateFunc != nil {
81
- h .CreateFunc (e , q )
83
+ h .CreateFunc (ctx , e , q )
82
84
}
83
85
}
84
86
85
87
// 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 ) {
87
89
if h .DeleteFunc != nil {
88
- h .DeleteFunc (e , q )
90
+ h .DeleteFunc (ctx , e , q )
89
91
}
90
92
}
91
93
92
94
// 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 ) {
94
96
if h .UpdateFunc != nil {
95
- h .UpdateFunc (e , q )
97
+ h .UpdateFunc (ctx , e , q )
96
98
}
97
99
}
98
100
99
101
// 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 ) {
101
103
if h .GenericFunc != nil {
102
- h .GenericFunc (e , q )
104
+ h .GenericFunc (ctx , e , q )
103
105
}
104
106
}
0 commit comments