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 := List .Prefix "/backends/"}}
|
||||
{{$tlsconfiguration := List .Prefix "/tlsconfiguration/"}}
|
||||
[backends]
|
||||
{{range $backend := List .Prefix "/backends/"}}
|
||||
{{$backendName := Last $backend}}
|
||||
|
||||
[backends]{{range $backends}}
|
||||
{{$backend := .}}
|
||||
{{$backendName := Last $backend}}
|
||||
{{$servers := ListServers $backend }}
|
||||
|
||||
{{$circuitBreaker := Get "" . "/circuitbreaker/" "expression"}}
|
||||
{{with $circuitBreaker}}
|
||||
[backends."{{$backendName}}".circuitBreaker]
|
||||
{{$circuitBreaker := Get "" $backend "/circuitbreaker/expression"}}
|
||||
{{with $circuitBreaker}}
|
||||
[backends."{{$backendName}}".circuitBreaker]
|
||||
expression = "{{$circuitBreaker}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{$loadBalancer := Get "" . "/loadbalancer/" "method"}}
|
||||
{{with $loadBalancer}}
|
||||
[backends."{{$backendName}}".loadBalancer]
|
||||
{{$loadBalancer := Get "" $backend "/loadbalancer/method"}}
|
||||
{{with $loadBalancer}}
|
||||
[backends."{{$backendName}}".loadBalancer]
|
||||
method = "{{$loadBalancer}}"
|
||||
sticky = {{ getSticky . }}
|
||||
sticky = {{ getSticky $backend }}
|
||||
{{if hasStickinessLabel $backend}}
|
||||
[backends."{{$backendName}}".loadBalancer.stickiness]
|
||||
cookieName = "{{getStickinessCookieName $backend}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{$healthCheck := Get "" . "/healthcheck/" "path"}}
|
||||
{{with $healthCheck}}
|
||||
[backends."{{$backendName}}".healthCheck]
|
||||
path = "{{$healthCheck}}"
|
||||
interval = "{{ Get "30s" $backend "/healthcheck/" "interval" }}"
|
||||
{{end}}
|
||||
|
||||
{{$maxConnAmt := Get "" . "/maxconn/" "amount"}}
|
||||
{{$maxConnExtractorFunc := Get "" . "/maxconn/" "extractorfunc"}}
|
||||
{{with $maxConnAmt}}
|
||||
{{with $maxConnExtractorFunc}}
|
||||
[backends."{{$backendName}}".maxConn]
|
||||
{{$maxConnAmt := Get "" $backend "/maxconn/amount"}}
|
||||
{{$maxConnExtractorFunc := Get "" $backend "/maxconn/extractorfunc"}}
|
||||
{{with $maxConnAmt}}
|
||||
{{with $maxConnExtractorFunc}}
|
||||
[backends."{{$backendName}}".maxConn]
|
||||
amount = {{$maxConnAmt}}
|
||||
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}}
|
||||
|
||||
{{range $servers}}
|
||||
[backends."{{$backendName}}".servers."{{Last .}}"]
|
||||
url = "{{Get "" . "/url"}}"
|
||||
weight = {{Get "0" . "/weight"}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
[frontends]
|
||||
{{range $frontend := List .Prefix "/frontends/" }}
|
||||
{{$frontendName := Last $frontend}}
|
||||
|
||||
[frontends]{{range $frontends}}
|
||||
{{$frontend := Last .}}
|
||||
{{$entryPoints := SplitGet . "/entrypoints"}}
|
||||
[frontends."{{$frontend}}"]
|
||||
backend = "{{Get "" . "/backend"}}"
|
||||
passHostHeader = {{Get "true" . "/passHostHeader"}}
|
||||
priority = {{Get "0" . "/priority"}}
|
||||
[frontends."{{$frontendName}}"]
|
||||
backend = "{{Get "" $frontend "/backend"}}"
|
||||
priority = {{Get "0" $frontend "/priority"}}
|
||||
passHostHeader = {{Get "true" $frontend "/passHostHeader"}}
|
||||
|
||||
{{$entryPoints := SplitGet $frontend "/entrypoints"}}
|
||||
entryPoints = [{{range $entryPoints}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
{{$routes := List . "/routes/"}}
|
||||
{{range $routes}}
|
||||
[frontends."{{$frontend}}".routes."{{Last .}}"]
|
||||
rule = "{{Get "" . "/rule"}}"
|
||||
{{end}}
|
||||
{{end}}]
|
||||
|
||||
{{range $route := List $frontend "/routes/"}}
|
||||
[frontends."{{$frontendName}}".routes."{{Last $route}}"]
|
||||
rule = "{{Get "" $route "/rule"}}"
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
{{range $tlsconfiguration}}
|
||||
{{$entryPoints := SplitGet . "/entrypoints"}}
|
||||
{{range $tlsConfiguration := List .Prefix "/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