From ce179a1043b279ac9c2407d19e7aedba094795b6 Mon Sep 17 00:00:00 2001 From: Knative Prow Robot Date: Tue, 4 Jan 2022 09:37:30 -0800 Subject: [PATCH] [release-1.1] using sharedmain.MainNamed for all controllers (#1690) * using sharedmain.MainNamed for all controllers Signed-off-by: Matthias Wessendorf * avoid kafka prefix Co-authored-by: Matthias Wessendorf --- control-plane/cmd/kafka-controller/main.go | 34 +++++++++++++++------- 1 file changed, 24 insertions(+), 10 deletions(-) diff --git a/control-plane/cmd/kafka-controller/main.go b/control-plane/cmd/kafka-controller/main.go index 272a9cd367..33645cf7a1 100644 --- a/control-plane/cmd/kafka-controller/main.go +++ b/control-plane/cmd/kafka-controller/main.go @@ -20,6 +20,9 @@ import ( "context" "log" + "knative.dev/pkg/injection" + "knative.dev/pkg/signals" + "knative.dev/pkg/configmap" "knative.dev/pkg/controller" "knative.dev/pkg/injection/sharedmain" @@ -52,27 +55,38 @@ func main() { log.Fatal("cannot process environment variables with prefix SINK", err) } - sharedmain.Main( - component, + sharedmain.MainNamed(signals.NewContext(), component, // Broker controller - func(ctx context.Context, watcher configmap.Watcher) *controller.Impl { - return broker.NewController(ctx, watcher, brokerEnv) + injection.NamedControllerConstructor{ + Name: "broker-controller", + ControllerConstructor: func(ctx context.Context, watcher configmap.Watcher) *controller.Impl { + return broker.NewController(ctx, watcher, brokerEnv) + }, }, // Trigger controller - func(ctx context.Context, watcher configmap.Watcher) *controller.Impl { - return trigger.NewController(ctx, watcher, brokerEnv) + injection.NamedControllerConstructor{ + Name: "trigger-controller", + ControllerConstructor: func(ctx context.Context, watcher configmap.Watcher) *controller.Impl { + return trigger.NewController(ctx, watcher, brokerEnv) + }, }, // KafkaSink controller - func(ctx context.Context, watcher configmap.Watcher) *controller.Impl { - return sink.NewController(ctx, watcher, sinkEnv) + injection.NamedControllerConstructor{ + Name: "sink-controller", + ControllerConstructor: func(ctx context.Context, watcher configmap.Watcher) *controller.Impl { + return sink.NewController(ctx, watcher, sinkEnv) + }, }, // KafkaSource controller - func(ctx context.Context, watcher configmap.Watcher) *controller.Impl { - return source.NewController(ctx, watcher, sourceEnv) + injection.NamedControllerConstructor{ + Name: "source-controller", + ControllerConstructor: func(ctx context.Context, watcher configmap.Watcher) *controller.Impl { + return source.NewController(ctx, watcher, sourceEnv) + }, }, ) }