From c5eb3d25250367cfa0940bc045f2f628d59d8a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Charles-Edouard=20Br=C3=A9t=C3=A9ch=C3=A9?= Date: Tue, 29 Aug 2023 23:06:15 +0200 Subject: [PATCH] fix: check caSecretName and tlsSecretName flags (#8155) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Charles-Edouard Brétéché --- cmd/cleanup-controller/main.go | 8 ++++++++ cmd/kyverno/main.go | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/cmd/cleanup-controller/main.go b/cmd/cleanup-controller/main.go index efad2a8079..0f0cca43ec 100644 --- a/cmd/cleanup-controller/main.go +++ b/cmd/cleanup-controller/main.go @@ -95,6 +95,14 @@ func main() { // setup ctx, setup, sdown := internal.Setup(appConfig, "kyverno-cleanup-controller", false) defer sdown() + if caSecretName == "" { + setup.Logger.Error(errors.New("exiting... caSecretName is a required flag"), "exiting... caSecretName is a required flag") + os.Exit(1) + } + if tlsSecretName == "" { + setup.Logger.Error(errors.New("exiting... tlsSecretName is a required flag"), "exiting... tlsSecretName is a required flag") + os.Exit(1) + } // certificates informers caSecret := informers.NewSecretInformer(setup.KubeClient, config.KyvernoNamespace(), caSecretName, resyncPeriod) tlsSecret := informers.NewSecretInformer(setup.KubeClient, config.KyvernoNamespace(), tlsSecretName, resyncPeriod) diff --git a/cmd/kyverno/main.go b/cmd/kyverno/main.go index fda94669ad..b145dfbfd5 100644 --- a/cmd/kyverno/main.go +++ b/cmd/kyverno/main.go @@ -241,6 +241,14 @@ func main() { // setup signalCtx, setup, sdown := internal.Setup(appConfig, "kyverno-admission-controller", false) defer sdown() + if caSecretName == "" { + setup.Logger.Error(errors.New("exiting... caSecretName is a required flag"), "exiting... caSecretName is a required flag") + os.Exit(1) + } + if tlsSecretName == "" { + setup.Logger.Error(errors.New("exiting... tlsSecretName is a required flag"), "exiting... tlsSecretName is a required flag") + os.Exit(1) + } caSecret := informers.NewSecretInformer(setup.KubeClient, config.KyvernoNamespace(), caSecretName, resyncPeriod) tlsSecret := informers.NewSecretInformer(setup.KubeClient, config.KyvernoNamespace(), tlsSecretName, resyncPeriod) if !informers.StartInformersAndWaitForCacheSync(signalCtx, setup.Logger, caSecret, tlsSecret) {