From d0bc1b72c6ea2d61511d53cb35bd34a76bd103b2 Mon Sep 17 00:00:00 2001
From: nhyatt <nhyatt@smoothnet.org>
Date: Mon, 10 Oct 2022 14:18:34 -0500
Subject: [PATCH] updates for configuration changes.

---
 cmd/webhook/httpServer.go | 14 +++++++-------
 cmd/webhook/main.go       |  4 ++--
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/cmd/webhook/httpServer.go b/cmd/webhook/httpServer.go
index 414dc80..c4e609c 100644
--- a/cmd/webhook/httpServer.go
+++ b/cmd/webhook/httpServer.go
@@ -1,7 +1,8 @@
 package main
-/*
+
 import (
 	"log"
+	"mutating-webhook/internal/config"
 	"net/http"
 	"strconv"
 	"strings"
@@ -20,15 +21,15 @@ func crossSiteOrigin(w http.ResponseWriter) {
 	w.Header().Add("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, Authorization, X-API-Token")
 }
 
-func httpServer(host string, port int) {
+func httpServer(cfg *config.Config) {
 	path := http.NewServeMux()
 
 	connection := &http.Server{
-		Addr:         host + ":" + strconv.FormatInt(int64(port), 10),
+		Addr:         cfg.WebServerIP + ":" + strconv.FormatInt(int64(cfg.WebServerPort), 10),
 		Handler:      path,
-		ReadTimeout:  time.Duration(config.WebSrvReadTimeout) * time.Second,
-		WriteTimeout: time.Duration(config.WebSrvWriteTimeout) * time.Second,
-		IdleTimeout:  time.Duration(config.WebSrvIdleTimeout) * time.Second,
+		ReadTimeout:  time.Duration(cfg.WebServerReadTimeout) * time.Second,
+		WriteTimeout: time.Duration(cfg.WebServerWriteTimeout) * time.Second,
+		IdleTimeout:  time.Duration(cfg.WebServerIdleTimeout) * time.Second,
 	}
 
 	// healthcheck
@@ -70,4 +71,3 @@ func webHealthCheck(w http.ResponseWriter, r *http.Request) {
 		tmpltError(w, http.StatusBadRequest, InvalidMethod)
 	}
 }
-*/
\ No newline at end of file
diff --git a/cmd/webhook/main.go b/cmd/webhook/main.go
index 0e6f452..cf9ff2b 100644
--- a/cmd/webhook/main.go
+++ b/cmd/webhook/main.go
@@ -23,9 +23,9 @@ func main() {
 	}()
 
 	// initialize application configuration
-	initialize.Init()
+	cfg := initialize.Init()
 
-	//go httpServer(cfg.WebSrvIP, cfg.WebSrvPort)
+	go httpServer(cfg)
 
 	forever()
 }