Skip to content

Commit

Permalink
[release-1.1] using sharedmain.MainNamed for all controllers (#1690)
Browse files Browse the repository at this point in the history
* using sharedmain.MainNamed for all controllers

Signed-off-by: Matthias Wessendorf <mwessend@redhat.com>

* avoid kafka prefix

Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
  • Loading branch information
knative-prow-robot and matzew authored Jan 4, 2022
1 parent 01240b7 commit ce179a1
Showing 1 changed file with 24 additions and 10 deletions.
34 changes: 24 additions & 10 deletions control-plane/cmd/kafka-controller/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
},
},
)
}

0 comments on commit ce179a1

Please sign in to comment.