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}}
|
||||
[backends]{{range $backendName, $backend := .Backends}}
|
||||
[backends]
|
||||
{{range $backendName, $backend := .Backends}}
|
||||
|
||||
{{if hasCircuitBreakerLabel $backend}}
|
||||
[backends.backend-{{$backendName}}.circuitbreaker]
|
||||
[backends.backend-{{$backendName}}.circuitBreaker]
|
||||
expression = "{{getCircuitBreakerExpression $backend}}"
|
||||
{{end}}
|
||||
|
||||
{{if hasLoadBalancerLabel $backend}}
|
||||
[backends.backend-{{$backendName}}.loadbalancer]
|
||||
[backends.backend-{{$backendName}}.loadBalancer]
|
||||
method = "{{getLoadBalancerMethod $backend}}"
|
||||
sticky = {{getSticky $backend}}
|
||||
{{if hasStickinessLabel $backend}}
|
||||
|
@ -16,9 +18,9 @@
|
|||
{{end}}
|
||||
|
||||
{{if hasMaxConnLabels $backend}}
|
||||
[backends.backend-{{$backendName}}.maxconn]
|
||||
[backends.backend-{{$backendName}}.maxConn]
|
||||
amount = {{getMaxConnAmount $backend}}
|
||||
extractorfunc = "{{getMaxConnExtractorFunc $backend}}"
|
||||
extractorFunc = "{{getMaxConnExtractorFunc $backend}}"
|
||||
{{end}}
|
||||
|
||||
{{$servers := index $backendServers $backendName}}
|
||||
|
@ -39,23 +41,29 @@
|
|||
|
||||
{{end}}
|
||||
|
||||
[frontends]{{range $frontend, $containers := .Frontends}}
|
||||
[frontends]
|
||||
{{range $frontend, $containers := .Frontends}}
|
||||
{{$container := index $containers 0}}
|
||||
|
||||
{{if hasServices $container}}
|
||||
{{$services := getServiceNames $container}}
|
||||
|
||||
{{range $serviceIndex, $serviceName := $services}}
|
||||
[frontends."frontend-{{getServiceBackend $container $serviceName}}"]
|
||||
backend = "backend-{{getServiceBackend $container $serviceName}}"
|
||||
priority = {{getServicePriority $container $serviceName}}
|
||||
passHostHeader = {{getServicePassHostHeader $container $serviceName}}
|
||||
|
||||
entryPoints = [{{range getServiceEntryPoints $container $serviceName}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
{{if getWhitelistSourceRange $container}}
|
||||
whitelistSourceRange = [{{range getWhitelistSourceRange $container}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
{{end}}
|
||||
priority = {{getServicePriority $container $serviceName}}
|
||||
entryPoints = [{{range getServiceEntryPoints $container $serviceName}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
basicAuth = [{{range getServiceBasicAuth $container $serviceName}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
@ -69,32 +77,40 @@
|
|||
|
||||
[frontends."frontend-{{getServiceBackend $container $serviceName}}".routes."service-{{$serviceName | replace "/" "" | replace "." "-"}}"]
|
||||
rule = "{{getServiceFrontendRule $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}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if hasServiceResponseHeaders $container $serviceName}}
|
||||
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customresponseheaders]
|
||||
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customResponseHeaders]
|
||||
{{range $k, $v := getServiceResponseHeaders $container $serviceName}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{end}} ## end range services
|
||||
|
||||
{{else}}
|
||||
|
||||
[frontends."frontend-{{$frontend}}"]
|
||||
backend = "backend-{{getBackend $container}}"
|
||||
priority = {{getPriority $container}}
|
||||
passHostHeader = {{getPassHostHeader $container}}
|
||||
|
||||
entryPoints = [{{range getEntryPoints $container}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
{{if getWhitelistSourceRange $container}}
|
||||
whitelistSourceRange = [{{range getWhitelistSourceRange $container}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
{{end}}
|
||||
priority = {{getPriority $container}}
|
||||
entryPoints = [{{range getEntryPoints $container}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
basicAuth = [{{range getBasicAuth $container}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
@ -153,13 +169,13 @@
|
|||
IsDevelopment = {{getIsDevelopmentHeaders $container}}
|
||||
{{end}}
|
||||
{{if hasRequestHeaders $container}}
|
||||
[frontends."frontend-{{$frontend}}".headers.customrequestheaders]
|
||||
[frontends."frontend-{{$frontend}}".headers.customRequestHeaders]
|
||||
{{range $k, $v := getRequestHeaders $container}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if hasResponseHeaders $container}}
|
||||
[frontends."frontend-{{$frontend}}".headers.customresponseheaders]
|
||||
[frontends."frontend-{{$frontend}}".headers.customResponseHeaders]
|
||||
{{range $k, $v := getResponseHeaders $container}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
|
@ -182,7 +198,10 @@
|
|||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
[frontends."frontend-{{$frontend}}".routes."route-frontend-{{$frontend}}"]
|
||||
rule = "{{getFrontendRule $container}}"
|
||||
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in a new issue