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,192 +124,268 @@ func templatesConsul_catalogTmpl() (*asset, error) {
} }
var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}} var _templatesDockerTmpl = []byte(`{{$backendServers := .Servers}}
[backends]{{range $backendName, $backend := .Backends}} [backends]
{{if hasCircuitBreakerLabel $backend}} {{range $backendName, $backend := .Backends}}
[backends.backend-{{$backendName}}.circuitbreaker]
expression = "{{getCircuitBreakerExpression $backend}}"
{{end}}
{{if hasLoadBalancerLabel $backend}} {{if hasCircuitBreakerLabel $backend}}
[backends.backend-{{$backendName}}.loadbalancer] [backends.backend-{{$backendName}}.circuitBreaker]
method = "{{getLoadBalancerMethod $backend}}" expression = "{{getCircuitBreakerExpression $backend}}"
sticky = {{getSticky $backend}} {{end}}
{{if hasStickinessLabel $backend}}
[backends.backend-{{$backendName}}.loadBalancer.stickiness]
cookieName = "{{getStickinessCookieName $backend}}"
{{end}}
{{end}}
{{if hasMaxConnLabels $backend}} {{if hasLoadBalancerLabel $backend}}
[backends.backend-{{$backendName}}.maxconn] [backends.backend-{{$backendName}}.loadBalancer]
amount = {{getMaxConnAmount $backend}} method = "{{getLoadBalancerMethod $backend}}"
extractorfunc = "{{getMaxConnExtractorFunc $backend}}" sticky = {{getSticky $backend}}
{{if hasStickinessLabel $backend}}
[backends.backend-{{$backendName}}.loadBalancer.stickiness]
cookieName = "{{getStickinessCookieName $backend}}"
{{end}} {{end}}
{{end}}
{{$servers := index $backendServers $backendName}} {{if hasMaxConnLabels $backend}}
{{range $serverName, $server := $servers}} [backends.backend-{{$backendName}}.maxConn]
amount = {{getMaxConnAmount $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}}
{{range $serverName, $server := $servers}}
{{if hasServices $server}} {{if hasServices $server}}
{{$services := getServiceNames $server}} {{$services := getServiceNames $server}}
{{range $serviceIndex, $serviceName := $services}} {{range $serviceIndex, $serviceName := $services}}
[backends.backend-{{getServiceBackend $server $serviceName}}.servers.service-{{$serverName}}] [backends.backend-{{getServiceBackend $server $serviceName}}.servers.service-{{$serverName}}]
url = "{{getServiceProtocol $server $serviceName}}://{{getIPAddress $server}}:{{getServicePort $server $serviceName}}" url = "{{getServiceProtocol $server $serviceName}}://{{getIPAddress $server}}:{{getServicePort $server $serviceName}}"
weight = {{getServiceWeight $server $serviceName}} weight = {{getServiceWeight $server $serviceName}}
{{end}} {{end}}
{{else}} {{else}}
[backends.backend-{{$backendName}}.servers.server-{{$server.Name | replace "/" "" | replace "." "-"}}] [backends.backend-{{$backendName}}.servers.server-{{$server.Name | replace "/" "" | replace "." "-"}}]
url = "{{getProtocol $server}}://{{getIPAddress $server}}:{{getPort $server}}" url = "{{getProtocol $server}}://{{getIPAddress $server}}:{{getPort $server}}"
weight = {{getWeight $server}} weight = {{getWeight $server}}
{{end}}
{{end}} {{end}}
{{end}}
{{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}} priority = {{getServicePriority $container $serviceName}}
{{if getWhitelistSourceRange $container}} passHostHeader = {{getServicePassHostHeader $container $serviceName}}
whitelistSourceRange = [{{range getWhitelistSourceRange $container}} passTLSCert = {{getServicePassTLSCert $container $serviceName}}
"{{.}}",
{{end}}]
{{end}}
priority = {{getServicePriority $container $serviceName}}
entryPoints = [{{range getServiceEntryPoints $container $serviceName}}
"{{.}}",
{{end}}]
basicAuth = [{{range getServiceBasicAuth $container $serviceName}}
"{{.}}",
{{end}}]
{{if hasServiceRedirect $container $serviceName}} entryPoints = [{{range getServiceEntryPoints $container $serviceName}}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".redirect] "{{.}}",
entryPoint = "{{getServiceRedirectEntryPoint $container $serviceName}}" {{end}}]
regex = "{{getServiceRedirectRegex $container $serviceName}}"
replacement = "{{getServiceRedirectReplacement $container $serviceName}}" {{if getServiceWhitelistSourceRange $container $serviceName}}
{{end}} whitelistSourceRange = [{{range getServiceWhitelistSourceRange $container $serviceName}}
"{{.}}",
{{end}}]
{{end}}
basicAuth = [{{range getServiceBasicAuth $container $serviceName}}
"{{.}}",
{{end}}]
{{if hasServiceRedirect $container $serviceName}}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".redirect]
entryPoint = "{{getServiceRedirectEntryPoint $container $serviceName}}"
regex = "{{getServiceRedirectRegex $container $serviceName}}"
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 "." "-"}}"] [frontends."frontend-{{getServiceBackend $container $serviceName}}".routes."service-{{$serviceName | replace "/" "" | replace "." "-"}}"]
rule = "{{getServiceFrontendRule $container $serviceName}}" rule = "{{getServiceFrontendRule $container $serviceName}}"
{{if hasServiceRequestHeaders $container $serviceName}}
[frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customrequestheaders] {{if hasServiceRequestHeaders $container $serviceName}}
{{range $k, $v := getServiceRequestHeaders $container $serviceName}} [frontends."frontend-{{getServiceBackend $container $serviceName}}".headers.customRequestHeaders]
{{$k}} = "{{$v}}" {{range $k, $v := getServiceRequestHeaders $container $serviceName}}
{{$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}}"
passHostHeader = {{getPassHostHeader $container}} priority = {{getPriority $container}}
{{if getWhitelistSourceRange $container}} passHostHeader = {{getPassHostHeader $container}}
passTLSCert = {{getPassTLSCert $container}}
entryPoints = [{{range getEntryPoints $container}}
"{{.}}",
{{end}}]
{{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}}
"{{.}}",
{{end}}]
{{if hasRedirect $container}} basicAuth = [{{range getBasicAuth $container}}
[frontends."frontend-{{$frontend}}".redirect] "{{.}}",
entryPoint = "{{getRedirectEntryPoint $container}}" {{end}}]
regex = "{{getRedirectRegex $container}}"
replacement = "{{getRedirectReplacement $container}}"
{{end}}
[frontends."frontend-{{$frontend}}".headers] {{if hasRedirect $container}}
{{if hasSSLRedirectHeaders $container}} [frontends."frontend-{{$frontend}}".redirect]
SSLRedirect = {{getSSLRedirectHeaders $container}} entryPoint = "{{getRedirectEntryPoint $container}}"
{{end}} regex = "{{getRedirectRegex $container}}"
{{if hasSSLTemporaryRedirectHeaders $container}} replacement = "{{getRedirectReplacement $container}}"
SSLTemporaryRedirect = {{getSSLTemporaryRedirectHeaders $container}}
{{end}}
{{if hasSSLHostHeaders $container}}
SSLHost = "{{getSSLHostHeaders $container}}"
{{end}}
{{if hasSTSSecondsHeaders $container}}
STSSeconds = {{getSTSSecondsHeaders $container}}
{{end}}
{{if hasSTSIncludeSubdomainsHeaders $container}}
STSIncludeSubdomains = {{getSTSIncludeSubdomainsHeaders $container}}
{{end}}
{{if hasSTSPreloadHeaders $container}}
STSPreload = {{getSTSPreloadHeaders $container}}
{{end}}
{{if hasForceSTSHeaderHeaders $container}}
ForceSTSHeader = {{getForceSTSHeaderHeaders $container}}
{{end}}
{{if hasFrameDenyHeaders $container}}
FrameDeny = {{getFrameDenyHeaders $container}}
{{end}}
{{if hasCustomFrameOptionsValueHeaders $container}}
CustomFrameOptionsValue = "{{getCustomFrameOptionsValueHeaders $container}}"
{{end}}
{{if hasContentTypeNosniffHeaders $container}}
ContentTypeNosniff = {{getContentTypeNosniffHeaders $container}}
{{end}}
{{if hasBrowserXSSFilterHeaders $container}}
BrowserXSSFilter = {{getBrowserXSSFilterHeaders $container}}
{{end}}
{{if hasContentSecurityPolicyHeaders $container}}
ContentSecurityPolicy = "{{getContentSecurityPolicyHeaders $container}}"
{{end}}
{{if hasPublicKeyHeaders $container}}
PublicKey = "{{getPublicKeyHeaders $container}}"
{{end}}
{{if hasReferrerPolicyHeaders $container}}
ReferrerPolicy = "{{getReferrerPolicyHeaders $container}}"
{{end}}
{{if hasIsDevelopmentHeaders $container}}
IsDevelopment = {{getIsDevelopmentHeaders $container}}
{{end}}
{{if hasRequestHeaders $container}}
[frontends."frontend-{{$frontend}}".headers.customrequestheaders]
{{range $k, $v := getRequestHeaders $container}}
{{$k}} = "{{$v}}"
{{end}} {{end}}
{{end}}
{{if hasResponseHeaders $container}} {{ if hasErrorPages $container }}
[frontends."frontend-{{$frontend}}".headers.customresponseheaders] [frontends."frontend-{{$frontend}}".errors]
{{range $k, $v := getResponseHeaders $container}} {{ range $pageName, $page := getErrorPages $container }}
{{$k}} = "{{$v}}" [frontends."frontend-{{$frontend}}".errors.{{ $pageName }}]
status = [{{range $page.Status}}
"{{.}}",
{{end}}]
backend = "{{$page.Backend}}"
query = "{{$page.Query}}"
{{end}}
{{end}} {{end}}
{{end}}
{{if hasAllowedHostsHeaders $container}} {{ if hasRateLimits $container }}
[frontends."frontend-{{$frontend}}".headers.AllowedHosts] [frontends."frontend-{{$frontend}}".rateLimit]
{{range getAllowedHostsHeaders $container}} 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}} {{end}}
{{end}}
{{if hasHostsProxyHeaders $container}} [frontends."frontend-{{$frontend}}".headers]
[frontends."frontend-{{$frontend}}".headers.HostsProxyHeaders] {{if hasSSLRedirectHeaders $container}}
{{range getHostsProxyHeaders $container}} SSLRedirect = {{getSSLRedirectHeaders $container}}
"{{.}}" {{end}}
{{end}} {{if hasSSLTemporaryRedirectHeaders $container}}
{{end}} SSLTemporaryRedirect = {{getSSLTemporaryRedirectHeaders $container}}
{{if hasSSLProxyHeaders $container}} {{end}}
[frontends."frontend-{{$frontend}}".headers.SSLProxyHeaders] {{if hasSSLHostHeaders $container}}
{{range $k, $v := getSSLProxyHeaders $container}} SSLHost = "{{getSSLHostHeaders $container}}"
{{$k}} = "{{$v}}" {{end}}
{{end}} {{if hasSTSSecondsHeaders $container}}
{{end}} STSSeconds = {{getSTSSecondsHeaders $container}}
{{end}}
{{if hasSTSIncludeSubdomainsHeaders $container}}
STSIncludeSubdomains = {{getSTSIncludeSubdomainsHeaders $container}}
{{end}}
{{if hasSTSPreloadHeaders $container}}
STSPreload = {{getSTSPreloadHeaders $container}}
{{end}}
{{if hasForceSTSHeaderHeaders $container}}
ForceSTSHeader = {{getForceSTSHeaderHeaders $container}}
{{end}}
{{if hasFrameDenyHeaders $container}}
FrameDeny = {{getFrameDenyHeaders $container}}
{{end}}
{{if hasCustomFrameOptionsValueHeaders $container}}
CustomFrameOptionsValue = "{{getCustomFrameOptionsValueHeaders $container}}"
{{end}}
{{if hasContentTypeNosniffHeaders $container}}
ContentTypeNosniff = {{getContentTypeNosniffHeaders $container}}
{{end}}
{{if hasBrowserXSSFilterHeaders $container}}
BrowserXSSFilter = {{getBrowserXSSFilterHeaders $container}}
{{end}}
{{if hasContentSecurityPolicyHeaders $container}}
ContentSecurityPolicy = "{{getContentSecurityPolicyHeaders $container}}"
{{end}}
{{if hasPublicKeyHeaders $container}}
PublicKey = "{{getPublicKeyHeaders $container}}"
{{end}}
{{if hasReferrerPolicyHeaders $container}}
ReferrerPolicy = "{{getReferrerPolicyHeaders $container}}"
{{end}}
{{if hasIsDevelopmentHeaders $container}}
IsDevelopment = {{getIsDevelopmentHeaders $container}}
{{end}}
{{if hasRequestHeaders $container}}
[frontends."frontend-{{$frontend}}".headers.customRequestHeaders]
{{range $k, $v := getRequestHeaders $container}}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
{{if hasResponseHeaders $container}}
[frontends."frontend-{{$frontend}}".headers.customResponseHeaders]
{{range $k, $v := getResponseHeaders $container}}
{{$k}} = "{{$v}}"
{{end}}
{{end}}
{{if hasAllowedHostsHeaders $container}}
[frontends."frontend-{{$frontend}}".headers.AllowedHosts]
{{range getAllowedHostsHeaders $container}}
"{{.}}"
{{end}}
{{end}}
{{if hasHostsProxyHeaders $container}}
[frontends."frontend-{{$frontend}}".headers.HostsProxyHeaders]
{{range getHostsProxyHeaders $container}}
"{{.}}"
{{end}}
{{end}}
{{if hasSSLProxyHeaders $container}}
[frontends."frontend-{{$frontend}}".headers.SSLProxyHeaders]
{{range $k, $v := getSSLProxyHeaders $container}}
{{$k}} = "{{$v}}"
{{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}}
`) `)