Make template more readable
* $value -> $container
This commit is contained in:
parent
e1bbe8cde0
commit
3414a02edf
1 changed files with 10 additions and 10 deletions
20
nginx.tmpl
20
nginx.tmpl
|
@ -33,30 +33,30 @@ server {
|
||||||
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
{{ range $host, $containers := groupByMulti $ "Env.VIRTUAL_HOST" "," }}
|
||||||
upstream {{ $host }} {
|
upstream {{ $host }} {
|
||||||
|
|
||||||
{{ range $index, $value := $containers }}
|
{{ range $index, $container := $containers }}
|
||||||
|
|
||||||
{{ $addrLen := len $value.Addresses }}
|
{{ $addrLen := len $container.Addresses }}
|
||||||
{{/* If only 1 port exposed, use that */}}
|
{{/* If only 1 port exposed, use that */}}
|
||||||
{{ if eq $addrLen 1 }}
|
{{ if eq $addrLen 1 }}
|
||||||
{{ with $address := index $value.Addresses 0 }}
|
{{ with $address := index $container.Addresses 0 }}
|
||||||
# {{$value.Name}}
|
# {{$container.Name}}
|
||||||
server {{ $address.IP }}:{{ $address.Port }};
|
server {{ $address.IP }}:{{ $address.Port }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var */}}
|
{{/* If more than one port exposed, use the one matching VIRTUAL_PORT env var */}}
|
||||||
{{ else if $value.Env.VIRTUAL_PORT }}
|
{{ else if $container.Env.VIRTUAL_PORT }}
|
||||||
{{ range $i, $address := $value.Addresses }}
|
{{ range $index, $address := $container.Addresses }}
|
||||||
{{ if eq $address.Port $value.Env.VIRTUAL_PORT }}
|
{{ if eq $address.Port $container.Env.VIRTUAL_PORT }}
|
||||||
# {{$value.Name}}
|
# {{$container.Name}}
|
||||||
server {{ $address.IP }}:{{ $address.Port }};
|
server {{ $address.IP }}:{{ $address.Port }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{/* Else default to standard web port 80 */}}
|
{{/* Else default to standard web port 80 */}}
|
||||||
{{ else }}
|
{{ else }}
|
||||||
{{ range $i, $address := $value.Addresses }}
|
{{ range $index, $address := $container.Addresses }}
|
||||||
{{ if eq $address.Port "80" }}
|
{{ if eq $address.Port "80" }}
|
||||||
# {{$value.Name}}
|
# {{$container.Name}}
|
||||||
server {{ $address.IP }}:{{ $address.Port }};
|
server {{ $address.IP }}:{{ $address.Port }};
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Reference in a new issue