Skip to content

Commit

Permalink
Only start the conversion webhooks if they are enabled via the contro…
Browse files Browse the repository at this point in the history
…ller.Options.StartWebhooks

Signed-off-by: Alper Rifat Ulucinar <ulucinar@users.noreply.github.com>
  • Loading branch information
ulucinar committed Jan 25, 2024
1 parent fb462a0 commit d1f07bb
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 4 additions & 0 deletions pkg/controller/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ type Options struct {
// PollJitter adds the specified jitter to the configured reconcile period
// of the up-to-date resources in managed.Reconciler.
PollJitter time.Duration

// StartWebhooks enables starting of the conversion webhooks by the
// provider's controllerruntime.Manager.
StartWebhooks bool
}

// ESSOptions for External Secret Stores.
Expand Down
7 changes: 5 additions & 2 deletions pkg/pipeline/templates/controller.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ func Setup(mgr ctrl.Manager, o tjcontroller.Options) error {
{{- end}}

// register webhooks for the kind {{ .TypePackageAlias }}{{ .CRD.Kind }}
if err := ctrl.NewWebhookManagedBy(mgr).
// if they're enabled.
if o.StartWebhooks {
if err := ctrl.NewWebhookManagedBy(mgr).
For(&{{ .TypePackageAlias }}{{ .CRD.Kind }}{}).
Complete(); err != nil {
return errors.Wrap(err, "cannot register webhook for the kind {{ .TypePackageAlias }}{{ .CRD.Kind }}")
return errors.Wrap(err, "cannot register webhook for the kind {{ .TypePackageAlias }}{{ .CRD.Kind }}")
}
}

r := managed.NewReconciler(mgr, xpresource.ManagedKind({{ .TypePackageAlias }}{{ .CRD.Kind }}_GroupVersionKind), opts...)
Expand Down

0 comments on commit d1f07bb

Please sign in to comment.