chore(docker): gen templates.

This commit is contained in:
Fernandez Ludovic 2017-12-20 00:52:56 +01:00 committed by Traefiker
parent dd7a8a9a87
commit 498b806ca9

View file

@ -124,14 +124,16 @@ func templatesConsul_catalogTmpl() (*asset, error) {
} }
var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}} var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
[backends]{{range $backendName, $backend := .Backends}} [backends]
{{range $backendName, $backend := .Backends}}
{{if hasCircuitBreakerLabel $backend}} {{if hasCircuitBreakerLabel $backend}}
[backends.backend-{{$backendName}}.circuitbreaker] [backends.backend-{{$backendName}}.circuitBreaker]
expression = "{{getCircuitBreakerExpression $backend}}" expression = "{{getCircuitBreakerExpression $backend}}"
{{end}} {{end}}
{{if hasLoadBalancerLabel $backend}} {{if hasLoadBalancerLabel $backend}}
[backends.backend-{{$backendName}}.loadbalancer] [backends.backend-{{$backendName}}.loadBalancer]
method = "{{getLoadBalancerMethod $backend}}" method = "{{getLoadBalancerMethod $backend}}"
sticky = {{getSticky $backend}} sticky = {{getSticky $backend}}
{{if hasStickinessLabel $backend}} {{if hasStickinessLabel $backend}}
@ -141,9 +143,16 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
{{end}} {{end}}
{{if hasMaxConnLabels $backend}} {{if hasMaxConnLabels $backend}}
[backends.backend-{{$backendName}}.maxconn] [backends.backend-{{$backendName}}.maxConn]
amount = {{getMaxConnAmount $backend}} amount = {{getMaxConnAmount $backend}}
extractorfunc = "{{getMaxConnExtractorFunc $backend}}" extractorFunc = "{{getMaxConnExtractorFunc $backend}}"
{{end}}
{{if hasHealthCheckLabels $backend}}
[backends.backend-{{$backendName}}.healthCheck]
path = "{{getHealthCheckPath $backend}}"
port = {{getHealthCheckPort $backend}}
interval = "{{getHealthCheckInterval $backend}}"
{{end}} {{end}}
{{$servers := index $backendServers $backendName}} {{$servers := index $backendServers $backendName}}
@ -164,23 +173,30 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
{{end}} {{end}}
[frontends]{{range $frontend, $containers := .Frontends}} [frontends]
{{range $frontend, $containers := .Frontends}}
{{$container := index $containers 0}} {{$container := index $containers 0}}
{{if hasServices $container}} {{if hasServices $container}}
{{$services := getServiceNames $container}} {{$services := getServiceNames $container}}
{{range $serviceIndex, $serviceName := $services}} {{range $serviceIndex, $serviceName := $services}}
[frontends."frontend-{{getServiceBackend $container $serviceName}}"] [frontends."frontend-{{getServiceBackend $container $serviceName}}"]
backend = "backend-{{getServiceBackend $container $serviceName}}" backend = "backend-{{getServiceBackend $container $serviceName}}"
passHostHeader = {{getServicePassHostHeader $container $serviceName}}
{{if getWhitelistSourceRange $container}}
whitelistSourceRange = [{{range getWhitelistSourceRange $container}}
"{{.}}",
{{end}}]
{{end}}
priority = {{getServicePriority $container $serviceName}} priority = {{getServicePriority $container $serviceName}}
passHostHeader = {{getServicePassHostHeader $container $serviceName}}
passTLSCert = {{getServicePassTLSCert $container $serviceName}}
entryPoints = [{{range getServiceEntryPoints $container $serviceName}} entryPoints = [{{range getServiceEntryPoints $container $serviceName}}
"{{.}}", "{{.}}",
{{end}}] {{end}}]
{{if getServiceWhitelistSourceRange $container $serviceName}}
whitelistSourceRange = [{{range getServiceWhitelistSourceRange $container $serviceName}}
"{{.}}",
{{end}}]
{{end}}
basicAuth = [{{range getServiceBasicAuth $container $serviceName}} basicAuth = [{{range getServiceBasicAuth $container $serviceName}}
"{{.}}", "{{.}}",
{{end}}] {{end}}]
@ -192,34 +208,67 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
replacement = "{{getServiceRedirectReplacement $container $serviceName}}" replacement = "{{getServiceRedirectReplacement $container $serviceName}}"
{{end}} {{end}}
{{ if hasServiceErrorPages $container $serviceName }}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".errors]
{{ range $pageName, $page := getServiceErrorPages $container $serviceName }}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".errors.{{$pageName}}]
status = [{{range $page.Status}}
"{{.}}",
{{end}}]
backend = "{{$page.Backend}}"
query = "{{$page.Query}}"
{{end}}
{{end}}
{{ if hasServiceRateLimits $container $serviceName }}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".rateLimit]
extractorFunc = "{{ getRateLimitsExtractorFunc $container $serviceName }}"
[frontends."frontend-{{getServiceBackend $container $serviceName}}".rateLimit.rateSet]
{{ range $limitName, $rateLimit := getServiceRateLimits $container $serviceName }}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".rateLimit.rateSet.{{ $limitName }}]
period = "{{ $rateLimit.Period }}"
average = {{ $rateLimit.Average }}
burst = {{ $rateLimit.Burst }}
{{end}}
{{end}}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".routes."service-{{$serviceName | replace "/" "" | replace "." "-"}}"] [frontends."frontend-{{getServiceBackend $container $serviceName}}".routes."service-{{$serviceName | replace "/" "" | replace "." "-"}}"]
rule = "{{getServiceFrontendRule $container $serviceName}}" rule = "{{getServiceFrontendRule $container $serviceName}}"
{{if hasServiceRequestHeaders $container $serviceName}} {{if hasServiceRequestHeaders $container $serviceName}}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customrequestheaders] [frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customRequestHeaders]
{{range $k, $v := getServiceRequestHeaders $container $serviceName}} {{range $k, $v := getServiceRequestHeaders $container $serviceName}}
{{$k}} = "{{$v}}" {{$k}} = "{{$v}}"
{{end}} {{end}}
{{end}} {{end}}
{{if hasServiceResponseHeaders $container $serviceName}} {{if hasServiceResponseHeaders $container $serviceName}}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customresponseheaders] [frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customResponseHeaders]
{{range $k, $v := getServiceResponseHeaders $container $serviceName}} {{range $k, $v := getServiceResponseHeaders $container $serviceName}}
{{$k}} = "{{$v}}" {{$k}} = "{{$v}}"
{{end}} {{end}}
{{end}} {{end}}
{{end}}
{{end}} ## end range services
{{else}} {{else}}
[frontends."frontend-{{$frontend}}"] [frontends."frontend-{{$frontend}}"]
backend = "backend-{{getBackend $container}}" backend = "backend-{{getBackend $container}}"
priority = {{getPriority $container}}
passHostHeader = {{getPassHostHeader $container}} passHostHeader = {{getPassHostHeader $container}}
passTLSCert = {{getPassTLSCert $container}}
entryPoints = [{{range getEntryPoints $container}}
"{{.}}",
{{end}}]
{{if getWhitelistSourceRange $container}} {{if getWhitelistSourceRange $container}}
whitelistSourceRange = [{{range getWhitelistSourceRange $container}} whitelistSourceRange = [{{range getWhitelistSourceRange $container}}
"{{.}}", "{{.}}",
{{end}}] {{end}}]
{{end}} {{end}}
priority = {{getPriority $container}}
entryPoints = [{{range getEntryPoints $container}}
"{{.}}",
{{end}}]
basicAuth = [{{range getBasicAuth $container}} basicAuth = [{{range getBasicAuth $container}}
"{{.}}", "{{.}}",
{{end}}] {{end}}]
@ -231,6 +280,30 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
replacement = "{{getRedirectReplacement $container}}" replacement = "{{getRedirectReplacement $container}}"
{{end}} {{end}}
{{ if hasErrorPages $container }}
[frontends."frontend-{{$frontend}}".errors]
{{ range $pageName, $page := getErrorPages $container }}
[frontends."frontend-{{$frontend}}".errors.{{ $pageName }}]
status = [{{range $page.Status}}
"{{.}}",
{{end}}]
backend = "{{$page.Backend}}"
query = "{{$page.Query}}"
{{end}}
{{end}}
{{ if hasRateLimits $container }}
[frontends."frontend-{{$frontend}}".rateLimit]
extractorFunc = "{{ getRateLimitsExtractorFunc $container }}"
[frontends."frontend-{{$frontend}}".rateLimit.rateSet]
{{ range $limitName, $rateLimit := getRateLimits $container }}
[frontends."frontend-{{$frontend}}".rateLimit.rateSet.{{ $limitName }}]
period = "{{ $rateLimit.Period }}"
average = {{ $rateLimit.Average }}
burst = {{ $rateLimit.Burst }}
{{end}}
{{end}}
[frontends."frontend-{{$frontend}}".headers] [frontends."frontend-{{$frontend}}".headers]
{{if hasSSLRedirectHeaders $container}} {{if hasSSLRedirectHeaders $container}}
SSLRedirect = {{getSSLRedirectHeaders $container}} SSLRedirect = {{getSSLRedirectHeaders $container}}
@ -278,13 +351,13 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
IsDevelopment = {{getIsDevelopmentHeaders $container}} IsDevelopment = {{getIsDevelopmentHeaders $container}}
{{end}} {{end}}
{{if hasRequestHeaders $container}} {{if hasRequestHeaders $container}}
[frontends."frontend-{{$frontend}}".headers.customrequestheaders] [frontends."frontend-{{$frontend}}".headers.customRequestHeaders]
{{range $k, $v := getRequestHeaders $container}} {{range $k, $v := getRequestHeaders $container}}
{{$k}} = "{{$v}}" {{$k}} = "{{$v}}"
{{end}} {{end}}
{{end}} {{end}}
{{if hasResponseHeaders $container}} {{if hasResponseHeaders $container}}
[frontends."frontend-{{$frontend}}".headers.customresponseheaders] [frontends."frontend-{{$frontend}}".headers.customResponseHeaders]
{{range $k, $v := getResponseHeaders $container}} {{range $k, $v := getResponseHeaders $container}}
{{$k}} = "{{$v}}" {{$k}} = "{{$v}}"
{{end}} {{end}}
@ -307,9 +380,12 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
{{$k}} = "{{$v}}" {{$k}} = "{{$v}}"
{{end}} {{end}}
{{end}} {{end}}
[frontends."frontend-{{$frontend}}".routes."route-frontend-{{$frontend}}"] [frontends."frontend-{{$frontend}}".routes."route-frontend-{{$frontend}}"]
rule = "{{getFrontendRule $container}}" rule = "{{getFrontendRule $container}}"
{{end}} {{end}}
{{end}} {{end}}
`) `)