diff --git a/controllers/webhook/webhook.go b/controllers/webhook/webhook.go index 9455cfd08ba..29739e2af00 100644 --- a/controllers/webhook/webhook.go +++ b/controllers/webhook/webhook.go @@ -46,6 +46,15 @@ type OpenDataHubValidatingWebhook struct { Decoder *admission.Decoder } +func Init(mgr ctrl.Manager) { + (&OpenDataHubValidatingWebhook{ + Client: mgr.GetClient(), + Decoder: admission.NewDecoder(mgr.GetScheme()), + }).SetupWithManager(mgr) + + (&DSCDefaulter{}).SetupWithManager(mgr) +} + func (w *OpenDataHubValidatingWebhook) SetupWithManager(mgr ctrl.Manager) { hookServer := mgr.GetWebhookServer() odhWebhook := &webhook.Admission{ diff --git a/main.go b/main.go index 7d33d59a997..778a829f5ee 100644 --- a/main.go +++ b/main.go @@ -55,7 +55,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/manager" ctrlmetrics "sigs.k8s.io/controller-runtime/pkg/metrics/server" ctrlwebhook "sigs.k8s.io/controller-runtime/pkg/webhook" - "sigs.k8s.io/controller-runtime/pkg/webhook/admission" dscv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/datasciencecluster/v1" dsciv1 "github.com/opendatahub-io/opendatahub-operator/v2/apis/dscinitialization/v1" @@ -235,12 +234,7 @@ func main() { //nolint:funlen,maintidx os.Exit(1) } - (&webhook.OpenDataHubValidatingWebhook{ - Client: mgr.GetClient(), - Decoder: admission.NewDecoder(mgr.GetScheme()), - }).SetupWithManager(mgr) - - (&webhook.DSCDefaulter{}).SetupWithManager(mgr) + webhook.Init(mgr) if err = (&dscictrl.DSCInitializationReconciler{ Client: mgr.GetClient(),