Use prefix for sticky and stickiness tags.

This commit is contained in:
Ludovic Fernandez 2018-01-02 09:44:02 +01:00 committed by Traefiker
parent 9a7821b8fa
commit 75533b2beb
2 changed files with 70 additions and 67 deletions

View file

@ -430,7 +430,7 @@ func (p *CatalogProvider) getBasicAuth(tags []string) []string {
} }
func (p *CatalogProvider) getSticky(tags []string) string { func (p *CatalogProvider) getSticky(tags []string) string {
stickyTag := p.getTag(types.LabelBackendLoadbalancerSticky, tags, "") stickyTag := p.getAttribute(types.SuffixBackendLoadBalancerSticky, tags, "")
if len(stickyTag) > 0 { if len(stickyTag) > 0 {
log.Warnf("Deprecated configuration found: %s. Please use %s.", types.LabelBackendLoadbalancerSticky, types.LabelBackendLoadbalancerStickiness) log.Warnf("Deprecated configuration found: %s. Please use %s.", types.LabelBackendLoadbalancerSticky, types.LabelBackendLoadbalancerStickiness)
} else { } else {
@ -440,12 +440,12 @@ func (p *CatalogProvider) getSticky(tags []string) string {
} }
func (p *CatalogProvider) hasStickinessLabel(tags []string) bool { func (p *CatalogProvider) hasStickinessLabel(tags []string) bool {
stickinessTag := p.getTag(types.LabelBackendLoadbalancerStickiness, tags, "") stickinessTag := p.getAttribute(types.SuffixBackendLoadBalancerStickiness, tags, "")
return len(stickinessTag) > 0 && strings.EqualFold(strings.TrimSpace(stickinessTag), "true") return len(stickinessTag) > 0 && strings.EqualFold(strings.TrimSpace(stickinessTag), "true")
} }
func (p *CatalogProvider) getStickinessCookieName(tags []string) string { func (p *CatalogProvider) getStickinessCookieName(tags []string) string {
return p.getTag(types.LabelBackendLoadbalancerStickinessCookieName, tags, "") return p.getAttribute(types.SuffixBackendLoadBalancerStickinessCookieName, tags, "")
} }
func (p *CatalogProvider) getAttribute(name string, tags []string, defaultValue string) string { func (p *CatalogProvider) getAttribute(name string, tags []string, defaultValue string) string {

View file

@ -4,70 +4,73 @@ import "strings"
// Traefik labels // Traefik labels
const ( const (
LabelPrefix = "traefik." LabelPrefix = "traefik."
SuffixPort = "port" SuffixPort = "port"
SuffixProtocol = "protocol" SuffixProtocol = "protocol"
SuffixWeight = "weight" SuffixWeight = "weight"
SuffixFrontendAuthBasic = "frontend.auth.basic" SuffixFrontendAuthBasic = "frontend.auth.basic"
SuffixFrontendBackend = "frontend.backend" SuffixFrontendBackend = "frontend.backend"
SuffixFrontendEntryPoints = "frontend.entryPoints" SuffixFrontendEntryPoints = "frontend.entryPoints"
SuffixFrontendPassHostHeader = "frontend.passHostHeader" SuffixFrontendPassHostHeader = "frontend.passHostHeader"
SuffixFrontendPriority = "frontend.priority" SuffixFrontendPriority = "frontend.priority"
SuffixFrontendRedirectEntryPoint = "frontend.redirect.entryPoint" SuffixFrontendRedirectEntryPoint = "frontend.redirect.entryPoint"
SuffixFrontendRedirectRegex = "frontend.redirect.regex" SuffixFrontendRedirectRegex = "frontend.redirect.regex"
SuffixFrontendRedirectReplacement = "frontend.redirect.replacement" SuffixFrontendRedirectReplacement = "frontend.redirect.replacement"
SuffixFrontendRule = "frontend.rule" SuffixFrontendRule = "frontend.rule"
LabelDomain = LabelPrefix + "domain" SuffixBackendLoadBalancerSticky = "backend.loadbalancer.sticky"
LabelEnable = LabelPrefix + "enable" SuffixBackendLoadBalancerStickiness = "backend.loadbalancer.stickiness"
LabelPort = LabelPrefix + SuffixPort SuffixBackendLoadBalancerStickinessCookieName = "backend.loadbalancer.stickiness.cookieName"
LabelPortIndex = LabelPrefix + "portIndex" LabelDomain = LabelPrefix + "domain"
LabelProtocol = LabelPrefix + SuffixProtocol LabelEnable = LabelPrefix + "enable"
LabelTags = LabelPrefix + "tags" LabelPort = LabelPrefix + SuffixPort
LabelWeight = LabelPrefix + SuffixWeight LabelPortIndex = LabelPrefix + "portIndex"
LabelFrontendAuthBasic = LabelPrefix + SuffixFrontendAuthBasic LabelProtocol = LabelPrefix + SuffixProtocol
LabelFrontendEntryPoints = LabelPrefix + SuffixFrontendEntryPoints LabelTags = LabelPrefix + "tags"
LabelFrontendPassHostHeader = LabelPrefix + SuffixFrontendPassHostHeader LabelWeight = LabelPrefix + SuffixWeight
LabelFrontendPassTLSCert = LabelPrefix + "frontend.passTLSCert" LabelFrontendAuthBasic = LabelPrefix + SuffixFrontendAuthBasic
LabelFrontendPriority = LabelPrefix + SuffixFrontendPriority LabelFrontendEntryPoints = LabelPrefix + SuffixFrontendEntryPoints
LabelFrontendRule = LabelPrefix + SuffixFrontendRule LabelFrontendPassHostHeader = LabelPrefix + SuffixFrontendPassHostHeader
LabelFrontendRuleType = LabelPrefix + "frontend.rule.type" LabelFrontendPassTLSCert = LabelPrefix + "frontend.passTLSCert"
LabelFrontendRedirectEntryPoint = LabelPrefix + SuffixFrontendRedirectEntryPoint LabelFrontendPriority = LabelPrefix + SuffixFrontendPriority
LabelFrontendRedirectRegex = LabelPrefix + SuffixFrontendRedirectRegex LabelFrontendRule = LabelPrefix + SuffixFrontendRule
LabelFrontendRedirectReplacement = LabelPrefix + SuffixFrontendRedirectReplacement LabelFrontendRuleType = LabelPrefix + "frontend.rule.type"
LabelTraefikFrontendValue = LabelPrefix + "frontend.value" LabelFrontendRedirectEntryPoint = LabelPrefix + SuffixFrontendRedirectEntryPoint
LabelTraefikFrontendWhitelistSourceRange = LabelPrefix + "frontend.whitelistSourceRange" LabelFrontendRedirectRegex = LabelPrefix + SuffixFrontendRedirectRegex
LabelFrontendRequestHeaders = LabelPrefix + "frontend.headers.customRequestHeaders" LabelFrontendRedirectReplacement = LabelPrefix + SuffixFrontendRedirectReplacement
LabelFrontendResponseHeaders = LabelPrefix + "frontend.headers.customResponseHeaders" LabelTraefikFrontendValue = LabelPrefix + "frontend.value"
LabelFrontendAllowedHosts = LabelPrefix + "frontend.headers.allowedHosts" LabelTraefikFrontendWhitelistSourceRange = LabelPrefix + "frontend.whitelistSourceRange"
LabelFrontendHostsProxyHeaders = LabelPrefix + "frontend.headers.hostsProxyHeaders" LabelFrontendRequestHeaders = LabelPrefix + "frontend.headers.customRequestHeaders"
LabelFrontendSSLRedirect = LabelPrefix + "frontend.headers.SSLRedirect" LabelFrontendResponseHeaders = LabelPrefix + "frontend.headers.customResponseHeaders"
LabelFrontendSSLTemporaryRedirect = LabelPrefix + "frontend.headers.SSLTemporaryRedirect" LabelFrontendAllowedHosts = LabelPrefix + "frontend.headers.allowedHosts"
LabelFrontendSSLHost = LabelPrefix + "frontend.headers.SSLHost" LabelFrontendHostsProxyHeaders = LabelPrefix + "frontend.headers.hostsProxyHeaders"
LabelFrontendSSLProxyHeaders = LabelPrefix + "frontend.headers.SSLProxyHeaders" LabelFrontendSSLRedirect = LabelPrefix + "frontend.headers.SSLRedirect"
LabelFrontendSTSSeconds = LabelPrefix + "frontend.headers.STSSeconds" LabelFrontendSSLTemporaryRedirect = LabelPrefix + "frontend.headers.SSLTemporaryRedirect"
LabelFrontendSTSIncludeSubdomains = LabelPrefix + "frontend.headers.STSIncludeSubdomains" LabelFrontendSSLHost = LabelPrefix + "frontend.headers.SSLHost"
LabelFrontendSTSPreload = LabelPrefix + "frontend.headers.STSPreload" LabelFrontendSSLProxyHeaders = LabelPrefix + "frontend.headers.SSLProxyHeaders"
LabelFrontendForceSTSHeader = LabelPrefix + "frontend.headers.forceSTSHeader" LabelFrontendSTSSeconds = LabelPrefix + "frontend.headers.STSSeconds"
LabelFrontendFrameDeny = LabelPrefix + "frontend.headers.frameDeny" LabelFrontendSTSIncludeSubdomains = LabelPrefix + "frontend.headers.STSIncludeSubdomains"
LabelFrontendCustomFrameOptionsValue = LabelPrefix + "frontend.headers.customFrameOptionsValue" LabelFrontendSTSPreload = LabelPrefix + "frontend.headers.STSPreload"
LabelFrontendContentTypeNosniff = LabelPrefix + "frontend.headers.contentTypeNosniff" LabelFrontendForceSTSHeader = LabelPrefix + "frontend.headers.forceSTSHeader"
LabelFrontendBrowserXSSFilter = LabelPrefix + "frontend.headers.browserXSSFilter" LabelFrontendFrameDeny = LabelPrefix + "frontend.headers.frameDeny"
LabelFrontendContentSecurityPolicy = LabelPrefix + "frontend.headers.contentSecurityPolicy" LabelFrontendCustomFrameOptionsValue = LabelPrefix + "frontend.headers.customFrameOptionsValue"
LabelFrontendPublicKey = LabelPrefix + "frontend.headers.publicKey" LabelFrontendContentTypeNosniff = LabelPrefix + "frontend.headers.contentTypeNosniff"
LabelFrontendReferrerPolicy = LabelPrefix + "frontend.headers.referrerPolicy" LabelFrontendBrowserXSSFilter = LabelPrefix + "frontend.headers.browserXSSFilter"
LabelFrontendIsDevelopment = LabelPrefix + "frontend.headers.isDevelopment" LabelFrontendContentSecurityPolicy = LabelPrefix + "frontend.headers.contentSecurityPolicy"
LabelBackend = LabelPrefix + "backend" LabelFrontendPublicKey = LabelPrefix + "frontend.headers.publicKey"
LabelBackendID = LabelPrefix + "backend.id" LabelFrontendReferrerPolicy = LabelPrefix + "frontend.headers.referrerPolicy"
LabelTraefikBackendCircuitbreaker = LabelPrefix + "backend.circuitbreaker" LabelFrontendIsDevelopment = LabelPrefix + "frontend.headers.isDevelopment"
LabelBackendCircuitbreakerExpression = LabelPrefix + "backend.circuitbreaker.expression" LabelBackend = LabelPrefix + "backend"
LabelBackendHealthcheckPath = LabelPrefix + "backend.healthcheck.path" LabelBackendID = LabelPrefix + "backend.id"
LabelBackendHealthcheckInterval = LabelPrefix + "backend.healthcheck.interval" LabelTraefikBackendCircuitbreaker = LabelPrefix + "backend.circuitbreaker"
LabelBackendLoadbalancerMethod = LabelPrefix + "backend.loadbalancer.method" LabelBackendCircuitbreakerExpression = LabelPrefix + "backend.circuitbreaker.expression"
LabelBackendLoadbalancerSticky = LabelPrefix + "backend.loadbalancer.sticky" LabelBackendHealthcheckPath = LabelPrefix + "backend.healthcheck.path"
LabelBackendLoadbalancerStickiness = LabelPrefix + "backend.loadbalancer.stickiness" LabelBackendHealthcheckInterval = LabelPrefix + "backend.healthcheck.interval"
LabelBackendLoadbalancerStickinessCookieName = LabelPrefix + "backend.loadbalancer.stickiness.cookieName" LabelBackendLoadbalancerMethod = LabelPrefix + "backend.loadbalancer.method"
LabelBackendMaxconnAmount = LabelPrefix + "backend.maxconn.amount" LabelBackendLoadbalancerSticky = LabelPrefix + SuffixBackendLoadBalancerSticky
LabelBackendMaxconnExtractorfunc = LabelPrefix + "backend.maxconn.extractorfunc" LabelBackendLoadbalancerStickiness = LabelPrefix + SuffixBackendLoadBalancerStickiness
LabelBackendLoadbalancerStickinessCookieName = LabelPrefix + SuffixBackendLoadBalancerStickinessCookieName
LabelBackendMaxconnAmount = LabelPrefix + "backend.maxconn.amount"
LabelBackendMaxconnExtractorfunc = LabelPrefix + "backend.maxconn.extractorfunc"
) )
//ServiceLabel converts a key value of Label*, given a serviceName, into a pattern <LabelPrefix>.<serviceName>.<property> //ServiceLabel converts a key value of Label*, given a serviceName, into a pattern <LabelPrefix>.<serviceName>.<property>