Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix whitespace in nginx templates #597

Merged
merged 2 commits into from
Apr 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions internal/nginx/config/servers_template.go
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
package config

var serversTemplateText = `
{{ range $s := . }}
{{ if $s.IsDefaultSSL }}
{{ range $s := . -}}
{{ if $s.IsDefaultSSL -}}
server {
listen 443 ssl default_server;

ssl_reject_handshake on;
}
{{ else if $s.IsDefaultHTTP }}
{{- else if $s.IsDefaultHTTP }}
server {
listen 80 default_server;

default_type text/html;
return 404;
}
{{ else }}
{{- else }}
server {
{{ if $s.SSL }}
{{- if $s.SSL }}
listen 443 ssl;
ssl_certificate {{ $s.SSL.Certificate }};
ssl_certificate_key {{ $s.SSL.CertificateKey }};

if ($ssl_server_name != $host) {
return 421;
}
{{ end }}
{{- end }}

server_name {{ $s.ServerName }};

{{ range $l := $s.Locations }}
location {{ $l.Path }} {
{{ if $l.Internal }}
{{ if $l.Internal -}}
internal;
{{ end }}

{{ if $l.Return }}
{{- if $l.Return -}}
return {{ $l.Return.Code }} "{{ $l.Return.Body }}";
{{ end }}

{{ if $l.HTTPMatchVar }}
{{- if $l.HTTPMatchVar -}}
set $http_matches {{ $l.HTTPMatchVar | printf "%q" }};
js_content httpmatches.redirect;
{{ end }}

{{ if $l.ProxyPass }}
{{- if $l.ProxyPass -}}
proxy_set_header Host $host;
proxy_pass {{ $l.ProxyPass }}$request_uri;
{{ end }}
{{- end }}
}
{{ end }}
}
{{ end }}
{{- end }}
{{ end }}
server {
listen unix:/var/lib/nginx/nginx-502-server.sock;
Expand Down
13 changes: 7 additions & 6 deletions internal/nginx/config/split_clients_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package config
var splitClientsTemplateText = `
{{ range $sc := . }}
split_clients $request_id ${{ $sc.VariableName }} {
{{ range $d := $sc.Distributions }}
{{ if eq $d.Percent "0.00" }}
{{- range $d := $sc.Distributions }}
{{- if eq $d.Percent "0.00" }}
# {{ $d.Percent }}% {{ $d.Value }};
{{ else }}
{{- else }}
{{ $d.Percent }}% {{ $d.Value }};
{{ end }}
{{ end }}
{{- end }}
{{- end }}
}
{{ end }}`
{{ end }}
`
5 changes: 3 additions & 2 deletions internal/nginx/config/upstreams_template.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ upstream {{ $u.Name }} {
random two least_conn;
{{ range $server := $u.Servers }}
server {{ $server.Address }};
{{ end }}
{{- end }}
}
{{ end }}`
{{ end }}
`