From 6a361e7913389be358f70e50aa756ad3ec35e0f5 Mon Sep 17 00:00:00 2001 From: Georgi Chulkov Date: Tue, 26 Mar 2024 16:38:38 +0100 Subject: [PATCH] Fix controller enabling logic (#21) --- cmd/main.go | 58 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 23 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index b3a726f8..7d19e26d 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -184,30 +184,42 @@ func main() { return } - err = controller.NewMachineReconciler().SetupWithManager(mgr) - if err != nil { - log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "Machine") - exitCode = 1 - return - } - err = controller.NewMachineClaimReconciler().SetupWithManager(mgr) - if err != nil { - log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "MachineClaim") - exitCode = 1 - return - } - err = controller.NewOOBReconciler().SetupWithManager(mgr) - if err != nil { - log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "OOB") - exitCode = 1 - return - } - err = controller.NewOOBSecretReconciler().SetupWithManager(mgr) - if err != nil { - log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "OOBSecret") - exitCode = 1 - return + if p.enableMachineController { + err = controller.NewMachineReconciler().SetupWithManager(mgr) + if err != nil { + log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "Machine") + exitCode = 1 + return + } + } + + if p.enableMachineClaimController { + err = controller.NewMachineClaimReconciler().SetupWithManager(mgr) + if err != nil { + log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "MachineClaim") + exitCode = 1 + return + } + } + + if p.enableOOBController { + err = controller.NewOOBReconciler().SetupWithManager(mgr) + if err != nil { + log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "OOB") + exitCode = 1 + return + } + } + + if p.enableOOBSecretController { + err = controller.NewOOBSecretReconciler().SetupWithManager(mgr) + if err != nil { + log.Error(ctx, fmt.Errorf("cannot create controller: %w", err), "controller", "OOBSecret") + exitCode = 1 + return + } } + //+kubebuilder:scaffold:builder err = mgr.AddHealthzCheck("health", healthz.Ping)