From cbb6f1125fe97d70f76d19bba8a1f6cce269f1b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lukas=20W=C3=B6hrl?= Date: Fri, 17 Feb 2023 08:39:01 +0100 Subject: [PATCH] disable AWSPCAClusterIssuer if namespace restriction MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Lukas Wöhrl --- main.go | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/main.go b/main.go index da5f1920..80365e24 100644 --- a/main.go +++ b/main.go @@ -97,6 +97,7 @@ func main() { Recorder: mgr.GetEventRecorderFor("awspcaissuer-controller"), GetCallerIdentity: true, } + if err = (&controllers.AWSPCAIssuerReconciler{ Client: mgr.GetClient(), Log: ctrl.Log.WithName("controllers").WithName("AWSPCAIssuer"), @@ -106,15 +107,21 @@ func main() { setupLog.Error(err, "unable to create controller", "controller", "AWSPCAIssuer") os.Exit(1) } - if err = (&controllers.AWSPCAClusterIssuerReconciler{ - Client: mgr.GetClient(), - Log: ctrl.Log.WithName("controllers").WithName("AWSPCAClusterIssuer"), - Scheme: mgr.GetScheme(), - GenericController: genericIssuerController, - }).SetupWithManager(mgr); err != nil { - setupLog.Error(err, "unable to create controller", "controller", "AWSPCAClusterIssuer") - os.Exit(1) + + if restrictToNamespace != "" { + setupLog.Info("restricting controller to namespace, disable AWSPCAClusterIssuer controller", "namespace", restrictToNamespace) + } else { + if err = (&controllers.AWSPCAClusterIssuerReconciler{ + Client: mgr.GetClient(), + Log: ctrl.Log.WithName("controllers").WithName("AWSPCAClusterIssuer"), + Scheme: mgr.GetScheme(), + GenericController: genericIssuerController, + }).SetupWithManager(mgr); err != nil { + setupLog.Error(err, "unable to create controller", "controller", "AWSPCAClusterIssuer") + os.Exit(1) + } } + if err = (&controllers.CertificateRequestReconciler{ Client: mgr.GetClient(), Log: ctrl.Log.WithName("controllers").WithName("CertificateRequest"),