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, ""),
|
"getRateLimitsExtractorFunc": getFuncString(label.TraefikFrontendRateLimitExtractorFunc, ""),
|
||||||
"getRateLimits": getRateLimits,
|
"getRateLimits": getRateLimits,
|
||||||
// Headers
|
// Headers
|
||||||
|
"hasHeaders": hasPrefixFunc(label.TraefikFrontendHeaders),
|
||||||
"hasRequestHeaders": hasFunc(label.TraefikFrontendRequestHeaders),
|
"hasRequestHeaders": hasFunc(label.TraefikFrontendRequestHeaders),
|
||||||
"getRequestHeaders": getFuncMap(label.TraefikFrontendRequestHeaders),
|
"getRequestHeaders": getFuncMap(label.TraefikFrontendRequestHeaders),
|
||||||
"hasResponseHeaders": hasFunc(label.TraefikFrontendResponseHeaders),
|
"hasResponseHeaders": hasFunc(label.TraefikFrontendResponseHeaders),
|
||||||
"getResponseHeaders": getFuncMap(label.TraefikFrontendResponseHeaders),
|
"getResponseHeaders": getFuncMap(label.TraefikFrontendResponseHeaders),
|
||||||
"hasAllowedHostsHeaders": hasFunc(label.TraefikFrontendAllowedHosts),
|
|
||||||
"getAllowedHostsHeaders": getFuncSliceString(label.TraefikFrontendAllowedHosts),
|
"getAllowedHostsHeaders": getFuncSliceString(label.TraefikFrontendAllowedHosts),
|
||||||
"hasHostsProxyHeaders": hasFunc(label.TraefikFrontendHostsProxyHeaders),
|
|
||||||
"getHostsProxyHeaders": getFuncSliceString(label.TraefikFrontendHostsProxyHeaders),
|
"getHostsProxyHeaders": getFuncSliceString(label.TraefikFrontendHostsProxyHeaders),
|
||||||
"hasSSLRedirectHeaders": hasFunc(label.TraefikFrontendSSLRedirect),
|
|
||||||
"getSSLRedirectHeaders": getFuncBool(label.TraefikFrontendSSLRedirect, false),
|
"getSSLRedirectHeaders": getFuncBool(label.TraefikFrontendSSLRedirect, false),
|
||||||
"hasSSLTemporaryRedirectHeaders": hasFunc(label.TraefikFrontendSSLTemporaryRedirect),
|
|
||||||
"getSSLTemporaryRedirectHeaders": getFuncBool(label.TraefikFrontendSSLTemporaryRedirect, false),
|
"getSSLTemporaryRedirectHeaders": getFuncBool(label.TraefikFrontendSSLTemporaryRedirect, false),
|
||||||
"hasSSLHostHeaders": hasFunc(label.TraefikFrontendSSLHost),
|
|
||||||
"getSSLHostHeaders": getFuncString(label.TraefikFrontendSSLHost, ""),
|
"getSSLHostHeaders": getFuncString(label.TraefikFrontendSSLHost, ""),
|
||||||
"hasSSLProxyHeaders": hasFunc(label.TraefikFrontendSSLProxyHeaders),
|
"hasSSLProxyHeaders": hasFunc(label.TraefikFrontendSSLProxyHeaders),
|
||||||
"getSSLProxyHeaders": getFuncMap(label.TraefikFrontendSSLProxyHeaders),
|
"getSSLProxyHeaders": getFuncMap(label.TraefikFrontendSSLProxyHeaders),
|
||||||
"hasSTSSecondsHeaders": hasFunc(label.TraefikFrontendSTSSeconds),
|
|
||||||
"getSTSSecondsHeaders": getFuncInt64(label.TraefikFrontendSTSSeconds, 0),
|
"getSTSSecondsHeaders": getFuncInt64(label.TraefikFrontendSTSSeconds, 0),
|
||||||
"hasSTSIncludeSubdomainsHeaders": hasFunc(label.TraefikFrontendSTSIncludeSubdomains),
|
|
||||||
"getSTSIncludeSubdomainsHeaders": getFuncBool(label.TraefikFrontendSTSIncludeSubdomains, false),
|
"getSTSIncludeSubdomainsHeaders": getFuncBool(label.TraefikFrontendSTSIncludeSubdomains, false),
|
||||||
"hasSTSPreloadHeaders": hasFunc(label.TraefikFrontendSTSPreload),
|
|
||||||
"getSTSPreloadHeaders": getFuncBool(label.TraefikFrontendSTSPreload, false),
|
"getSTSPreloadHeaders": getFuncBool(label.TraefikFrontendSTSPreload, false),
|
||||||
"hasForceSTSHeaderHeaders": hasFunc(label.TraefikFrontendForceSTSHeader),
|
|
||||||
"getForceSTSHeaderHeaders": getFuncBool(label.TraefikFrontendForceSTSHeader, false),
|
"getForceSTSHeaderHeaders": getFuncBool(label.TraefikFrontendForceSTSHeader, false),
|
||||||
"hasFrameDenyHeaders": hasFunc(label.TraefikFrontendFrameDeny),
|
|
||||||
"getFrameDenyHeaders": getFuncBool(label.TraefikFrontendFrameDeny, false),
|
"getFrameDenyHeaders": getFuncBool(label.TraefikFrontendFrameDeny, false),
|
||||||
"hasCustomFrameOptionsValueHeaders": hasFunc(label.TraefikFrontendCustomFrameOptionsValue),
|
|
||||||
"getCustomFrameOptionsValueHeaders": getFuncString(label.TraefikFrontendCustomFrameOptionsValue, ""),
|
"getCustomFrameOptionsValueHeaders": getFuncString(label.TraefikFrontendCustomFrameOptionsValue, ""),
|
||||||
"hasContentTypeNosniffHeaders": hasFunc(label.TraefikFrontendContentTypeNosniff),
|
|
||||||
"getContentTypeNosniffHeaders": getFuncBool(label.TraefikFrontendContentTypeNosniff, false),
|
"getContentTypeNosniffHeaders": getFuncBool(label.TraefikFrontendContentTypeNosniff, false),
|
||||||
"hasBrowserXSSFilterHeaders": hasFunc(label.TraefikFrontendBrowserXSSFilter),
|
|
||||||
"getBrowserXSSFilterHeaders": getFuncBool(label.TraefikFrontendBrowserXSSFilter, false),
|
"getBrowserXSSFilterHeaders": getFuncBool(label.TraefikFrontendBrowserXSSFilter, false),
|
||||||
"hasContentSecurityPolicyHeaders": hasFunc(label.TraefikFrontendContentSecurityPolicy),
|
|
||||||
"getContentSecurityPolicyHeaders": getFuncString(label.TraefikFrontendContentSecurityPolicy, ""),
|
"getContentSecurityPolicyHeaders": getFuncString(label.TraefikFrontendContentSecurityPolicy, ""),
|
||||||
"hasPublicKeyHeaders": hasFunc(label.TraefikFrontendPublicKey),
|
|
||||||
"getPublicKeyHeaders": getFuncString(label.TraefikFrontendPublicKey, ""),
|
"getPublicKeyHeaders": getFuncString(label.TraefikFrontendPublicKey, ""),
|
||||||
"hasReferrerPolicyHeaders": hasFunc(label.TraefikFrontendReferrerPolicy),
|
|
||||||
"getReferrerPolicyHeaders": getFuncString(label.TraefikFrontendReferrerPolicy, ""),
|
"getReferrerPolicyHeaders": getFuncString(label.TraefikFrontendReferrerPolicy, ""),
|
||||||
"hasIsDevelopmentHeaders": hasFunc(label.TraefikFrontendIsDevelopment),
|
|
||||||
"getIsDevelopmentHeaders": getFuncBool(label.TraefikFrontendIsDevelopment, false),
|
"getIsDevelopmentHeaders": getFuncBool(label.TraefikFrontendIsDevelopment, false),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -94,52 +94,32 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
{{if hasHeaders $service }}
|
||||||
[frontends."frontend-{{$frontendName}}".headers]
|
[frontends."frontend-{{$frontendName}}".headers]
|
||||||
{{if hasSSLRedirectHeaders $service}}
|
|
||||||
SSLRedirect = {{getSSLRedirectHeaders $service}}
|
SSLRedirect = {{getSSLRedirectHeaders $service}}
|
||||||
{{end}}
|
|
||||||
{{if hasSSLTemporaryRedirectHeaders $service}}
|
|
||||||
SSLTemporaryRedirect = {{getSSLTemporaryRedirectHeaders $service}}
|
SSLTemporaryRedirect = {{getSSLTemporaryRedirectHeaders $service}}
|
||||||
{{end}}
|
|
||||||
{{if hasSSLHostHeaders $service}}
|
|
||||||
SSLHost = "{{getSSLHostHeaders $service}}"
|
SSLHost = "{{getSSLHostHeaders $service}}"
|
||||||
{{end}}
|
|
||||||
{{if hasSTSSecondsHeaders $service}}
|
|
||||||
STSSeconds = {{getSTSSecondsHeaders $service}}
|
STSSeconds = {{getSTSSecondsHeaders $service}}
|
||||||
{{end}}
|
|
||||||
{{if hasSTSIncludeSubdomainsHeaders $service}}
|
|
||||||
STSIncludeSubdomains = {{getSTSIncludeSubdomainsHeaders $service}}
|
STSIncludeSubdomains = {{getSTSIncludeSubdomainsHeaders $service}}
|
||||||
{{end}}
|
|
||||||
{{if hasSTSPreloadHeaders $service}}
|
|
||||||
STSPreload = {{getSTSPreloadHeaders $service}}
|
STSPreload = {{getSTSPreloadHeaders $service}}
|
||||||
{{end}}
|
|
||||||
{{if hasForceSTSHeaderHeaders $service}}
|
|
||||||
ForceSTSHeader = {{getForceSTSHeaderHeaders $service}}
|
ForceSTSHeader = {{getForceSTSHeaderHeaders $service}}
|
||||||
{{end}}
|
|
||||||
{{if hasFrameDenyHeaders $service}}
|
|
||||||
FrameDeny = {{getFrameDenyHeaders $service}}
|
FrameDeny = {{getFrameDenyHeaders $service}}
|
||||||
{{end}}
|
|
||||||
{{if hasCustomFrameOptionsValueHeaders $service}}
|
|
||||||
CustomFrameOptionsValue = "{{getCustomFrameOptionsValueHeaders $service}}"
|
CustomFrameOptionsValue = "{{getCustomFrameOptionsValueHeaders $service}}"
|
||||||
{{end}}
|
|
||||||
{{if hasContentTypeNosniffHeaders $service}}
|
|
||||||
ContentTypeNosniff = {{getContentTypeNosniffHeaders $service}}
|
ContentTypeNosniff = {{getContentTypeNosniffHeaders $service}}
|
||||||
{{end}}
|
|
||||||
{{if hasBrowserXSSFilterHeaders $service}}
|
|
||||||
BrowserXSSFilter = {{getBrowserXSSFilterHeaders $service}}
|
BrowserXSSFilter = {{getBrowserXSSFilterHeaders $service}}
|
||||||
{{end}}
|
|
||||||
{{if hasContentSecurityPolicyHeaders $service}}
|
|
||||||
ContentSecurityPolicy = "{{getContentSecurityPolicyHeaders $service}}"
|
ContentSecurityPolicy = "{{getContentSecurityPolicyHeaders $service}}"
|
||||||
{{end}}
|
|
||||||
{{if hasPublicKeyHeaders $service}}
|
|
||||||
PublicKey = "{{getPublicKeyHeaders $service}}"
|
PublicKey = "{{getPublicKeyHeaders $service}}"
|
||||||
{{end}}
|
|
||||||
{{if hasReferrerPolicyHeaders $service}}
|
|
||||||
ReferrerPolicy = "{{getReferrerPolicyHeaders $service}}"
|
ReferrerPolicy = "{{getReferrerPolicyHeaders $service}}"
|
||||||
{{end}}
|
|
||||||
{{if hasIsDevelopmentHeaders $service}}
|
|
||||||
IsDevelopment = {{getIsDevelopmentHeaders $service}}
|
IsDevelopment = {{getIsDevelopmentHeaders $service}}
|
||||||
{{end}}
|
|
||||||
|
AllowedHosts = [{{range getAllowedHostsHeaders $service}}
|
||||||
|
"{{.}}",
|
||||||
|
{{end}}]
|
||||||
|
|
||||||
|
HostsProxyHeaders = [{{range getHostsProxyHeaders $service}}
|
||||||
|
"{{.}}",
|
||||||
|
{{end}}]
|
||||||
|
|
||||||
{{if hasRequestHeaders $service}}
|
{{if hasRequestHeaders $service}}
|
||||||
[frontends."frontend-{{$frontendName}}".headers.customRequestHeaders]
|
[frontends."frontend-{{$frontendName}}".headers.customRequestHeaders]
|
||||||
{{range $k, $v := getRequestHeaders $service}}
|
{{range $k, $v := getRequestHeaders $service}}
|
||||||
|
@ -152,24 +132,13 @@
|
||||||
{{$k}} = "{{$v}}"
|
{{$k}} = "{{$v}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{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}}
|
{{if hasSSLProxyHeaders $service}}
|
||||||
[frontends."frontend-{{$frontendName}}".headers.SSLProxyHeaders]
|
[frontends."frontend-{{$frontendName}}".headers.SSLProxyHeaders]
|
||||||
{{range $k, $v := getSSLProxyHeaders $service}}
|
{{range $k, $v := getSSLProxyHeaders $service}}
|
||||||
{{$k}} = "{{$v}}"
|
{{$k}} = "{{$v}}"
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
{{end}}
|
||||||
|
|
||||||
[frontends."frontend-{{$frontendName}}".routes."route-frontend-{{$frontendName}}"]
|
[frontends."frontend-{{$frontendName}}".routes."route-frontend-{{$frontendName}}"]
|
||||||
rule = "{{getFrontendRule $service}}"
|
rule = "{{getFrontendRule $service}}"
|
||||||
|
|
Loading…
Reference in a new issue