refactor(k8s): template readability.
This commit is contained in:
parent
a81171d5f1
commit
7c0e557f84
1 changed files with 83 additions and 71 deletions
|
@ -1,16 +1,20 @@
|
|||
[backends]{{range $backendName, $backend := .Backends}}
|
||||
[backends."{{$backendName}}"]
|
||||
[backends]
|
||||
{{range $backendName, $backend := .Backends}}
|
||||
|
||||
[backends."{{$backendName}}"]
|
||||
|
||||
{{if $backend.CircuitBreaker}}
|
||||
[backends."{{$backendName}}".circuitbreaker]
|
||||
[backends."{{$backendName}}".circuitBreaker]
|
||||
expression = "{{$backend.CircuitBreaker.Expression}}"
|
||||
{{end}}
|
||||
[backends."{{$backendName}}".loadbalancer]
|
||||
|
||||
[backends."{{$backendName}}".loadBalancer]
|
||||
method = "{{$backend.LoadBalancer.Method}}"
|
||||
{{if $backend.LoadBalancer.Sticky}}
|
||||
sticky = true
|
||||
{{end}}
|
||||
{{if $backend.LoadBalancer.Stickiness}}
|
||||
[backends."{{$backendName}}".loadbalancer.stickiness]
|
||||
[backends."{{$backendName}}".loadBalancer.stickiness]
|
||||
cookieName = "{{$backend.LoadBalancer.Stickiness.CookieName}}"
|
||||
{{end}}
|
||||
|
||||
|
@ -25,91 +29,99 @@
|
|||
|
||||
{{range $serverName, $server := $backend.Servers}}
|
||||
[backends."{{$backendName}}".servers."{{$serverName}}"]
|
||||
url = "{{$server.URL}}"
|
||||
weight = {{$server.Weight}}
|
||||
url = "{{$server.URL}}"
|
||||
weight = {{$server.Weight}}
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
[frontends]{{range $frontendName, $frontend := .Frontends}}
|
||||
[frontends."{{$frontendName}}"]
|
||||
backend = "{{$frontend.Backend}}"
|
||||
priority = {{$frontend.Priority}}
|
||||
passHostHeader = {{$frontend.PassHostHeader}}
|
||||
entryPoints = [{{range $frontend.EntryPoints}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
basicAuth = [{{range $frontend.BasicAuth}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
whitelistSourceRange = [{{range $frontend.WhitelistSourceRange}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
[frontends]
|
||||
{{range $frontendName, $frontend := .Frontends}}
|
||||
|
||||
{{if $frontend.Redirect}}
|
||||
[frontends."{{$frontendName}}".redirect]
|
||||
entryPoint = "{{$frontend.Redirect.EntryPoint}}"
|
||||
regex = "{{$frontend.Redirect.Regex}}"
|
||||
replacement = "{{$frontend.Redirect.Replacement}}"
|
||||
{{end}}
|
||||
[frontends."{{$frontendName}}"]
|
||||
backend = "{{$frontend.Backend}}"
|
||||
priority = {{$frontend.Priority}}
|
||||
passHostHeader = {{$frontend.PassHostHeader}}
|
||||
|
||||
entryPoints = [{{range $frontend.EntryPoints}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
basicAuth = [{{range $frontend.BasicAuth}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
whitelistSourceRange = [{{range $frontend.WhitelistSourceRange}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
{{if $frontend.Redirect}}
|
||||
[frontends."{{$frontendName}}".redirect]
|
||||
entryPoint = "{{$frontend.RedirectEntryPoint}}"
|
||||
regex = "{{$frontend.RedirectRegex}}"
|
||||
replacement = "{{$frontend.RedirectReplacement}}"
|
||||
{{end}}
|
||||
|
||||
{{if $frontend.Headers }}
|
||||
[frontends."{{$frontendName}}".headers]
|
||||
SSLRedirect = {{$frontend.Headers.SSLRedirect}}
|
||||
SSLTemporaryRedirect = {{$frontend.Headers.SSLTemporaryRedirect}}
|
||||
SSLHost = "{{$frontend.Headers.SSLHost}}"
|
||||
STSSeconds = {{$frontend.Headers.STSSeconds}}
|
||||
STSIncludeSubdomains = {{$frontend.Headers.STSIncludeSubdomains}}
|
||||
STSPreload = {{$frontend.Headers.STSPreload}}
|
||||
ForceSTSHeader = {{$frontend.Headers.ForceSTSHeader}}
|
||||
FrameDeny = {{$frontend.Headers.FrameDeny}}
|
||||
CustomFrameOptionsValue = "{{$frontend.Headers.CustomFrameOptionsValue}}"
|
||||
ContentTypeNosniff = {{$frontend.Headers.ContentTypeNosniff}}
|
||||
BrowserXSSFilter = {{$frontend.Headers.BrowserXSSFilter}}
|
||||
ContentSecurityPolicy = "{{$frontend.Headers.ContentSecurityPolicy}}"
|
||||
PublicKey = "{{$frontend.Headers.PublicKey}}"
|
||||
ReferrerPolicy = "{{$frontend.Headers.ReferrerPolicy}}"
|
||||
IsDevelopment = {{$frontend.Headers.IsDevelopment}}
|
||||
{{if $frontend.Headers.AllowedHosts}}
|
||||
AllowedHosts = [{{range $frontend.Headers.AllowedHosts}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
{{end}}
|
||||
{{if $frontend.Headers.HostsProxyHeaders}}
|
||||
HostsProxyHeaders = [{{range $frontend.Headers.HostsProxyHeaders}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
{{end}}
|
||||
{{if $frontend.Headers.CustomRequestHeaders}}
|
||||
SSLRedirect = {{$frontend.Headers.SSLRedirect}}
|
||||
SSLTemporaryRedirect = {{$frontend.Headers.SSLTemporaryRedirect}}
|
||||
SSLHost = "{{$frontend.Headers.SSLHost}}"
|
||||
STSSeconds = {{$frontend.Headers.STSSeconds}}
|
||||
STSIncludeSubdomains = {{$frontend.Headers.STSIncludeSubdomains}}
|
||||
STSPreload = {{$frontend.Headers.STSPreload}}
|
||||
ForceSTSHeader = {{$frontend.Headers.ForceSTSHeader}}
|
||||
FrameDeny = {{$frontend.Headers.FrameDeny}}
|
||||
CustomFrameOptionsValue = "{{$frontend.Headers.CustomFrameOptionsValue}}"
|
||||
ContentTypeNosniff = {{$frontend.Headers.ContentTypeNosniff}}
|
||||
BrowserXSSFilter = {{$frontend.Headers.BrowserXSSFilter}}
|
||||
ContentSecurityPolicy = "{{$frontend.Headers.ContentSecurityPolicy}}"
|
||||
PublicKey = "{{$frontend.Headers.PublicKey}}"
|
||||
ReferrerPolicy = "{{$frontend.Headers.ReferrerPolicy}}"
|
||||
IsDevelopment = {{$frontend.Headers.IsDevelopment}}
|
||||
{{if $frontend.Headers.AllowedHosts}}
|
||||
AllowedHosts = [{{range $frontend.Headers.AllowedHosts}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
{{end}}
|
||||
{{if $frontend.Headers.HostsProxyHeaders}}
|
||||
HostsProxyHeaders = [{{range $frontend.Headers.HostsProxyHeaders}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
{{end}}
|
||||
{{if $frontend.Headers.CustomRequestHeaders}}
|
||||
[frontends."{{$frontendName}}".headers.customrequestheaders]
|
||||
{{range $k, $v := $frontend.Headers.CustomRequestHeaders}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{range $k, $v := $frontend.Headers.CustomRequestHeaders}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if $frontend.Headers.CustomResponseHeaders}}
|
||||
{{if $frontend.Headers.CustomResponseHeaders}}
|
||||
[frontends."{{$frontendName}}".headers.customresponseheaders]
|
||||
{{range $k, $v := $frontend.Headers.CustomResponseHeaders}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{range $k, $v := $frontend.Headers.CustomResponseHeaders}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if $frontend.Headers.SSLProxyHeaders}}
|
||||
{{if $frontend.Headers.SSLProxyHeaders}}
|
||||
[frontends."{{$frontendName}}".headers.SSLProxyHeaders]
|
||||
{{range $k, $v := $frontend.Headers.SSLProxyHeaders}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{range $k, $v := $frontend.Headers.SSLProxyHeaders}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{range $routeName, $route := $frontend.Routes}}
|
||||
[frontends."{{$frontendName}}".routes."{{$routeName}}"]
|
||||
rule = "{{$route.Rule}}"
|
||||
rule = "{{$route.Rule}}"
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
|
||||
{{range $tls := .TLS}}
|
||||
{{range $tls := .TLS }}
|
||||
[[tls]]
|
||||
entryPoints = [{{range $tls.EntryPoints}}
|
||||
entryPoints = [{{range $tls.EntryPoints }}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
{{end}}]
|
||||
[tls.certificate]
|
||||
certFile = """{{$tls.Certificate.CertFile}}"""
|
||||
keyFile = """{{$tls.Certificate.KeyFile}}"""
|
||||
certFile = """{{ $tls.Certificate.CertFile }}"""
|
||||
keyFile = """{{ $tls.Certificate.KeyFile }}"""
|
||||
{{end}}
|
||||
|
|
Loading…
Reference in a new issue