Skip to content

Commit

Permalink
Address PR review for webhook setup
Browse files Browse the repository at this point in the history
Signed-off-by: Maysun J Faisal <maysunaneek@gmail.com>
  • Loading branch information
maysunfaisal committed Oct 26, 2023
1 parent 3f459a9 commit e3667e7
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down Expand Up @@ -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"}
},
)
}
}

0 comments on commit e3667e7

Please sign in to comment.