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}}
[backends]{{range $backendName, $backend := .Backends}}
[backends]
{{range $backendName, $backend := .Backends}}
{{if hasCircuitBreakerLabel $backend}}
[backends.backend-{{$backendName}}.circuitbreaker]
[backends.backend-{{$backendName}}.circuitBreaker]
expression = "{{getCircuitBreakerExpression $backend}}"
{{end}}
{{if hasLoadBalancerLabel $backend}}
[backends.backend-{{$backendName}}.loadbalancer]
[backends.backend-{{$backendName}}.loadBalancer]
method = "{{getLoadBalancerMethod $backend}}"
sticky = {{getSticky $backend}}
{{if hasStickinessLabel $backend}}
@ -141,9 +143,16 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
{{end}}
{{if hasMaxConnLabels $backend}}
[backends.backend-{{$backendName}}.maxconn]
[backends.backend-{{$backendName}}.maxConn]
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}}
{{$servers := index $backendServers $backendName}}
@ -164,23 +173,30 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
{{end}}
[frontends]{{range $frontend, $containers := .Frontends}}
[frontends]
{{range $frontend, $containers := .Frontends}}
{{$container := index $containers 0}}
{{if hasServices $container}}
{{$services := getServiceNames $container}}
{{range $serviceIndex, $serviceName := $services}}
[frontends."frontend-{{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}}
passHostHeader = {{getServicePassHostHeader $container $serviceName}}
passTLSCert = {{getServicePassTLSCert $container $serviceName}}
entryPoints = [{{range getServiceEntryPoints $container $serviceName}}
"{{.}}",
{{end}}]
{{if getServiceWhitelistSourceRange $container $serviceName}}
whitelistSourceRange = [{{range getServiceWhitelistSourceRange $container $serviceName}}
"{{.}}",
{{end}}]
{{end}}
basicAuth = [{{range getServiceBasicAuth $container $serviceName}}
"{{.}}",
{{end}}]
@ -192,34 +208,67 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
replacement = "{{getServiceRedirectReplacement $container $serviceName}}"
{{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 "." "-"}}"]
rule = "{{getServiceFrontendRule $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}}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
{{if hasServiceResponseHeaders $container $serviceName}}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customresponseheaders]
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customResponseHeaders]
{{range $k, $v := getServiceResponseHeaders $container $serviceName}}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
{{end}}
{{end}} ## end range services
{{else}}
[frontends."frontend-{{$frontend}}"]
backend = "backend-{{getBackend $container}}"
priority = {{getPriority $container}}
passHostHeader = {{getPassHostHeader $container}}
passTLSCert = {{getPassTLSCert $container}}
entryPoints = [{{range getEntryPoints $container}}
"{{.}}",
{{end}}]
{{if getWhitelistSourceRange $container}}
whitelistSourceRange = [{{range getWhitelistSourceRange $container}}
"{{.}}",
{{end}}]
{{end}}
priority = {{getPriority $container}}
entryPoints = [{{range getEntryPoints $container}}
"{{.}}",
{{end}}]
basicAuth = [{{range getBasicAuth $container}}
"{{.}}",
{{end}}]
@ -231,6 +280,30 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
replacement = "{{getRedirectReplacement $container}}"
{{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]
{{if hasSSLRedirectHeaders $container}}
SSLRedirect = {{getSSLRedirectHeaders $container}}
@ -278,13 +351,13 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
IsDevelopment = {{getIsDevelopmentHeaders $container}}
{{end}}
{{if hasRequestHeaders $container}}
[frontends."frontend-{{$frontend}}".headers.customrequestheaders]
[frontends."frontend-{{$frontend}}".headers.customRequestHeaders]
{{range $k, $v := getRequestHeaders $container}}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
{{if hasResponseHeaders $container}}
[frontends."frontend-{{$frontend}}".headers.customresponseheaders]
[frontends."frontend-{{$frontend}}".headers.customResponseHeaders]
{{range $k, $v := getResponseHeaders $container}}
{{$k}} = "{{$v}}"
{{end}}
@ -307,9 +380,12 @@ var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
[frontends."frontend-{{$frontend}}".routes."route-frontend-{{$frontend}}"]
rule = "{{getFrontendRule $container}}"
{{end}}
{{end}}
`)