@@ -6,13 +6,6 @@ import (
66 "os"
77 "time"
88
9- "github.com/spf13/cobra"
10- rbacv1 "k8s.io/api/rbac/v1"
11- "k8s.io/apimachinery/pkg/runtime"
12- "k8s.io/apimachinery/pkg/util/intstr"
13- "k8s.io/apimachinery/pkg/util/wait"
14- "sigs.k8s.io/controller-runtime/pkg/client"
15-
169 ctrlutils "github.com/openmcp-project/controller-utils/pkg/controller"
1710 crdutil "github.com/openmcp-project/controller-utils/pkg/crds"
1811 "github.com/openmcp-project/controller-utils/pkg/init/webhooks"
@@ -21,6 +14,12 @@ import (
2114 openmcpconst "github.com/openmcp-project/openmcp-operator/api/constants"
2215 "github.com/openmcp-project/openmcp-operator/lib/clusteraccess"
2316 libutils "github.com/openmcp-project/openmcp-operator/lib/utils"
17+ "github.com/spf13/cobra"
18+ rbacv1 "k8s.io/api/rbac/v1"
19+ "k8s.io/apimachinery/pkg/runtime"
20+ "k8s.io/apimachinery/pkg/util/intstr"
21+ "k8s.io/apimachinery/pkg/util/wait"
22+ "sigs.k8s.io/controller-runtime/pkg/client"
2423
2524 pwv1alpha1 "github.com/openmcp-project/project-workspace-operator/api/core/v1alpha1"
2625 "github.com/openmcp-project/project-workspace-operator/api/crds"
@@ -237,6 +236,19 @@ func (o *InitOptions) Run(ctx context.Context) error {
237236 opts = append(opts, webhooks.WithCustomCA{todo})
238237 */
239238
239+ webhookTypes := []webhooks.APITypes {
240+ {
241+ Obj : & pwv1alpha1.Project {},
242+ Validator : true ,
243+ Defaulter : true ,
244+ },
245+ {
246+ Obj : & pwv1alpha1.Workspace {},
247+ Validator : true ,
248+ Defaulter : true ,
249+ },
250+ }
251+
240252 if ! pwc .Spec .Webhook .Disabled {
241253 log .Info ("Webhooks are enabled, ensuring required resources ..." )
242254
@@ -245,15 +257,14 @@ func (o *InitOptions) Run(ctx context.Context) error {
245257 return fmt .Errorf ("unable to generate webhook certificate: %w" , err )
246258 }
247259
260+ // Compile-time checks to ensure Project implements the required interfaces
261+
248262 // Install webhooks
249263 err := webhooks .Install (
250264 ctx ,
251265 o .PlatformCluster .Client (),
252266 onboardingScheme ,
253- []client.Object {
254- & pwv1alpha1.Project {},
255- & pwv1alpha1.Workspace {},
256- },
267+ webhookTypes ,
257268 installOpts ... ,
258269 )
259270 if err != nil {
@@ -267,10 +278,7 @@ func (o *InitOptions) Run(ctx context.Context) error {
267278 ctx ,
268279 o .PlatformCluster .Client (),
269280 onboardingScheme ,
270- []client.Object {
271- & pwv1alpha1.Project {},
272- & pwv1alpha1.Workspace {},
273- },
281+ webhookTypes ,
274282 installOpts ... ,
275283 )
276284 if err != nil {
0 commit comments