refactor(rancher): headers as pointer.
This commit is contained in:
parent
38b5aef208
commit
7e5c258266
2 changed files with 42 additions and 89 deletions
|
@ -55,45 +55,29 @@ func (p *Provider) buildConfiguration(services []rancherData) *types.Configurati
|
|||
"getRateLimitsExtractorFunc": getFuncString(label.TraefikFrontendRateLimitExtractorFunc, ""),
|
||||
"getRateLimits": getRateLimits,
|
||||
// Headers
|
||||
"hasHeaders": hasPrefixFunc(label.TraefikFrontendHeaders),
|
||||
"hasRequestHeaders": hasFunc(label.TraefikFrontendRequestHeaders),
|
||||
"getRequestHeaders": getFuncMap(label.TraefikFrontendRequestHeaders),
|
||||
"hasResponseHeaders": hasFunc(label.TraefikFrontendResponseHeaders),
|
||||
"getResponseHeaders": getFuncMap(label.TraefikFrontendResponseHeaders),
|
||||
"hasAllowedHostsHeaders": hasFunc(label.TraefikFrontendAllowedHosts),
|
||||
"getAllowedHostsHeaders": getFuncSliceString(label.TraefikFrontendAllowedHosts),
|
||||
"hasHostsProxyHeaders": hasFunc(label.TraefikFrontendHostsProxyHeaders),
|
||||
"getHostsProxyHeaders": getFuncSliceString(label.TraefikFrontendHostsProxyHeaders),
|
||||
"hasSSLRedirectHeaders": hasFunc(label.TraefikFrontendSSLRedirect),
|
||||
"getSSLRedirectHeaders": getFuncBool(label.TraefikFrontendSSLRedirect, false),
|
||||
"hasSSLTemporaryRedirectHeaders": hasFunc(label.TraefikFrontendSSLTemporaryRedirect),
|
||||
"getSSLTemporaryRedirectHeaders": getFuncBool(label.TraefikFrontendSSLTemporaryRedirect, false),
|
||||
"hasSSLHostHeaders": hasFunc(label.TraefikFrontendSSLHost),
|
||||
"getSSLHostHeaders": getFuncString(label.TraefikFrontendSSLHost, ""),
|
||||
"hasSSLProxyHeaders": hasFunc(label.TraefikFrontendSSLProxyHeaders),
|
||||
"getSSLProxyHeaders": getFuncMap(label.TraefikFrontendSSLProxyHeaders),
|
||||
"hasSTSSecondsHeaders": hasFunc(label.TraefikFrontendSTSSeconds),
|
||||
"getSTSSecondsHeaders": getFuncInt64(label.TraefikFrontendSTSSeconds, 0),
|
||||
"hasSTSIncludeSubdomainsHeaders": hasFunc(label.TraefikFrontendSTSIncludeSubdomains),
|
||||
"getSTSIncludeSubdomainsHeaders": getFuncBool(label.TraefikFrontendSTSIncludeSubdomains, false),
|
||||
"hasSTSPreloadHeaders": hasFunc(label.TraefikFrontendSTSPreload),
|
||||
"getSTSPreloadHeaders": getFuncBool(label.TraefikFrontendSTSPreload, false),
|
||||
"hasForceSTSHeaderHeaders": hasFunc(label.TraefikFrontendForceSTSHeader),
|
||||
"getForceSTSHeaderHeaders": getFuncBool(label.TraefikFrontendForceSTSHeader, false),
|
||||
"hasFrameDenyHeaders": hasFunc(label.TraefikFrontendFrameDeny),
|
||||
"getFrameDenyHeaders": getFuncBool(label.TraefikFrontendFrameDeny, false),
|
||||
"hasCustomFrameOptionsValueHeaders": hasFunc(label.TraefikFrontendCustomFrameOptionsValue),
|
||||
"getCustomFrameOptionsValueHeaders": getFuncString(label.TraefikFrontendCustomFrameOptionsValue, ""),
|
||||
"hasContentTypeNosniffHeaders": hasFunc(label.TraefikFrontendContentTypeNosniff),
|
||||
"getContentTypeNosniffHeaders": getFuncBool(label.TraefikFrontendContentTypeNosniff, false),
|
||||
"hasBrowserXSSFilterHeaders": hasFunc(label.TraefikFrontendBrowserXSSFilter),
|
||||
"getBrowserXSSFilterHeaders": getFuncBool(label.TraefikFrontendBrowserXSSFilter, false),
|
||||
"hasContentSecurityPolicyHeaders": hasFunc(label.TraefikFrontendContentSecurityPolicy),
|
||||
"getContentSecurityPolicyHeaders": getFuncString(label.TraefikFrontendContentSecurityPolicy, ""),
|
||||
"hasPublicKeyHeaders": hasFunc(label.TraefikFrontendPublicKey),
|
||||
"getPublicKeyHeaders": getFuncString(label.TraefikFrontendPublicKey, ""),
|
||||
"hasReferrerPolicyHeaders": hasFunc(label.TraefikFrontendReferrerPolicy),
|
||||
"getReferrerPolicyHeaders": getFuncString(label.TraefikFrontendReferrerPolicy, ""),
|
||||
"hasIsDevelopmentHeaders": hasFunc(label.TraefikFrontendIsDevelopment),
|
||||
"getIsDevelopmentHeaders": getFuncBool(label.TraefikFrontendIsDevelopment, false),
|
||||
}
|
||||
|
||||
|
|
|
@ -94,82 +94,51 @@
|
|||
{{end}}
|
||||
{{end}}
|
||||
|
||||
{{if hasHeaders $service }}
|
||||
[frontends."frontend-{{$frontendName}}".headers]
|
||||
{{if hasSSLRedirectHeaders $service}}
|
||||
SSLRedirect = {{getSSLRedirectHeaders $service}}
|
||||
SSLRedirect = {{getSSLRedirectHeaders $service}}
|
||||
SSLTemporaryRedirect = {{getSSLTemporaryRedirectHeaders $service}}
|
||||
SSLHost = "{{getSSLHostHeaders $service}}"
|
||||
STSSeconds = {{getSTSSecondsHeaders $service}}
|
||||
STSIncludeSubdomains = {{getSTSIncludeSubdomainsHeaders $service}}
|
||||
STSPreload = {{getSTSPreloadHeaders $service}}
|
||||
ForceSTSHeader = {{getForceSTSHeaderHeaders $service}}
|
||||
FrameDeny = {{getFrameDenyHeaders $service}}
|
||||
CustomFrameOptionsValue = "{{getCustomFrameOptionsValueHeaders $service}}"
|
||||
ContentTypeNosniff = {{getContentTypeNosniffHeaders $service}}
|
||||
BrowserXSSFilter = {{getBrowserXSSFilterHeaders $service}}
|
||||
ContentSecurityPolicy = "{{getContentSecurityPolicyHeaders $service}}"
|
||||
PublicKey = "{{getPublicKeyHeaders $service}}"
|
||||
ReferrerPolicy = "{{getReferrerPolicyHeaders $service}}"
|
||||
IsDevelopment = {{getIsDevelopmentHeaders $service}}
|
||||
|
||||
AllowedHosts = [{{range getAllowedHostsHeaders $service}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
HostsProxyHeaders = [{{range getHostsProxyHeaders $service}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
{{if hasRequestHeaders $service}}
|
||||
[frontends."frontend-{{$frontendName}}".headers.customRequestHeaders]
|
||||
{{range $k, $v := getRequestHeaders $service}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{if hasSSLTemporaryRedirectHeaders $service}}
|
||||
SSLTemporaryRedirect = {{getSSLTemporaryRedirectHeaders $service}}
|
||||
{{end}}
|
||||
{{if hasResponseHeaders $service}}
|
||||
[frontends."frontend-{{$frontendName}}".headers.customResponseHeaders]
|
||||
{{range $k, $v := getResponseHeaders $service}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{if hasSSLHostHeaders $service}}
|
||||
SSLHost = "{{getSSLHostHeaders $service}}"
|
||||
{{end}}
|
||||
{{if hasSTSSecondsHeaders $service}}
|
||||
STSSeconds = {{getSTSSecondsHeaders $service}}
|
||||
{{end}}
|
||||
{{if hasSTSIncludeSubdomainsHeaders $service}}
|
||||
STSIncludeSubdomains = {{getSTSIncludeSubdomainsHeaders $service}}
|
||||
{{end}}
|
||||
{{if hasSTSPreloadHeaders $service}}
|
||||
STSPreload = {{getSTSPreloadHeaders $service}}
|
||||
{{end}}
|
||||
{{if hasForceSTSHeaderHeaders $service}}
|
||||
ForceSTSHeader = {{getForceSTSHeaderHeaders $service}}
|
||||
{{end}}
|
||||
{{if hasFrameDenyHeaders $service}}
|
||||
FrameDeny = {{getFrameDenyHeaders $service}}
|
||||
{{end}}
|
||||
{{if hasCustomFrameOptionsValueHeaders $service}}
|
||||
CustomFrameOptionsValue = "{{getCustomFrameOptionsValueHeaders $service}}"
|
||||
{{end}}
|
||||
{{if hasContentTypeNosniffHeaders $service}}
|
||||
ContentTypeNosniff = {{getContentTypeNosniffHeaders $service}}
|
||||
{{end}}
|
||||
{{if hasBrowserXSSFilterHeaders $service}}
|
||||
BrowserXSSFilter = {{getBrowserXSSFilterHeaders $service}}
|
||||
{{end}}
|
||||
{{if hasContentSecurityPolicyHeaders $service}}
|
||||
ContentSecurityPolicy = "{{getContentSecurityPolicyHeaders $service}}"
|
||||
{{end}}
|
||||
{{if hasPublicKeyHeaders $service}}
|
||||
PublicKey = "{{getPublicKeyHeaders $service}}"
|
||||
{{end}}
|
||||
{{if hasReferrerPolicyHeaders $service}}
|
||||
ReferrerPolicy = "{{getReferrerPolicyHeaders $service}}"
|
||||
{{end}}
|
||||
{{if hasIsDevelopmentHeaders $service}}
|
||||
IsDevelopment = {{getIsDevelopmentHeaders $service}}
|
||||
{{end}}
|
||||
{{if hasRequestHeaders $service}}
|
||||
[frontends."frontend-{{$frontendName}}".headers.customRequestHeaders]
|
||||
{{range $k, $v := getRequestHeaders $service}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if hasResponseHeaders $service}}
|
||||
[frontends."frontend-{{$frontendName}}".headers.customResponseHeaders]
|
||||
{{range $k, $v := getResponseHeaders $service}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if hasAllowedHostsHeaders $service}}
|
||||
[frontends."frontend-{{$frontendName}}".headers.AllowedHosts]
|
||||
{{range getAllowedHostsHeaders $service}}
|
||||
"{{.}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if hasHostsProxyHeaders $service}}
|
||||
[frontends."frontend-{{$frontendName}}".headers.HostsProxyHeaders]
|
||||
{{range getHostsProxyHeaders $service}}
|
||||
"{{.}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if hasSSLProxyHeaders $service}}
|
||||
[frontends."frontend-{{$frontendName}}".headers.SSLProxyHeaders]
|
||||
{{range $k, $v := getSSLProxyHeaders $service}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{if hasSSLProxyHeaders $service}}
|
||||
[frontends."frontend-{{$frontendName}}".headers.SSLProxyHeaders]
|
||||
{{range $k, $v := getSSLProxyHeaders $service}}
|
||||
{{$k}} = "{{$v}}"
|
||||
{{end}}
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
||||
[frontends."frontend-{{$frontendName}}".routes."route-frontend-{{$frontendName}}"]
|
||||
rule = "{{getFrontendRule $service}}"
|
||||
|
|
Loading…
Reference in a new issue