refactor(kv): template readability.
This commit is contained in:
parent
be0dd71bb4
commit
c95393b238
1 changed files with 61 additions and 58 deletions
|
@ -1,78 +1,81 @@
|
||||||
{{$frontends := List .Prefix "/frontends/" }}
|
[backends]
|
||||||
{{$backends := List .Prefix "/backends/"}}
|
{{range $backend := List .Prefix "/backends/"}}
|
||||||
{{$tlsconfiguration := List .Prefix "/tlsconfiguration/"}}
|
{{$backendName := Last $backend}}
|
||||||
|
|
||||||
[backends]{{range $backends}}
|
{{$circuitBreaker := Get "" $backend "/circuitbreaker/expression"}}
|
||||||
{{$backend := .}}
|
{{with $circuitBreaker}}
|
||||||
{{$backendName := Last $backend}}
|
[backends."{{$backendName}}".circuitBreaker]
|
||||||
{{$servers := ListServers $backend }}
|
|
||||||
|
|
||||||
{{$circuitBreaker := Get "" . "/circuitbreaker/" "expression"}}
|
|
||||||
{{with $circuitBreaker}}
|
|
||||||
[backends."{{$backendName}}".circuitBreaker]
|
|
||||||
expression = "{{$circuitBreaker}}"
|
expression = "{{$circuitBreaker}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{$loadBalancer := Get "" . "/loadbalancer/" "method"}}
|
{{$loadBalancer := Get "" $backend "/loadbalancer/method"}}
|
||||||
{{with $loadBalancer}}
|
{{with $loadBalancer}}
|
||||||
[backends."{{$backendName}}".loadBalancer]
|
[backends."{{$backendName}}".loadBalancer]
|
||||||
method = "{{$loadBalancer}}"
|
method = "{{$loadBalancer}}"
|
||||||
sticky = {{ getSticky . }}
|
sticky = {{ getSticky $backend }}
|
||||||
{{if hasStickinessLabel $backend}}
|
{{if hasStickinessLabel $backend}}
|
||||||
[backends."{{$backendName}}".loadBalancer.stickiness]
|
[backends."{{$backendName}}".loadBalancer.stickiness]
|
||||||
cookieName = "{{getStickinessCookieName $backend}}"
|
cookieName = "{{getStickinessCookieName $backend}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{$healthCheck := Get "" . "/healthcheck/" "path"}}
|
{{$maxConnAmt := Get "" $backend "/maxconn/amount"}}
|
||||||
{{with $healthCheck}}
|
{{$maxConnExtractorFunc := Get "" $backend "/maxconn/extractorfunc"}}
|
||||||
[backends."{{$backendName}}".healthCheck]
|
{{with $maxConnAmt}}
|
||||||
path = "{{$healthCheck}}"
|
{{with $maxConnExtractorFunc}}
|
||||||
interval = "{{ Get "30s" $backend "/healthcheck/" "interval" }}"
|
[backends."{{$backendName}}".maxConn]
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{$maxConnAmt := Get "" . "/maxconn/" "amount"}}
|
|
||||||
{{$maxConnExtractorFunc := Get "" . "/maxconn/" "extractorfunc"}}
|
|
||||||
{{with $maxConnAmt}}
|
|
||||||
{{with $maxConnExtractorFunc}}
|
|
||||||
[backends."{{$backendName}}".maxConn]
|
|
||||||
amount = {{$maxConnAmt}}
|
amount = {{$maxConnAmt}}
|
||||||
extractorFunc = "{{$maxConnExtractorFunc}}"
|
extractorFunc = "{{$maxConnExtractorFunc}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{$healthCheck := Get "" $backend "/healthcheck/path"}}
|
||||||
|
{{with $healthCheck}}
|
||||||
|
[backends."{{$backendName}}".healthCheck]
|
||||||
|
path = "{{$healthCheck}}"
|
||||||
|
interval = "{{ Get "30s" $backend "/healthcheck/interval" }}"
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{range $server := ListServers $backend}}
|
||||||
|
[backends."{{$backendName}}".servers."{{Last $server}}"]
|
||||||
|
url = "{{Get "" $server "/url"}}"
|
||||||
|
weight = {{Get "0" $server "/weight"}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{range $servers}}
|
[frontends]
|
||||||
[backends."{{$backendName}}".servers."{{Last .}}"]
|
{{range $frontend := List .Prefix "/frontends/" }}
|
||||||
url = "{{Get "" . "/url"}}"
|
{{$frontendName := Last $frontend}}
|
||||||
weight = {{Get "0" . "/weight"}}
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
[frontends]{{range $frontends}}
|
[frontends."{{$frontendName}}"]
|
||||||
{{$frontend := Last .}}
|
backend = "{{Get "" $frontend "/backend"}}"
|
||||||
{{$entryPoints := SplitGet . "/entrypoints"}}
|
priority = {{Get "0" $frontend "/priority"}}
|
||||||
[frontends."{{$frontend}}"]
|
passHostHeader = {{Get "true" $frontend "/passHostHeader"}}
|
||||||
backend = "{{Get "" . "/backend"}}"
|
|
||||||
passHostHeader = {{Get "true" . "/passHostHeader"}}
|
{{$entryPoints := SplitGet $frontend "/entrypoints"}}
|
||||||
priority = {{Get "0" . "/priority"}}
|
|
||||||
entryPoints = [{{range $entryPoints}}
|
entryPoints = [{{range $entryPoints}}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
{{$routes := List . "/routes/"}}
|
|
||||||
{{range $routes}}
|
{{range $route := List $frontend "/routes/"}}
|
||||||
[frontends."{{$frontend}}".routes."{{Last .}}"]
|
[frontends."{{$frontendName}}".routes."{{Last $route}}"]
|
||||||
rule = "{{Get "" . "/rule"}}"
|
rule = "{{Get "" $route "/rule"}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{range $tlsconfiguration}}
|
{{range $tlsConfiguration := List .Prefix "/tlsconfiguration/"}}
|
||||||
{{$entryPoints := SplitGet . "/entrypoints"}}
|
|
||||||
[[tlsConfiguration]]
|
[[tlsConfiguration]]
|
||||||
entryPoints = [{{range $entryPoints}}
|
|
||||||
"{{.}}",
|
|
||||||
{{end}}]
|
|
||||||
[tlsConfiguration.certificate]
|
|
||||||
certFile = """{{Get "" . "/certificate" "/certfile"}}"""
|
|
||||||
keyFile = """{{Get "" . "/certificate" "/keyfile"}}"""
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
|
{{$entryPoints := SplitGet $tlsConfiguration "/entrypoints"}}
|
||||||
|
entryPoints = [{{range $entryPoints}}
|
||||||
|
"{{.}}",
|
||||||
|
{{end}}]
|
||||||
|
|
||||||
|
[tlsConfiguration.certificate]
|
||||||
|
certFile = """{{Get "" $tlsConfiguration "/certificate/certfile"}}"""
|
||||||
|
keyFile = """{{Get "" $tlsConfiguration "/certificate/keyfile"}}"""
|
||||||
|
|
||||||
|
{{end}}
|
||||||
|
|
Loading…
Reference in a new issue