From e3667e71a9464138617d853023009996c0fccce2 Mon Sep 17 00:00:00 2001 From: Maysun J Faisal Date: Thu, 26 Oct 2023 17:31:26 -0400 Subject: [PATCH] Address PR review for webhook setup Signed-off-by: Maysun J Faisal --- main.go | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/main.go b/main.go index 3a2875c72..dea1fb227 100644 --- a/main.go +++ b/main.go @@ -160,12 +160,6 @@ func main() { } } - // Retrieve the option to enable HTTP2 on the Webhook server - enableWebhookHTTP2 := os.Getenv("ENABLE_WEBHOOK_HTTP2") - if enableWebhookHTTP2 == "" { - enableWebhookHTTP2 = "false" - } - // Parse any passed in tokens and set up a client for handling the github tokens err = github.ParseGitHubTokens() if err != nil { @@ -232,15 +226,6 @@ func main() { if os.Getenv("ENABLE_WEBHOOKS") != "false" { setupLog.Info("setting up webhooks") setUpWebhooks(mgr) - server := mgr.GetWebhookServer() - if enableWebhookHTTP2 == "false" { - setupLog.Info("disabling http/2 on the webhook server") - server.TLSOpts = append(server.TLSOpts, - func(c *tls.Config) { - c.NextProtos = []string{"http/1.1"} - }, - ) - } } if err = (&controllers.SnapshotEnvironmentBindingReconciler{ @@ -279,4 +264,20 @@ func setUpWebhooks(mgr ctrl.Manager) { setupLog.Error(err, "unable to setup webhooks") os.Exit(1) } + + // Retrieve the option to enable HTTP2 on the Webhook server + enableWebhookHTTP2 := os.Getenv("ENABLE_WEBHOOK_HTTP2") + if enableWebhookHTTP2 == "" { + enableWebhookHTTP2 = "false" + } + + if enableWebhookHTTP2 == "false" { + setupLog.Info("disabling http/2 on the webhook server") + server := mgr.GetWebhookServer() + server.TLSOpts = append(server.TLSOpts, + func(c *tls.Config) { + c.NextProtos = []string{"http/1.1"} + }, + ) + } }