From 27c0c94eb7b8fba6f4bb61cccdf070a4f6aae193 Mon Sep 17 00:00:00 2001 From: Alper Rifat Ulucinar Date: Thu, 3 Aug 2023 18:11:52 +0300 Subject: [PATCH] Set a default EventHandler if the provider's main module does not supply one - Setting a default EventHandler to keep backwards-compatibility for the generated providers Signed-off-by: Alper Rifat Ulucinar (cherry picked from commit 7c2b48d8111db919469e62ebdeadf8534916b7f0) --- pkg/pipeline/templates/setup.go.tmpl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pkg/pipeline/templates/setup.go.tmpl b/pkg/pipeline/templates/setup.go.tmpl index 72b9f5a4..dd7754b4 100644 --- a/pkg/pipeline/templates/setup.go.tmpl +++ b/pkg/pipeline/templates/setup.go.tmpl @@ -8,6 +8,7 @@ import ( ctrl "sigs.k8s.io/controller-runtime" "github.com/upbound/upjet/pkg/controller" + "github.com/upbound/upjet/pkg/controller/handler" {{ .Imports }} ) @@ -15,6 +16,11 @@ import ( // Setup{{ .Group }} creates all controllers with the supplied logger and adds them to // the supplied manager. func Setup{{ .Group }}(mgr ctrl.Manager, o controller.Options) error { + // set the default event handler if the provider's main module did not + // set one. + if o.EventHandler == nil { + o.EventHandler = handler.NewEventHandler() + } for _, setup := range []func(ctrl.Manager, controller.Options) error{ {{- range $alias := .Aliases }} {{ $alias }}Setup,