chore(consulcatalog): gen templates.
This commit is contained in:
parent
bd5cab6e87
commit
1fe6a8b04d
1 changed files with 150 additions and 42 deletions
|
@ -55,56 +55,164 @@ func (fi bindataFileInfo) Sys() interface{} {
|
||||||
}
|
}
|
||||||
|
|
||||||
var _templatesConsul_catalogTmpl = []byte(`[backends]
|
var _templatesConsul_catalogTmpl = []byte(`[backends]
|
||||||
{{range $index, $node := .Nodes}}
|
{{range $service := .Services}}
|
||||||
[backends."backend-{{getBackend $node}}".servers."{{getBackendName $node $index}}"]
|
|
||||||
url = "{{getAttribute "protocol" $node.Service.Tags "http"}}://{{getBackendAddress $node}}:{{$node.Service.Port}}"
|
{{ $circuitBreaker := getCircuitBreaker $service.Attributes }}
|
||||||
{{$weight := getAttribute "backend.weight" $node.Service.Tags "0"}}
|
{{if $circuitBreaker }}
|
||||||
{{with $weight}}
|
[backends."backend-{{ getServiceBackendName $service }}".circuitBreaker]
|
||||||
weight = {{$weight}}
|
expression = "{{ $circuitBreaker.Expression }}"
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
{{ $loadBalancer := getLoadBalancer $service.Attributes }}
|
||||||
|
{{if $loadBalancer }}
|
||||||
|
[backends."backend-{{ getServiceBackendName $service }}".loadBalancer]
|
||||||
|
method = "{{ $loadBalancer.Method }}"
|
||||||
|
sticky = {{ $loadBalancer.Sticky }}
|
||||||
|
{{if $loadBalancer.Stickiness }}
|
||||||
|
[backends."backend-{{ getServiceBackendName $service }}".loadBalancer.stickiness]
|
||||||
|
cookieName = "{{ $loadBalancer.Stickiness.CookieName }}"
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{ $maxConn := getMaxConn $service.Attributes }}
|
||||||
|
{{if $maxConn }}
|
||||||
|
[backends."backend-{{ getServiceBackendName $service }}".maxConn]
|
||||||
|
extractorFunc = "{{ $maxConn.ExtractorFunc }}"
|
||||||
|
amount = {{ $maxConn.Amount }}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{ $healthCheck := getHealthCheck $service.Attributes }}
|
||||||
|
{{if $healthCheck }}
|
||||||
|
[backends.backend-{{ getServiceBackendName $service }}.healthCheck]
|
||||||
|
path = "{{ $healthCheck.Path }}"
|
||||||
|
port = {{ $healthCheck.Port }}
|
||||||
|
interval = "{{ $healthCheck.Interval }}"
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{range $index, $node := .Nodes}}
|
||||||
|
|
||||||
{{range .Services}}
|
[backends."backend-{{ getNodeBackendName $node }}".servers."{{ getServerName $node $index }}"]
|
||||||
{{$service := .ServiceName}}
|
url = "{{ getProtocol $node.Service.Tags }}://{{ getBackendAddress $node }}:{{ $node.Service.Port }}"
|
||||||
{{$circuitBreaker := getAttribute "backend.circuitbreaker" .Attributes ""}}
|
weight = {{ getWeight $node.Service.Tags }}
|
||||||
{{with $circuitBreaker}}
|
|
||||||
[backends."backend-{{$service}}".circuitbreaker]
|
|
||||||
expression = "{{$circuitBreaker}}"
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
[backends."backend-{{$service}}".loadbalancer]
|
|
||||||
method = "{{getAttribute "backend.loadbalancer" .Attributes "wrr"}}"
|
|
||||||
sticky = {{getSticky .Attributes}}
|
|
||||||
{{if hasStickinessLabel .Attributes}}
|
|
||||||
[backends."backend-{{$service}}".loadbalancer.stickiness]
|
|
||||||
cookieName = "{{getStickinessCookieName .Attributes}}"
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{if hasMaxconnAttributes .Attributes}}
|
|
||||||
[backends."backend-{{$service}}".maxconn]
|
|
||||||
amount = {{getAttribute "backend.maxconn.amount" .Attributes "" }}
|
|
||||||
extractorfunc = "{{getAttribute "backend.maxconn.extractorfunc" .Attributes "" }}"
|
|
||||||
{{end}}
|
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
[frontends]
|
[frontends]
|
||||||
{{range .Services}}
|
{{range $service := .Services}}
|
||||||
[frontends."frontend-{{.ServiceName}}"]
|
|
||||||
backend = "backend-{{.ServiceName}}"
|
[frontends."frontend-{{ $service.ServiceName }}"]
|
||||||
passHostHeader = {{getAttribute "frontend.passHostHeader" .Attributes "true"}}
|
backend = "backend-{{ getServiceBackendName $service }}"
|
||||||
priority = {{getAttribute "frontend.priority" .Attributes "0"}}
|
priority = {{ getPriority $service.Attributes }}
|
||||||
{{$entryPoints := getAttribute "frontend.entrypoints" .Attributes ""}}
|
passHostHeader = {{ getPassHostHeader $service.Attributes }}
|
||||||
{{with $entryPoints}}
|
passTLSCert = {{ getPassTLSCert $service.Attributes }}
|
||||||
entrypoints = [{{range getEntryPoints $entryPoints}}
|
|
||||||
|
entryPoints = [{{range getFrontEndEntryPoints $service.Attributes }}
|
||||||
|
"{{.}}",
|
||||||
|
{{end}}]
|
||||||
|
|
||||||
|
{{ $whitelistSourceRange := getWhitelistSourceRange $service.Attributes }}
|
||||||
|
{{if $whitelistSourceRange }}
|
||||||
|
whitelistSourceRange = [{{range $whitelistSourceRange}}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
{{end}}
|
{{end}}
|
||||||
basicAuth = [{{range getBasicAuth .Attributes}}
|
|
||||||
|
basicAuth = [{{range getBasicAuth $service.Attributes }}
|
||||||
"{{.}}",
|
"{{.}}",
|
||||||
{{end}}]
|
{{end}}]
|
||||||
[frontends."frontend-{{.ServiceName}}".routes."route-host-{{.ServiceName}}"]
|
|
||||||
rule = "{{getFrontendRule .}}"
|
{{ $redirect := getRedirect $service.Attributes }}
|
||||||
|
{{if $redirect }}
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".redirect]
|
||||||
|
entryPoint = "{{ $redirect.EntryPoint }}"
|
||||||
|
regex = "{{ $redirect.Regex }}"
|
||||||
|
replacement = "{{ $redirect.Replacement }}"
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{ if hasErrorPages $service.Attributes }}
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".errors]
|
||||||
|
{{ range $pageName, $page := getErrorPages $service.Attributes }}
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".errors.{{ $pageName }}]
|
||||||
|
status = [{{range $page.Status }}
|
||||||
|
"{{.}}",
|
||||||
|
{{end}}]
|
||||||
|
backend = "{{ $page.Backend }}"
|
||||||
|
query = "{{ $page.Query }}"
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{ if hasRateLimit $service.Attributes }}
|
||||||
|
{{ $rateLimit := getRateLimit $service.Attributes }}
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".rateLimit]
|
||||||
|
extractorFunc = "{{ $rateLimit.ExtractorFunc }}"
|
||||||
|
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".rateLimit.rateSet]
|
||||||
|
{{ range $limitName, $limit := $rateLimit.RateSet }}
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".rateLimit.rateSet.{{ $limitName }}]
|
||||||
|
period = "{{ $limit.Period }}"
|
||||||
|
average = {{ $limit.Average }}
|
||||||
|
burst = {{ $limit.Burst }}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{ $headers := getHeaders $service.Attributes }}
|
||||||
|
{{ if $headers }}
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".headers]
|
||||||
|
SSLRedirect = {{ $headers.SSLRedirect }}
|
||||||
|
SSLTemporaryRedirect = {{ $headers.SSLTemporaryRedirect }}
|
||||||
|
SSLHost = "{{ $headers.SSLHost }}"
|
||||||
|
STSSeconds = {{ $headers.STSSeconds }}
|
||||||
|
STSIncludeSubdomains = {{ $headers.STSIncludeSubdomains }}
|
||||||
|
STSPreload = {{ $headers.STSPreload }}
|
||||||
|
ForceSTSHeader = {{ $headers.ForceSTSHeader }}
|
||||||
|
FrameDeny = {{ $headers.FrameDeny }}
|
||||||
|
CustomFrameOptionsValue = "{{ $headers.CustomFrameOptionsValue }}"
|
||||||
|
ContentTypeNosniff = {{ $headers.ContentTypeNosniff }}
|
||||||
|
BrowserXSSFilter = {{ $headers.BrowserXSSFilter }}
|
||||||
|
ContentSecurityPolicy = "{{ $headers.ContentSecurityPolicy }}"
|
||||||
|
PublicKey = "{{ $headers.PublicKey }}"
|
||||||
|
ReferrerPolicy = "{{ $headers.ReferrerPolicy }}"
|
||||||
|
IsDevelopment = {{ $headers.IsDevelopment }}
|
||||||
|
|
||||||
|
{{ if $headers.AllowedHosts }}
|
||||||
|
AllowedHosts = [{{ range $headers.AllowedHosts }}
|
||||||
|
"{{.}}",
|
||||||
|
{{end}}]
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{ if $headers.HostsProxyHeaders }}
|
||||||
|
HostsProxyHeaders = [{{ range $headers.HostsProxyHeaders }}
|
||||||
|
"{{.}}",
|
||||||
|
{{end}}]
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{ if $headers.CustomRequestHeaders }}
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".headers.customRequestHeaders]
|
||||||
|
{{ range $k, $v := $headers.CustomRequestHeaders }}
|
||||||
|
{{$k}} = "{{$v}}"
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{ if $headers.CustomResponseHeaders }}
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".headers.customResponseHeaders]
|
||||||
|
{{ range $k, $v := $headers.CustomResponseHeaders }}
|
||||||
|
{{$k}} = "{{$v}}"
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
{{ if $headers.SSLProxyHeaders }}
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".headers.SSLProxyHeaders]
|
||||||
|
{{range $k, $v := $headers.SSLProxyHeaders}}
|
||||||
|
{{$k}} = "{{$v}}"
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
|
[frontends."frontend-{{ $service.ServiceName }}".routes."route-host-{{ $service.ServiceName }}"]
|
||||||
|
rule = "{{ getFrontendRule $service }}"
|
||||||
|
|
||||||
{{end}}
|
{{end}}
|
||||||
`)
|
`)
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue