Skip to content

Commit

Permalink
fix controller-runtime ncompatibilities
Browse files Browse the repository at this point in the history
  • Loading branch information
halamix2 committed Sep 24, 2024
1 parent fe497d7 commit 596db3d
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions components/operator/internal/tracing/watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/util/workqueue"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/event"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
Expand All @@ -14,44 +15,45 @@ const (
tracingOTLPService = "telemetry-otlp-traces"
)

type eventHandler struct{}
type eventHandler[object client.Object, request reconcile.Request] struct{}

func (e eventHandler) Create(_ context.Context, event event.CreateEvent, q workqueue.RateLimitingInterface) {
func (e eventHandler[object, request]) Create(_ context.Context, event event.CreateEvent, q workqueue.TypedRateLimitingInterface[request]) {
if event.Object == nil {
return
}
svcName := event.Object.GetName()
if svcName != tracingOTLPService {
return
}
q.Add(reconcile.Request{NamespacedName: types.NamespacedName{
q.Add(request{NamespacedName: types.NamespacedName{
Name: event.Object.GetName(),
Namespace: event.Object.GetNamespace(),
}})
}

func (e eventHandler) Update(_ context.Context, _ event.UpdateEvent, _ workqueue.RateLimitingInterface) {
func (e eventHandler[object, request]) Update(_ context.Context, _ event.UpdateEvent, _ workqueue.TypedRateLimitingInterface[request]) {
}

func (e eventHandler) Delete(_ context.Context, event event.DeleteEvent, q workqueue.RateLimitingInterface) {
func (e eventHandler[object, request]) Delete(_ context.Context, event event.DeleteEvent, q workqueue.TypedRateLimitingInterface[request]) {
if event.Object == nil {
return
}
svcName := event.Object.GetName()
if svcName != tracingOTLPService {
return
}
q.Add(reconcile.Request{NamespacedName: types.NamespacedName{
q.Add(request{NamespacedName: types.NamespacedName{
Name: event.Object.GetName(),
Namespace: event.Object.GetNamespace(),
}})

}

func (e eventHandler) Generic(_ context.Context, _ event.GenericEvent, _ workqueue.RateLimitingInterface) {
func (e eventHandler[object, request]) Generic(_ context.Context, _ event.GenericEvent, _ workqueue.TypedRateLimitingInterface[request]) {
}

var _ handler.EventHandler = eventHandler{}
var _ handler.EventHandler = eventHandler[client.Object, reconcile.Request]{}

func ServiceCollectorWatcher() handler.EventHandler {
return &eventHandler{}
return &eventHandler[client.Object, reconcile.Request]{}
}

0 comments on commit 596db3d

Please sign in to comment.