refactor(k8s): template readability.

fix(k8s): redirection template.
This commit is contained in:
Fernandez Ludovic 2018-01-05 11:53:31 +01:00 committed by Traefiker
parent 4497ddbb0e
commit 742dde72bb

View file

@ -1,25 +1,23 @@
[backends] [backends]
{{range $backendName, $backend := .Backends}} {{range $backendName, $backend := .Backends }}
[backends."{{$backendName}}"] [backends."{{ $backendName }}"]
{{if $backend.CircuitBreaker}} {{if $backend.CircuitBreaker }}
[backends."{{$backendName}}".circuitBreaker] [backends."{{ $backendName }} ".circuitBreaker]
expression = "{{$backend.CircuitBreaker.Expression}}" expression = "{{ $backend.CircuitBreaker.Expression }}"
{{end}} {{end}}
[backends."{{$backendName}}".loadBalancer] [backends."{{ $backendName }}".loadBalancer]
method = "{{$backend.LoadBalancer.Method}}" method = "{{ $backend.LoadBalancer.Method }}"
{{if $backend.LoadBalancer.Sticky}} sticky = {{ $backend.LoadBalancer.Sticky }}
sticky = true {{if $backend.LoadBalancer.Stickiness }}
{{end}} [backends."{{ $backendName }}".loadBalancer.stickiness]
{{if $backend.LoadBalancer.Stickiness}} cookieName = "{{ $backend.LoadBalancer.Stickiness.CookieName }}"
[backends."{{$backendName}}".loadBalancer.stickiness]
cookieName = "{{$backend.LoadBalancer.Stickiness.CookieName}}"
{{end}} {{end}}
{{if $backend.MaxConn}} {{if $backend.MaxConn }}
[backends.backend-{{$backendName}}.maxConn] [backends.backend-{{ $backendName }}.maxConn]
amount = {{ $backend.MaxConn.Amount }} amount = {{ $backend.MaxConn.Amount }}
extractorFunc = "{{ $backend.MaxConn.ExtractorFunc }}" extractorFunc = "{{ $backend.MaxConn.ExtractorFunc }}"
{{end}} {{end}}
@ -33,60 +31,60 @@
retryExpression = "{{ $backend.Buffering.RetryExpression }}" retryExpression = "{{ $backend.Buffering.RetryExpression }}"
{{end}} {{end}}
{{range $serverName, $server := $backend.Servers}} {{range $serverName, $server := $backend.Servers }}
[backends."{{$backendName}}".servers."{{$serverName}}"] [backends."{{ $backendName }}".servers."{{ $serverName }}"]
url = "{{$server.URL}}" url = "{{ $server.URL }}"
weight = {{$server.Weight}} weight = {{ $server.Weight }}
{{end}} {{end}}
{{end}} {{end}}
[frontends] [frontends]
{{range $frontendName, $frontend := .Frontends}} {{range $frontendName, $frontend := .Frontends }}
[frontends."{{$frontendName}}"] [frontends."{{ $frontendName }}"]
backend = "{{$frontend.Backend}}" backend = "{{ $frontend.Backend }}"
priority = {{$frontend.Priority}} priority = {{ $frontend.Priority }}
passHostHeader = {{$frontend.PassHostHeader}} passHostHeader = {{ $frontend.PassHostHeader }}
passTLSCert = {{$frontend.PassTLSCert}} passTLSCert = {{ $frontend.PassTLSCert }}
entryPoints = [{{range $frontend.EntryPoints}} entryPoints = [{{range $frontend.EntryPoints }}
"{{.}}", "{{.}}",
{{end}}] {{end}}]
basicAuth = [{{range $frontend.BasicAuth}} basicAuth = [{{range $frontend.BasicAuth }}
"{{.}}", "{{.}}",
{{end}}] {{end}}]
whitelistSourceRange = [{{range $frontend.WhitelistSourceRange}} whitelistSourceRange = [{{range $frontend.WhitelistSourceRange }}
"{{.}}", "{{.}}",
{{end}}] {{end}}]
{{if $frontend.Redirect}} {{if $frontend.Redirect }}
[frontends."{{$frontendName}}".redirect] [frontends."{{ $frontendName }}".redirect]
entryPoint = "{{$frontend.RedirectEntryPoint}}" entryPoint = "{{ $frontend.Redirect.EntryPoint }}"
regex = "{{$frontend.RedirectRegex}}" regex = "{{ $frontend.Redirect.Regex }}"
replacement = "{{$frontend.RedirectReplacement}}" replacement = "{{ $frontend.Redirect.Replacement }}"
{{end}} {{end}}
{{ if $frontend.Errors }} {{if $frontend.Errors }}
[frontends."frontend-{{$frontendName}}".errors] [frontends."frontend-{{ $frontendName }}".errors]
{{ range $pageName, $page := $frontend.Errors }} {{range $pageName, $page := $frontend.Errors }}
[frontends."frontend-{{$frontendName}}".errors.{{ $pageName }}] [frontends."frontend-{{ $frontendName }}".errors.{{ $pageName }}]
status = [{{range $page.Status}} status = [{{range $page.Status }}
"{{.}}", "{{.}}",
{{end}}] {{end}}]
backend = "{{$page.Backend}}" backend = "{{ $page.Backend }}"
query = "{{$page.Query}}" query = "{{ $page.Query }}"
{{end}} {{end}}
{{end}} {{end}}
{{ if $frontend.RateLimit }} {{if $frontend.RateLimit }}
[frontends."frontend-{{$frontendName}}".rateLimit] [frontends."frontend-{{ $frontendName }}".rateLimit]
extractorFunc = "{{ $frontend.RateLimit.ExtractorFunc }}" extractorFunc = "{{ $frontend.RateLimit.ExtractorFunc }}"
[frontends."frontend-{{$frontendName}}".rateLimit.rateSet] [frontends."frontend-{{ $frontendName }}".rateLimit.rateSet]
{{ range $limitName, $limit := $frontend.RateLimit.RateSet }} {{range $limitName, $limit := $frontend.RateLimit.RateSet }}
[frontends."frontend-{{$frontendName}}".rateLimit.rateSet.{{ $limitName }}] [frontends."frontend-{{ $frontendName }}".rateLimit.rateSet.{{ $limitName }}]
period = "{{ $limit.Period }}" period = "{{ $limit.Period }}"
average = {{ $limit.Average }} average = {{ $limit.Average }}
burst = {{ $limit.Burst }} burst = {{ $limit.Burst }}
@ -94,55 +92,55 @@
{{end}} {{end}}
{{if $frontend.Headers }} {{if $frontend.Headers }}
[frontends."{{$frontendName}}".headers] [frontends."{{ $frontendName }}".headers]
SSLRedirect = {{$frontend.Headers.SSLRedirect}} SSLRedirect = {{ $frontend.Headers.SSLRedirect }}
SSLTemporaryRedirect = {{$frontend.Headers.SSLTemporaryRedirect}} SSLTemporaryRedirect = {{ $frontend.Headers.SSLTemporaryRedirect }}
SSLHost = "{{$frontend.Headers.SSLHost}}" SSLHost = "{{ $frontend.Headers.SSLHost }}"
STSSeconds = {{$frontend.Headers.STSSeconds}} STSSeconds = {{ $frontend.Headers.STSSeconds }}
STSIncludeSubdomains = {{$frontend.Headers.STSIncludeSubdomains}} STSIncludeSubdomains = {{ $frontend.Headers.STSIncludeSubdomains }}
STSPreload = {{$frontend.Headers.STSPreload}} STSPreload = {{ $frontend.Headers.STSPreload }}
ForceSTSHeader = {{$frontend.Headers.ForceSTSHeader}} ForceSTSHeader = {{ $frontend.Headers.ForceSTSHeader }}
FrameDeny = {{$frontend.Headers.FrameDeny}} FrameDeny = {{ $frontend.Headers.FrameDeny }}
CustomFrameOptionsValue = "{{$frontend.Headers.CustomFrameOptionsValue}}" CustomFrameOptionsValue = "{{ $frontend.Headers.CustomFrameOptionsValue }}"
ContentTypeNosniff = {{$frontend.Headers.ContentTypeNosniff}} ContentTypeNosniff = {{ $frontend.Headers.ContentTypeNosniff }}
BrowserXSSFilter = {{$frontend.Headers.BrowserXSSFilter}} BrowserXSSFilter = {{ $frontend.Headers.BrowserXSSFilter }}
ContentSecurityPolicy = "{{$frontend.Headers.ContentSecurityPolicy}}" ContentSecurityPolicy = "{{ $frontend.Headers.ContentSecurityPolicy }}"
PublicKey = "{{$frontend.Headers.PublicKey}}" PublicKey = "{{ $frontend.Headers.PublicKey }}"
ReferrerPolicy = "{{$frontend.Headers.ReferrerPolicy}}" ReferrerPolicy = "{{ $frontend.Headers.ReferrerPolicy }}"
IsDevelopment = {{$frontend.Headers.IsDevelopment}} IsDevelopment = {{ $frontend.Headers.IsDevelopment }}
{{if $frontend.Headers.AllowedHosts}} {{if $frontend.Headers.AllowedHosts }}
AllowedHosts = [{{range $frontend.Headers.AllowedHosts}} AllowedHosts = [{{range $frontend.Headers.AllowedHosts }}
"{{.}}", "{{.}}",
{{end}}] {{end}}]
{{end}} {{end}}
{{if $frontend.Headers.HostsProxyHeaders}} {{if $frontend.Headers.HostsProxyHeaders }}
HostsProxyHeaders = [{{range $frontend.Headers.HostsProxyHeaders}} HostsProxyHeaders = [{{range $frontend.Headers.HostsProxyHeaders }}
"{{.}}", "{{.}}",
{{end}}] {{end}}]
{{end}} {{end}}
{{if $frontend.Headers.CustomRequestHeaders}} {{if $frontend.Headers.CustomRequestHeaders }}
[frontends."{{$frontendName}}".headers.customrequestheaders] [frontends."{{ $frontendName }}".headers.customRequestHeaders]
{{range $k, $v := $frontend.Headers.CustomRequestHeaders}} {{range $k, $v := $frontend.Headers.CustomRequestHeaders }}
{{$k}} = "{{$v}}" {{ $k }} = "{{ $v }}"
{{end}} {{end}}
{{end}} {{end}}
{{if $frontend.Headers.CustomResponseHeaders}} {{if $frontend.Headers.CustomResponseHeaders }}
[frontends."{{$frontendName}}".headers.customresponseheaders] [frontends."{{ $frontendName }}".headers.customResponseHeaders]
{{range $k, $v := $frontend.Headers.CustomResponseHeaders}} {{range $k, $v := $frontend.Headers.CustomResponseHeaders }}
{{$k}} = "{{$v}}" {{ $k }} = "{{ $v }}"
{{end}} {{end}}
{{end}} {{end}}
{{if $frontend.Headers.SSLProxyHeaders}} {{if $frontend.Headers.SSLProxyHeaders }}
[frontends."{{$frontendName}}".headers.SSLProxyHeaders] [frontends."{{ $frontendName }}".headers.SSLProxyHeaders]
{{range $k, $v := $frontend.Headers.SSLProxyHeaders}} {{range $k, $v := $frontend.Headers.SSLProxyHeaders }}
{{$k}} = "{{$v}}" {{ $k }} = "{{ $v }}"
{{end}} {{end}}
{{end}} {{end}}
{{end}} {{end}}
{{range $routeName, $route := $frontend.Routes}} {{range $routeName, $route := $frontend.Routes }}
[frontends."{{$frontendName}}".routes."{{$routeName}}"] [frontends."{{ $frontendName }}".routes."{{ $routeName }}"]
rule = "{{$route.Rule}}" rule = "{{ $route.Rule }}"
{{end}} {{end}}
{{end}} {{end}}