@@ -226,72 +226,46 @@ func main() {
226226 os .Exit (1 )
227227 }
228228
229- setupLog .Info ("webhook port" , "webhook-port" , webhookPort )
230- if webhookPort == 0 {
231- if err = (& controllers.AWSMachineReconciler {
232- Client : mgr .GetClient (),
233- Log : ctrl .Log .WithName ("controllers" ).WithName ("AWSMachine" ),
234- Recorder : mgr .GetEventRecorderFor ("awsmachine-controller" ),
235- Endpoints : awsServiceEndpoints ,
236- WatchFilterValue : watchFilterValue ,
237- }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : awsMachineConcurrency , RecoverPanic : ptr.To [bool ](true )}); err != nil {
238- setupLog .Error (err , "unable to create controller" , "controller" , "AWSMachine" )
229+ setupReconcilersAndWebhooks (ctx , mgr , awsServiceEndpoints , externalResourceGC , alternativeGCStrategy )
230+ if feature .Gates .Enabled (feature .EKS ) {
231+ setupEKSReconcilersAndWebhooks (ctx , mgr , awsServiceEndpoints , externalResourceGC , alternativeGCStrategy , waitInfraPeriod )
232+ }
239233
240- os .Exit (1 )
241- }
242- if err = (& controllers.AWSClusterReconciler {
243- Client : mgr .GetClient (),
244- Recorder : mgr .GetEventRecorderFor ("awscluster-controller" ),
245- Endpoints : awsServiceEndpoints ,
246- WatchFilterValue : watchFilterValue ,
247- ExternalResourceGC : externalResourceGC ,
248- }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : awsClusterConcurrency , RecoverPanic : ptr.To [bool ](true )}); err != nil {
249- setupLog .Error (err , "unable to create controller" , "controller" , "AWSCluster" )
250- os .Exit (1 )
251- }
252- enableGates (ctx , mgr , awsServiceEndpoints , externalResourceGC )
253- } else {
254- setupReconcilersAndWebhooks (ctx , mgr , awsServiceEndpoints , externalResourceGC , alternativeGCStrategy )
255- if feature .Gates .Enabled (feature .EKS ) {
256- setupEKSReconcilersAndWebhooks (ctx , mgr , awsServiceEndpoints , externalResourceGC , alternativeGCStrategy , waitInfraPeriod )
257- }
258-
259- if feature .Gates .Enabled (feature .ROSA ) {
260- setupLog .Debug ("enabling ROSA control plane controller" )
261- if webhookPort == 0 {
262- if err := (& rosacontrolplanecontrollers.ROSAControlPlaneReconciler {
263- Client : mgr .GetClient (),
264- WatchFilterValue : watchFilterValue ,
265- WaitInfraPeriod : waitInfraPeriod ,
266- Endpoints : awsServiceEndpoints ,
267- }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : awsClusterConcurrency , RecoverPanic : ptr.To [bool ](true )}); err != nil {
268- setupLog .Error (err , "unable to create controller" , "controller" , "ROSAControlPlane" )
269- os .Exit (1 )
270- }
271-
272- setupLog .Debug ("enabling ROSA cluster controller" )
273- if err := (& controllers.ROSAClusterReconciler {
274- Client : mgr .GetClient (),
275- Recorder : mgr .GetEventRecorderFor ("rosacluster-controller" ),
276- WatchFilterValue : watchFilterValue ,
277- Endpoints : awsServiceEndpoints ,
278- }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : awsClusterConcurrency , RecoverPanic : ptr.To [bool ](true )}); err != nil {
279- setupLog .Error (err , "unable to create controller" , "controller" , "ROSACluster" )
280- os .Exit (1 )
281- }
282-
283- setupLog .Debug ("enabling ROSA machinepool controller" )
284- if err := (& expcontrollers.ROSAMachinePoolReconciler {
285- Client : mgr .GetClient (),
286- Recorder : mgr .GetEventRecorderFor ("rosamachinepool-controller" ),
287- WatchFilterValue : watchFilterValue ,
288- Endpoints : awsServiceEndpoints ,
289- }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : awsClusterConcurrency , RecoverPanic : ptr.To [bool ](true )}); err != nil {
290- setupLog .Error (err , "unable to create controller" , "controller" , "ROSAMachinePool" )
291- os .Exit (1 )
292- }
234+ if feature .Gates .Enabled (feature .ROSA ) {
235+ setupLog .Debug ("enabling ROSA control plane controller" )
236+ if webhookPort == 0 {
237+ if err := (& rosacontrolplanecontrollers.ROSAControlPlaneReconciler {
238+ Client : mgr .GetClient (),
239+ WatchFilterValue : watchFilterValue ,
240+ WaitInfraPeriod : waitInfraPeriod ,
241+ Endpoints : awsServiceEndpoints ,
242+ }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : awsClusterConcurrency , RecoverPanic : ptr.To [bool ](true )}); err != nil {
243+ setupLog .Error (err , "unable to create controller" , "controller" , "ROSAControlPlane" )
244+ os .Exit (1 )
293245 }
294246
247+ setupLog .Debug ("enabling ROSA cluster controller" )
248+ if err := (& controllers.ROSAClusterReconciler {
249+ Client : mgr .GetClient (),
250+ Recorder : mgr .GetEventRecorderFor ("rosacluster-controller" ),
251+ WatchFilterValue : watchFilterValue ,
252+ Endpoints : awsServiceEndpoints ,
253+ }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : awsClusterConcurrency , RecoverPanic : ptr.To [bool ](true )}); err != nil {
254+ setupLog .Error (err , "unable to create controller" , "controller" , "ROSACluster" )
255+ os .Exit (1 )
256+ }
257+
258+ setupLog .Debug ("enabling ROSA machinepool controller" )
259+ if err := (& expcontrollers.ROSAMachinePoolReconciler {
260+ Client : mgr .GetClient (),
261+ Recorder : mgr .GetEventRecorderFor ("rosamachinepool-controller" ),
262+ WatchFilterValue : watchFilterValue ,
263+ Endpoints : awsServiceEndpoints ,
264+ }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : awsClusterConcurrency , RecoverPanic : ptr.To [bool ](true )}); err != nil {
265+ setupLog .Error (err , "unable to create controller" , "controller" , "ROSAMachinePool" )
266+ os .Exit (1 )
267+ }
268+ } else {
295269 if err := (& rosacontrolplanev1.ROSAControlPlane {}).SetupWebhookWithManager (mgr ); err != nil {
296270 setupLog .Error (err , "unable to create webhook" , "webhook" , "ROSAControlPlane" )
297271 os .Exit (1 )
@@ -302,9 +276,10 @@ func main() {
302276 os .Exit (1 )
303277 }
304278 }
279+ }
305280
306- // +kubebuilder:scaffold:builder
307-
281+ // +kubebuilder:scaffold:builder
282+ if webhookPort != 0 {
308283 if err := mgr .AddReadyzCheck ("webhook" , mgr .GetWebhookServer ().StartedChecker ()); err != nil {
309284 setupLog .Error (err , "unable to create ready check" )
310285 os .Exit (1 )
@@ -365,11 +340,11 @@ func setupReconcilersAndWebhooks(ctx context.Context, mgr ctrl.Manager, awsServi
365340 setupLog .Error (err , "unable to create controller" , "controller" , "AWSMachinePool" )
366341 os .Exit (1 )
367342 }
368- }
369-
370- if err := ( & expinfrav1. AWSMachinePool {}). SetupWebhookWithManager ( mgr ); err != nil {
371- setupLog . Error ( err , "unable to create webhook" , "webhook" , "AWSMachinePool" )
372- os . Exit ( 1 )
343+ } else {
344+ if err := ( & expinfrav1. AWSMachinePool {}). SetupWebhookWithManager ( mgr ); err != nil {
345+ setupLog . Error ( err , "unable to create webhook" , "webhook" , "AWSMachinePool" )
346+ os . Exit ( 1 )
347+ }
373348 }
374349 }
375350
@@ -403,33 +378,35 @@ func setupReconcilersAndWebhooks(ctx context.Context, mgr ctrl.Manager, awsServi
403378 }
404379 }
405380
406- if err := (& infrav1.AWSMachineTemplateWebhook {}).SetupWebhookWithManager (mgr ); err != nil {
407- setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSMachineTemplate" )
408- os .Exit (1 )
409- }
410- if err := (& infrav1.AWSCluster {}).SetupWebhookWithManager (mgr ); err != nil {
411- setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSCluster" )
412- os .Exit (1 )
413- }
414- if err := (& infrav1.AWSClusterTemplate {}).SetupWebhookWithManager (mgr ); err != nil {
415- setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSClusterTemplate" )
416- os .Exit (1 )
417- }
418- if err := (& infrav1.AWSClusterControllerIdentity {}).SetupWebhookWithManager (mgr ); err != nil {
419- setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSClusterControllerIdentity" )
420- os .Exit (1 )
421- }
422- if err := (& infrav1.AWSClusterRoleIdentity {}).SetupWebhookWithManager (mgr ); err != nil {
423- setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSClusterRoleIdentity" )
424- os .Exit (1 )
425- }
426- if err := (& infrav1.AWSClusterStaticIdentity {}).SetupWebhookWithManager (mgr ); err != nil {
427- setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSClusterStaticIdentity" )
428- os .Exit (1 )
429- }
430- if err := (& infrav1.AWSMachine {}).SetupWebhookWithManager (mgr ); err != nil {
431- setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSMachine" )
432- os .Exit (1 )
381+ if webhookPort != 0 {
382+ if err := (& infrav1.AWSMachineTemplateWebhook {}).SetupWebhookWithManager (mgr ); err != nil {
383+ setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSMachineTemplate" )
384+ os .Exit (1 )
385+ }
386+ if err := (& infrav1.AWSCluster {}).SetupWebhookWithManager (mgr ); err != nil {
387+ setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSCluster" )
388+ os .Exit (1 )
389+ }
390+ if err := (& infrav1.AWSClusterTemplate {}).SetupWebhookWithManager (mgr ); err != nil {
391+ setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSClusterTemplate" )
392+ os .Exit (1 )
393+ }
394+ if err := (& infrav1.AWSClusterControllerIdentity {}).SetupWebhookWithManager (mgr ); err != nil {
395+ setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSClusterControllerIdentity" )
396+ os .Exit (1 )
397+ }
398+ if err := (& infrav1.AWSClusterRoleIdentity {}).SetupWebhookWithManager (mgr ); err != nil {
399+ setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSClusterRoleIdentity" )
400+ os .Exit (1 )
401+ }
402+ if err := (& infrav1.AWSClusterStaticIdentity {}).SetupWebhookWithManager (mgr ); err != nil {
403+ setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSClusterStaticIdentity" )
404+ os .Exit (1 )
405+ }
406+ if err := (& infrav1.AWSMachine {}).SetupWebhookWithManager (mgr ); err != nil {
407+ setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSMachine" )
408+ os .Exit (1 )
409+ }
433410 }
434411}
435412
@@ -501,11 +478,11 @@ func setupEKSReconcilersAndWebhooks(ctx context.Context, mgr ctrl.Manager, awsSe
501478 }).SetupWithManager (ctx , mgr , controller.Options {MaxConcurrentReconciles : awsClusterConcurrency , RecoverPanic : ptr.To [bool ](true )}); err != nil {
502479 setupLog .Error (err , "unable to create controller" , "controller" , "AWSFargateProfile" )
503480 }
504- }
505-
506- if err := ( & expinfrav1. AWSFargateProfile {}). SetupWebhookWithManager ( mgr ); err != nil {
507- setupLog . Error ( err , "unable to create webhook" , "webhook" , "AWSFargateProfile" )
508- os . Exit ( 1 )
481+ } else {
482+ if err := ( & expinfrav1. AWSFargateProfile {}). SetupWebhookWithManager ( mgr ); err != nil {
483+ setupLog . Error ( err , "unable to create webhook" , "webhook" , "AWSFargateProfile" )
484+ os . Exit ( 1 )
485+ }
509486 }
510487 }
511488
@@ -524,18 +501,20 @@ func setupEKSReconcilersAndWebhooks(ctx context.Context, mgr ctrl.Manager, awsSe
524501 setupLog .Error (err , "unable to create controller" , "controller" , "AWSManagedMachinePool" )
525502 os .Exit (1 )
526503 }
504+ } else {
505+ if err := (& expinfrav1.AWSManagedMachinePool {}).SetupWebhookWithManager (mgr ); err != nil {
506+ setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSManagedMachinePool" )
507+ os .Exit (1 )
508+ }
527509 }
510+ }
528511
529- if err := (& expinfrav1.AWSManagedMachinePool {}).SetupWebhookWithManager (mgr ); err != nil {
530- setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSManagedMachinePool" )
512+ if webhookPort != 0 {
513+ if err := (& ekscontrolplanev1.AWSManagedControlPlane {}).SetupWebhookWithManager (mgr ); err != nil {
514+ setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSManagedControlPlane" )
531515 os .Exit (1 )
532516 }
533517 }
534-
535- if err := (& ekscontrolplanev1.AWSManagedControlPlane {}).SetupWebhookWithManager (mgr ); err != nil {
536- setupLog .Error (err , "unable to create webhook" , "webhook" , "AWSManagedControlPlane" )
537- os .Exit (1 )
538- }
539518}
540519
541520func enableGates (ctx context.Context , mgr ctrl.Manager , awsServiceEndpoints []scope.ServiceEndpoint , externalResourceGC bool ) {
0 commit comments