Skip to content

Commit 54e9b4a

Browse files
authored
Improve consistency of templates (#434)
* Improve consistency of nginx templates * Improve consistency of ingress templates * Remove logic from templates that are not needed
1 parent e3f5224 commit 54e9b4a

File tree

3 files changed

+21
-27
lines changed

3 files changed

+21
-27
lines changed

internal/nginx/templates/nginx-plus.ingress.tmpl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ upstream {{$upstream.Name}} {
1111
{{end}}
1212
{{if $.Keepalive}}keepalive {{$.Keepalive}};{{end}}
1313
{{- if $upstream.UpstreamServers -}}
14-
{{- if $upstream.Queue }}
14+
{{- if $upstream.Queue}}
1515
queue {{$upstream.Queue}} timeout={{$upstream.QueueTimeout}}s;
1616
{{- end -}}
17-
{{- end }}
17+
{{- end}}
1818
}
1919
{{- end}}
2020

@@ -70,7 +70,7 @@ server {
7070
}
7171
{{- end}}
7272

73-
{{ with $jwt := $server.JWTAuth }}
73+
{{with $jwt := $server.JWTAuth}}
7474
auth_jwt_key_file {{$jwt.Key}};
7575
auth_jwt "{{.Realm}}"{{if $jwt.Token}} token={{$jwt.Token}}{{end}};
7676

@@ -86,7 +86,7 @@ server {
8686

8787
{{- range $healthCheck := $server.HealthChecks}}
8888
location @hc-{{$healthCheck.UpstreamName}} {
89-
{{- range $name, $header := $healthCheck.Headers }}
89+
{{- range $name, $header := $healthCheck.Headers}}
9090
proxy_set_header {{$name}} "{{$header}}";
9191
{{- end }}
9292
proxy_connect_timeout {{$healthCheck.TimeoutSeconds}}s;
@@ -111,7 +111,7 @@ server {
111111
# location for minion {{$location.MinionIngress.Namespace}}/{{$location.MinionIngress.Name}}
112112
{{end}}
113113
{{if $location.GRPC}}
114-
{{if not $server.GRPCOnly}}
114+
{{if not $server.GRPCOnly}}
115115
error_page 400 @grpcerror400;
116116
error_page 401 @grpcerror401;
117117
error_page 403 @grpcerror403;
@@ -132,7 +132,7 @@ server {
132132
{{$value}}{{end}}
133133
{{- end}}
134134

135-
{{ with $jwt := $location.JWTAuth }}
135+
{{with $jwt := $location.JWTAuth}}
136136
auth_jwt_key_file {{$jwt.Key}};
137137
auth_jwt "{{.Realm}}"{{if $jwt.Token}} token={{$jwt.Token}}{{end}};
138138
{{end}}

internal/nginx/templates/nginx-plus.tmpl

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ events {
2222
worker_connections {{.WorkerConnections}};
2323
}
2424

25-
2625
http {
2726
include /etc/nginx/mime.types;
2827
default_type application/octet-stream;
@@ -38,7 +37,7 @@ http {
3837
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
3938
'$status $body_bytes_sent "$http_referer" '
4039
'"$http_user_agent" "$http_x_forwarded_for"';
41-
{{- end }}
40+
{{- end}}
4241
access_log /var/log/nginx/access.log main;
4342

4443
sendfile on;
@@ -61,7 +60,6 @@ http {
6160
{{if .SSLPreferServerCiphers}}ssl_prefer_server_ciphers on;{{end}}
6261
{{if .SSLDHParam}}ssl_dhparam {{.SSLDHParam}};{{end}}
6362

64-
6563
server {
6664
listen 80 default_server{{if .ProxyProtocol}} proxy_protocol{{end}};
6765
listen 443 ssl default_server{{if .HTTP2}} http2{{end}}{{if .ProxyProtocol}} proxy_protocol{{end}};
@@ -85,7 +83,7 @@ http {
8583
}
8684
}
8785

88-
{{- if .NginxStatus }}
86+
{{- if .NginxStatus}}
8987
# NGINX Plus APIs
9088
server {
9189
listen {{.NginxStatusPort}};
@@ -96,15 +94,15 @@ http {
9694

9795
location = /dashboard.html {
9896
}
99-
{{ range $value := .NginxStatusAllowCIDRs }}{{ if ne $value "" }}
100-
allow {{$value}};{{ end }}
101-
{{end}}
97+
{{range $value := .NginxStatusAllowCIDRs}}
98+
allow {{$value}};{{end}}
99+
102100
deny all;
103101
location /api {
104102
api write=off;
105103
}
106104
}
107-
{{- end }}
105+
{{- end}}
108106

109107
# NGINX Plus API over unix socket
110108
server {
@@ -135,11 +133,10 @@ stream {
135133
log_format stream-main '$remote_addr [$time_local] '
136134
'$protocol $status $bytes_sent $bytes_received '
137135
'$session_time';
138-
{{- end }}
136+
{{- end}}
139137

140138
access_log /var/log/nginx/stream-access.log stream-main;
141139

142140
{{range $value := .StreamSnippets}}
143-
{{$value}}
144-
{{end}}
141+
{{$value}}{{end}}
145142
}

internal/nginx/templates/nginx.tmpl

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ events {
2121
worker_connections {{.WorkerConnections}};
2222
}
2323

24-
2524
http {
2625
include /etc/nginx/mime.types;
2726
default_type application/octet-stream;
@@ -37,7 +36,7 @@ http {
3736
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
3837
'$status $body_bytes_sent "$http_referer" '
3938
'"$http_user_agent" "$http_x_forwarded_for"';
40-
{{- end }}
39+
{{- end}}
4140
access_log /var/log/nginx/access.log main;
4241

4342
sendfile on;
@@ -82,19 +81,18 @@ http {
8281
}
8382
}
8483

85-
{{- if .NginxStatus }}
84+
{{- if .NginxStatus}}
8685
# stub_status
8786
server {
8887
listen {{.NginxStatusPort}};
89-
{{ range $value := .NginxStatusAllowCIDRs }}{{ if ne $value "" }}
90-
allow {{$value}};{{ end }}
91-
{{end}}
88+
{{range $value := .NginxStatusAllowCIDRs}}
89+
allow {{$value}};{{end}}
9290
deny all;
9391
location /stub_status {
9492
stub_status;
9593
}
9694
}
97-
{{- end }}
95+
{{- end}}
9896

9997
include /etc/nginx/config-version.conf;
10098
include /etc/nginx/conf.d/*.conf;
@@ -107,11 +105,10 @@ stream {
107105
log_format stream-main '$remote_addr [$time_local] '
108106
'$protocol $status $bytes_sent $bytes_received '
109107
'$session_time';
110-
{{- end }}
108+
{{- end}}
111109

112110
access_log /var/log/nginx/stream-access.log stream-main;
113111

114112
{{range $value := .StreamSnippets}}
115-
{{$value}}
116-
{{end}}
113+
{{$value}}{{end}}
117114
}

0 commit comments

Comments
 (0)