refactor(docker): template readability.
This commit is contained in:
parent
705f3f1372
commit
6e5f7650a5
1 changed files with 168 additions and 149 deletions
|
@ -1,12 +1,14 @@
|
||||||
{{$backendServers := .Servers}}
|
{{$backendServers := .Servers}}
|
||||||
[backends]{{range $backendName, $backend := .Backends}}
|
[backends]
|
||||||
|
{{range $backendName, $backend := .Backends}}
|
||||||
|
|
||||||
{{if hasCircuitBreakerLabel $backend}}
|
{{if hasCircuitBreakerLabel $backend}}
|
||||||
[backends.backend-{{$backendName}}.circuitbreaker]
|
[backends.backend-{{$backendName}}.circuitBreaker]
|
||||||
expression = "{{getCircuitBreakerExpression $backend}}"
|
expression = "{{getCircuitBreakerExpression $backend}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasLoadBalancerLabel $backend}}
|
{{if hasLoadBalancerLabel $backend}}
|
||||||
[backends.backend-{{$backendName}}.loadbalancer]
|
[backends.backend-{{$backendName}}.loadBalancer]
|
||||||
method = "{{getLoadBalancerMethod $backend}}"
|
method = "{{getLoadBalancerMethod $backend}}"
|
||||||
sticky = {{getSticky $backend}}
|
sticky = {{getSticky $backend}}
|
||||||
{{if hasStickinessLabel $backend}}
|
{{if hasStickinessLabel $backend}}
|
||||||
|
@ -16,9 +18,9 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasMaxConnLabels $backend}}
|
{{if hasMaxConnLabels $backend}}
|
||||||
[backends.backend-{{$backendName}}.maxconn]
|
[backends.backend-{{$backendName}}.maxConn]
|
||||||
amount = {{getMaxConnAmount $backend}}
|
amount = {{getMaxConnAmount $backend}}
|
||||||
extractorfunc = "{{getMaxConnExtractorFunc $backend}}"
|
extractorFunc = "{{getMaxConnExtractorFunc $backend}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{$servers := index $backendServers $backendName}}
|
{{$servers := index $backendServers $backendName}}
|
||||||
|
@ -39,23 +41,29 @@
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
[frontends]{{range $frontend, $containers := .Frontends}}
|
[frontends]
|
||||||
|
{{range $frontend, $containers := .Frontends}}
|
||||||
{{$container := index $containers 0}}
|
{{$container := index $containers 0}}
|
||||||
|
|
||||||
{{if hasServices $container}}
|
{{if hasServices $container}}
|
||||||
{{$services := getServiceNames $container}}
|
{{$services := getServiceNames $container}}
|
||||||
|
|
||||||
{{range $serviceIndex, $serviceName := $services}}
|
{{range $serviceIndex, $serviceName := $services}}
|
||||||
[frontends."frontend-{{getServiceBackend $container $serviceName}}"]
|
[frontends."frontend-{{getServiceBackend $container $serviceName}}"]
|
||||||
backend = "backend-{{getServiceBackend $container $serviceName}}"
|
backend = "backend-{{getServiceBackend $container $serviceName}}"
|
||||||
|
priority = {{getServicePriority $container $serviceName}}
|
||||||
passHostHeader = {{getServicePassHostHeader $container $serviceName}}
|
passHostHeader = {{getServicePassHostHeader $container $serviceName}}
|
||||||
|
|
||||||
|
entryPoints = [{{range getServiceEntryPoints $container $serviceName}}
|
||||||
|
"{{.}}",
|
||||||
|
{{end}}]
|
||||||
|
|
||||||
{{if getWhitelistSourceRange $container}}
|
{{if getWhitelistSourceRange $container}}
|
||||||
whitelistSourceRange = [{{range getWhitelistSourceRange $container}}
|
whitelistSourceRange = [{{range getWhitelistSourceRange $container}}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
{{end}}
|
{{end}}
|
||||||
priority = {{getServicePriority $container $serviceName}}
|
|
||||||
entryPoints = [{{range getServiceEntryPoints $container $serviceName}}
|
|
||||||
"{{.}}",
|
|
||||||
{{end}}]
|
|
||||||
basicAuth = [{{range getServiceBasicAuth $container $serviceName}}
|
basicAuth = [{{range getServiceBasicAuth $container $serviceName}}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
|
@ -69,32 +77,40 @@
|
||||||
|
|
||||||
[frontends."frontend-{{getServiceBackend $container $serviceName}}".routes."service-{{$serviceName | replace "/" "" | replace "." "-"}}"]
|
[frontends."frontend-{{getServiceBackend $container $serviceName}}".routes."service-{{$serviceName | replace "/" "" | replace "." "-"}}"]
|
||||||
rule = "{{getServiceFrontendRule $container $serviceName}}"
|
rule = "{{getServiceFrontendRule $container $serviceName}}"
|
||||||
|
|
||||||
{{if hasServiceRequestHeaders $container $serviceName}}
|
{{if hasServiceRequestHeaders $container $serviceName}}
|
||||||
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customrequestheaders]
|
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customRequestHeaders]
|
||||||
{{range $k, $v := getServiceRequestHeaders $container $serviceName}}
|
{{range $k, $v := getServiceRequestHeaders $container $serviceName}}
|
||||||
{{$k}} = "{{$v}}"
|
{{$k}} = "{{$v}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if hasServiceResponseHeaders $container $serviceName}}
|
{{if hasServiceResponseHeaders $container $serviceName}}
|
||||||
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customresponseheaders]
|
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customResponseHeaders]
|
||||||
{{range $k, $v := getServiceResponseHeaders $container $serviceName}}
|
{{range $k, $v := getServiceResponseHeaders $container $serviceName}}
|
||||||
{{$k}} = "{{$v}}"
|
{{$k}} = "{{$v}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
|
||||||
|
{{end}} ## end range services
|
||||||
|
|
||||||
{{else}}
|
{{else}}
|
||||||
|
|
||||||
[frontends."frontend-{{$frontend}}"]
|
[frontends."frontend-{{$frontend}}"]
|
||||||
backend = "backend-{{getBackend $container}}"
|
backend = "backend-{{getBackend $container}}"
|
||||||
|
priority = {{getPriority $container}}
|
||||||
passHostHeader = {{getPassHostHeader $container}}
|
passHostHeader = {{getPassHostHeader $container}}
|
||||||
|
|
||||||
|
entryPoints = [{{range getEntryPoints $container}}
|
||||||
|
"{{.}}",
|
||||||
|
{{end}}]
|
||||||
|
|
||||||
{{if getWhitelistSourceRange $container}}
|
{{if getWhitelistSourceRange $container}}
|
||||||
whitelistSourceRange = [{{range getWhitelistSourceRange $container}}
|
whitelistSourceRange = [{{range getWhitelistSourceRange $container}}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
{{end}}
|
{{end}}
|
||||||
priority = {{getPriority $container}}
|
|
||||||
entryPoints = [{{range getEntryPoints $container}}
|
|
||||||
"{{.}}",
|
|
||||||
{{end}}]
|
|
||||||
basicAuth = [{{range getBasicAuth $container}}
|
basicAuth = [{{range getBasicAuth $container}}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
|
@ -153,13 +169,13 @@
|
||||||
IsDevelopment = {{getIsDevelopmentHeaders $container}}
|
IsDevelopment = {{getIsDevelopmentHeaders $container}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if hasRequestHeaders $container}}
|
{{if hasRequestHeaders $container}}
|
||||||
[frontends."frontend-{{$frontend}}".headers.customrequestheaders]
|
[frontends."frontend-{{$frontend}}".headers.customRequestHeaders]
|
||||||
{{range $k, $v := getRequestHeaders $container}}
|
{{range $k, $v := getRequestHeaders $container}}
|
||||||
{{$k}} = "{{$v}}"
|
{{$k}} = "{{$v}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if hasResponseHeaders $container}}
|
{{if hasResponseHeaders $container}}
|
||||||
[frontends."frontend-{{$frontend}}".headers.customresponseheaders]
|
[frontends."frontend-{{$frontend}}".headers.customResponseHeaders]
|
||||||
{{range $k, $v := getResponseHeaders $container}}
|
{{range $k, $v := getResponseHeaders $container}}
|
||||||
{{$k}} = "{{$v}}"
|
{{$k}} = "{{$v}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
@ -182,7 +198,10 @@
|
||||||
{{$k}} = "{{$v}}"
|
{{$k}} = "{{$v}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
[frontends."frontend-{{$frontend}}".routes."route-frontend-{{$frontend}}"]
|
[frontends."frontend-{{$frontend}}".routes."route-frontend-{{$frontend}}"]
|
||||||
rule = "{{getFrontendRule $container}}"
|
rule = "{{getFrontendRule $container}}"
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue