Skip to content

Commit

Permalink
review comments incorporated - skipping webhook server creation if no…
Browse files Browse the repository at this point in the history
…t necessory
  • Loading branch information
abodhekar committed Sep 25, 2023
1 parent 0cc0073 commit c0331bb
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 42 deletions.
81 changes: 40 additions & 41 deletions cmd/manager/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion helm/db-controller/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ dbproxy:
dsnexec:
enabled: true
image:
repository: ""
repository: "ghcr.io/infobloxopen/dsnexec"
tag: ""

zapLogger:
Expand Down

0 comments on commit c0331bb

Please sign in to comment.