From c0331bb75fcff96a3d88bd7397b4c43e2e0dfd30 Mon Sep 17 00:00:00 2001 From: Abhishek Date: Fri, 22 Sep 2023 11:52:44 +0530 Subject: [PATCH] review comments incorporated - skipping webhook server creation if not necessory --- cmd/manager/main.go | 81 +++++++++++++++++----------------- helm/db-controller/values.yaml | 2 +- 2 files changed, 41 insertions(+), 42 deletions(-) diff --git a/cmd/manager/main.go b/cmd/manager/main.go index 08c84533..ca3e2459 100644 --- a/cmd/manager/main.go +++ b/cmd/manager/main.go @@ -173,49 +173,48 @@ func main() { os.Exit(1) } - webHookServer := mgr.GetWebhookServer() - - webHookServer.Port = 7443 - webHookServer.CertDir = "./certs/" - - if enableDBProxyWebhook { - - cfg, err := dbwebhook.ParseConfig(dBProxySidecarConfigPath) - - if err != nil { - setupLog.Error(err, "could not parse db proxy sidecar configuration") - os.Exit(1) + if enableDBProxyWebhook || enableDsnExecWebhook { + webHookServer := mgr.GetWebhookServer() + webHookServer.Port = 7443 + webHookServer.CertDir = "./certs/" + if enableDBProxyWebhook { + + cfg, err := dbwebhook.ParseConfig(dBProxySidecarConfigPath) + + if err != nil { + setupLog.Error(err, "could not parse db proxy sidecar configuration") + os.Exit(1) + } + setupLog.Info("Parsed db proxy conig:", "dbproxysidecarconfig", cfg) + + setupLog.Info("registering with webhook server for DbProxy") + webHookServer.Register("/mutate", &webhook.Admission{ + Handler: &dbwebhook.DBProxyInjector{ + Name: "DB Proxy", + Client: mgr.GetClient(), + DBProxySidecarConfig: cfg, + }, + }) } - setupLog.Info("Parsed db proxy conig:", "dbproxysidecarconfig", cfg) - - setupLog.Info("registering with webhook server for DbProxy") - webHookServer.Register("/mutate", &webhook.Admission{ - Handler: &dbwebhook.DBProxyInjector{ - Name: "DB Proxy", - Client: mgr.GetClient(), - DBProxySidecarConfig: cfg, - }, - }) - } - - if enableDsnExecWebhook { - - cfg, err := dbwebhook.ParseConfig(dsnExecSidecarConfigPath) - - if err != nil { - setupLog.Error(err, "could not parse dsnexec sidecar configuration") - os.Exit(1) + if enableDsnExecWebhook { + + cfg, err := dbwebhook.ParseConfig(dsnExecSidecarConfigPath) + + if err != nil { + setupLog.Error(err, "could not parse dsnexec sidecar configuration") + os.Exit(1) + } + setupLog.Info("Parsed dsnexec conig:", "dsnexecsidecarconfig", cfg) + + setupLog.Info("registering with webhook server for DsnExec") + webHookServer.Register("/mutate-dsnexec", &webhook.Admission{ + Handler: &dbwebhook.DsnExecInjector{ + Name: "Dsnexec", + Client: mgr.GetClient(), + DsnExecSidecarConfig: cfg, + }, + }) } - setupLog.Info("Parsed dsnexec conig:", "dsnexecsidecarconfig", cfg) - - setupLog.Info("registering with webhook server for DsnExec") - webHookServer.Register("/mutate-dsnexec", &webhook.Admission{ - Handler: &dbwebhook.DsnExecInjector{ - Name: "Dsnexec", - Client: mgr.GetClient(), - DsnExecSidecarConfig: cfg, - }, - }) } setupLog.Info("starting manager") diff --git a/helm/db-controller/values.yaml b/helm/db-controller/values.yaml index 163b4848..450d8431 100644 --- a/helm/db-controller/values.yaml +++ b/helm/db-controller/values.yaml @@ -109,7 +109,7 @@ dbproxy: dsnexec: enabled: true image: - repository: "" + repository: "ghcr.io/infobloxopen/dsnexec" tag: "" zapLogger: