diff --git a/controllers/nginx/pkg/config/config.go b/controllers/nginx/pkg/config/config.go index 799c37b3d5..b72b690e53 100644 --- a/controllers/nginx/pkg/config/config.go +++ b/controllers/nginx/pkg/config/config.go @@ -302,8 +302,8 @@ type Configuration struct { // NewDefault returns the default nginx configuration func NewDefault() Configuration { - defIPCIDR := make([]string, 0) - defIPCIDR = append(defIPCIDR, "0.0.0.0/0") + defIPCIDR := make([]string, 0) + defIPCIDR = append(defIPCIDR, "0.0.0.0/0") cfg := Configuration{ AllowBackendServerHeader: false, ClientHeaderBufferSize: "1k", diff --git a/controllers/nginx/pkg/template/configmap.go b/controllers/nginx/pkg/template/configmap.go index 577a816e56..2b5401e420 100644 --- a/controllers/nginx/pkg/template/configmap.go +++ b/controllers/nginx/pkg/template/configmap.go @@ -30,7 +30,7 @@ const ( customHTTPErrors = "custom-http-errors" skipAccessLogUrls = "skip-access-log-urls" whitelistSourceRange = "whitelist-source-range" - proxyRealIPCIDR = "proxy-real-ip-cidr" + proxyRealIPCIDR = "proxy-real-ip-cidr" ) // ReadConfig obtains the configuration defined by the user merged with the defaults. @@ -46,7 +46,7 @@ func ReadConfig(src map[string]string) config.Configuration { errors := make([]int, 0) skipUrls := make([]string, 0) whitelist := make([]string, 0) - proxylist := make([]string, 0) + proxylist := make([]string, 0) if val, ok := conf[customHTTPErrors]; ok { delete(conf, customHTTPErrors) @@ -71,14 +71,14 @@ func ReadConfig(src map[string]string) config.Configuration { delete(conf, proxyRealIPCIDR) proxylist = append(proxylist, strings.Split(val, ",")...) } else { - proxylist = append(proxylist, "0.0.0.0/0") - } + proxylist = append(proxylist, "0.0.0.0/0") + } to := config.NewDefault() to.CustomHTTPErrors = filterErrors(errors) to.SkipAccessLogURLs = skipUrls to.WhitelistSourceRange = whitelist - to.ProxyRealIPCIDR = proxylist + to.ProxyRealIPCIDR = proxylist config := &mapstructure.DecoderConfig{ Metadata: nil, diff --git a/controllers/nginx/pkg/template/configmap_test.go b/controllers/nginx/pkg/template/configmap_test.go index aadfb83c78..b7aab61aca 100644 --- a/controllers/nginx/pkg/template/configmap_test.go +++ b/controllers/nginx/pkg/template/configmap_test.go @@ -42,7 +42,7 @@ func TestMergeConfigMapToStruct(t *testing.T) { "use-gzip": "true", "enable-dynamic-tls-records": "false", "gzip-types": "text/html", - "proxy-real-ip-cidr": "1.1.1.1/8,2.2.2.2/24", + "proxy-real-ip-cidr": "1.1.1.1/8,2.2.2.2/24", } def := config.NewDefault() def.CustomHTTPErrors = []int{300, 400} @@ -53,7 +53,7 @@ func TestMergeConfigMapToStruct(t *testing.T) { def.EnableDynamicTLSRecords = false def.UseProxyProtocol = true def.GzipTypes = "text/html" - def.ProxyRealIPCIDR = []string{"1.1.1.1/8", "2.2.2.2/24"} + def.ProxyRealIPCIDR = []string{"1.1.1.1/8", "2.2.2.2/24"} to := ReadConfig(conf) if diff := pretty.Compare(to, def); diff != "" {