Documentation ¶
Index ¶
- Constants
- Variables
- func FindSegmentSubmatch(name string) []string
- func GetBoolValue(labels map[string]string, labelName string, defaultValue bool) bool
- func GetBuffering(labels map[string]string) *types.Buffering
- func GetCircuitBreaker(labels map[string]string) *types.CircuitBreaker
- func GetErrorPages(labels map[string]string) map[string]*types.ErrorPage
- func GetFuncBool(labelName string, defaultValue bool) func(map[string]string) bool
- func GetFuncInt(labelName string, defaultValue int) func(map[string]string) int
- func GetFuncSliceString(labelName string) func(map[string]string) []string
- func GetFuncString(labelName string, defaultValue string) func(map[string]string) string
- func GetHeaders(labels map[string]string) *types.Headers
- func GetHealthCheck(labels map[string]string) *types.HealthCheck
- func GetInt64Value(labels map[string]string, labelName string, defaultValue int64) int64
- func GetIntValue(labels map[string]string, labelName string, defaultValue int) int
- func GetLoadBalancer(labels map[string]string) *types.LoadBalancer
- func GetMapValue(labels map[string]string, labelName string) map[string]string
- func GetMaxConn(labels map[string]string) *types.MaxConn
- func GetRateLimit(labels map[string]string) *types.RateLimit
- func GetRedirect(labels map[string]string) *types.Redirect
- func GetServiceLabel(labelName, serviceName string) string
- func GetSliceStringValue(labels map[string]string, labelName string) []string
- func GetStringMultipleStrict(labels map[string]string, labelNames ...string) (map[string]string, error)
- func GetStringValue(labels map[string]string, labelName string, defaultValue string) string
- func GetWhiteList(labels map[string]string) *types.WhiteList
- func Has(labels map[string]string, labelName string) bool
- func HasPrefix(labels map[string]string, prefix string) bool
- func IsEnabled(labels map[string]string, exposedByDefault bool) bool
- func ParseErrorPages(labels map[string]string, labelPrefix string, labelRegex *regexp.Regexp) map[string]*types.ErrorPage
- func ParseMapValue(labelName, values string) map[string]string
- func ParseRateSets(labels map[string]string, labelPrefix string, labelRegex *regexp.Regexp) map[string]*types.Rate
- func SplitAndTrimString(base string, sep string) []string
- type SegmentProperties
- type SegmentPropertyValues
Constants ¶
const ( DefaultWeight = 1 DefaultProtocol = "http" DefaultPassHostHeader = true DefaultPassTLSCert = false DefaultFrontendPriority = 0 DefaultCircuitBreakerExpression = "NetworkErrorRatio() > 1" DefaultBackendLoadBalancerMethod = "wrr" DefaultBackendMaxconnExtractorFunc = "request.host" DefaultBackendLoadbalancerStickinessCookieName = "" DefaultBackendHealthCheckPort = 0 )
Default values
const ( Prefix = "traefik." SuffixBackend = "backend" SuffixDomain = "domain" SuffixEnable = "enable" SuffixPort = "port" SuffixPortIndex = "portIndex" SuffixProtocol = "protocol" SuffixTags = "tags" SuffixWeight = "weight" SuffixBackendID = "backend.id" SuffixBackendCircuitBreaker = "backend.circuitbreaker" SuffixBackendCircuitBreakerExpression = "backend.circuitbreaker.expression" SuffixBackendHealthCheckPath = "backend.healthcheck.path" SuffixBackendHealthCheckPort = "backend.healthcheck.port" SuffixBackendHealthCheckInterval = "backend.healthcheck.interval" SuffixBackendLoadBalancer = "backend.loadbalancer" SuffixBackendLoadBalancerMethod = SuffixBackendLoadBalancer + ".method" SuffixBackendLoadBalancerSticky = SuffixBackendLoadBalancer + ".sticky" SuffixBackendLoadBalancerStickiness = SuffixBackendLoadBalancer + ".stickiness" SuffixBackendLoadBalancerStickinessCookieName = SuffixBackendLoadBalancer + ".stickiness.cookieName" SuffixBackendMaxConnAmount = "backend.maxconn.amount" SuffixBackendMaxConnExtractorFunc = "backend.maxconn.extractorfunc" SuffixBackendBuffering = "backend.buffering" SuffixBackendBufferingMaxRequestBodyBytes = SuffixBackendBuffering + ".maxRequestBodyBytes" SuffixBackendBufferingMemRequestBodyBytes = SuffixBackendBuffering + ".memRequestBodyBytes" SuffixBackendBufferingMaxResponseBodyBytes = SuffixBackendBuffering + ".maxResponseBodyBytes" SuffixBackendBufferingMemResponseBodyBytes = SuffixBackendBuffering + ".memResponseBodyBytes" SuffixBackendBufferingRetryExpression = SuffixBackendBuffering + ".retryExpression" SuffixFrontend = "frontend" SuffixFrontendAuthBasic = "frontend.auth.basic" SuffixFrontendEntryPoints = "frontend.entryPoints" SuffixFrontendHeaders = "frontend.headers." SuffixFrontendRequestHeaders = SuffixFrontendHeaders + "customRequestHeaders" SuffixFrontendResponseHeaders = SuffixFrontendHeaders + "customResponseHeaders" SuffixFrontendHeadersAllowedHosts = SuffixFrontendHeaders + "allowedHosts" SuffixFrontendHeadersHostsProxyHeaders = SuffixFrontendHeaders + "hostsProxyHeaders" SuffixFrontendHeadersSSLRedirect = SuffixFrontendHeaders + "SSLRedirect" SuffixFrontendHeadersSSLTemporaryRedirect = SuffixFrontendHeaders + "SSLTemporaryRedirect" SuffixFrontendHeadersSSLHost = SuffixFrontendHeaders + "SSLHost" SuffixFrontendHeadersSSLProxyHeaders = SuffixFrontendHeaders + "SSLProxyHeaders" SuffixFrontendHeadersSTSSeconds = SuffixFrontendHeaders + "STSSeconds" SuffixFrontendHeadersSTSIncludeSubdomains = SuffixFrontendHeaders + "STSIncludeSubdomains" SuffixFrontendHeadersSTSPreload = SuffixFrontendHeaders + "STSPreload" SuffixFrontendHeadersForceSTSHeader = SuffixFrontendHeaders + "forceSTSHeader" SuffixFrontendHeadersFrameDeny = SuffixFrontendHeaders + "frameDeny" SuffixFrontendHeadersCustomFrameOptionsValue = SuffixFrontendHeaders + "customFrameOptionsValue" SuffixFrontendHeadersContentTypeNosniff = SuffixFrontendHeaders + "contentTypeNosniff" SuffixFrontendHeadersBrowserXSSFilter = SuffixFrontendHeaders + "browserXSSFilter" SuffixFrontendHeadersCustomBrowserXSSValue = SuffixFrontendHeaders + "customBrowserXSSValue" SuffixFrontendHeadersContentSecurityPolicy = SuffixFrontendHeaders + "contentSecurityPolicy" SuffixFrontendHeadersPublicKey = SuffixFrontendHeaders + "publicKey" SuffixFrontendHeadersReferrerPolicy = SuffixFrontendHeaders + "referrerPolicy" SuffixFrontendHeadersIsDevelopment = SuffixFrontendHeaders + "isDevelopment" SuffixFrontendPassHostHeader = "frontend.passHostHeader" SuffixFrontendPassTLSCert = "frontend.passTLSCert" SuffixFrontendPriority = "frontend.priority" SuffixFrontendRateLimitExtractorFunc = "frontend.rateLimit.extractorFunc" SuffixFrontendRedirectEntryPoint = "frontend.redirect.entryPoint" SuffixFrontendRedirectRegex = "frontend.redirect.regex" SuffixFrontendRedirectReplacement = "frontend.redirect.replacement" SuffixFrontendRedirectPermanent = "frontend.redirect.permanent" SuffixFrontendRule = "frontend.rule" SuffixFrontendWhitelistSourceRange = "frontend.whitelistSourceRange" // Deprecated SuffixFrontendWhiteList = "frontend.whiteList." SuffixFrontendWhiteListSourceRange = SuffixFrontendWhiteList + "sourceRange" SuffixFrontendWhiteListUseXForwardedFor = SuffixFrontendWhiteList + "useXForwardedFor" TraefikDomain = Prefix + SuffixDomain TraefikEnable = Prefix + SuffixEnable TraefikPort = Prefix + SuffixPort TraefikPortIndex = Prefix + SuffixPortIndex TraefikProtocol = Prefix + SuffixProtocol TraefikTags = Prefix + SuffixTags TraefikWeight = Prefix + SuffixWeight TraefikBackend = Prefix + SuffixBackend TraefikBackendID = Prefix + SuffixBackendID TraefikBackendCircuitBreaker = Prefix + SuffixBackendCircuitBreaker TraefikBackendCircuitBreakerExpression = Prefix + SuffixBackendCircuitBreakerExpression TraefikBackendHealthCheckPath = Prefix + SuffixBackendHealthCheckPath TraefikBackendHealthCheckPort = Prefix + SuffixBackendHealthCheckPort TraefikBackendHealthCheckInterval = Prefix + SuffixBackendHealthCheckInterval TraefikBackendLoadBalancer = Prefix + SuffixBackendLoadBalancer TraefikBackendLoadBalancerMethod = Prefix + SuffixBackendLoadBalancerMethod TraefikBackendLoadBalancerSticky = Prefix + SuffixBackendLoadBalancerSticky TraefikBackendLoadBalancerStickiness = Prefix + SuffixBackendLoadBalancerStickiness TraefikBackendLoadBalancerStickinessCookieName = Prefix + SuffixBackendLoadBalancerStickinessCookieName TraefikBackendMaxConnAmount = Prefix + SuffixBackendMaxConnAmount TraefikBackendMaxConnExtractorFunc = Prefix + SuffixBackendMaxConnExtractorFunc TraefikBackendBuffering = Prefix + SuffixBackendBuffering TraefikBackendBufferingMaxRequestBodyBytes = Prefix + SuffixBackendBufferingMaxRequestBodyBytes TraefikBackendBufferingMemRequestBodyBytes = Prefix + SuffixBackendBufferingMemRequestBodyBytes TraefikBackendBufferingMaxResponseBodyBytes = Prefix + SuffixBackendBufferingMaxResponseBodyBytes TraefikBackendBufferingMemResponseBodyBytes = Prefix + SuffixBackendBufferingMemResponseBodyBytes TraefikBackendBufferingRetryExpression = Prefix + SuffixBackendBufferingRetryExpression TraefikFrontend = Prefix + SuffixFrontend TraefikFrontendAuthBasic = Prefix + SuffixFrontendAuthBasic TraefikFrontendEntryPoints = Prefix + SuffixFrontendEntryPoints TraefikFrontendPassHostHeader = Prefix + SuffixFrontendPassHostHeader TraefikFrontendPassTLSCert = Prefix + SuffixFrontendPassTLSCert TraefikFrontendPriority = Prefix + SuffixFrontendPriority TraefikFrontendRateLimitExtractorFunc = Prefix + SuffixFrontendRateLimitExtractorFunc TraefikFrontendRedirectEntryPoint = Prefix + SuffixFrontendRedirectEntryPoint TraefikFrontendRedirectRegex = Prefix + SuffixFrontendRedirectRegex TraefikFrontendRedirectReplacement = Prefix + SuffixFrontendRedirectReplacement TraefikFrontendRedirectPermanent = Prefix + SuffixFrontendRedirectPermanent TraefikFrontendRule = Prefix + SuffixFrontendRule TraefikFrontendWhitelistSourceRange = Prefix + SuffixFrontendWhitelistSourceRange // Deprecated TraefikFrontendWhiteListSourceRange = Prefix + SuffixFrontendWhiteListSourceRange TraefikFrontendWhiteListUseXForwardedFor = Prefix + SuffixFrontendWhiteListUseXForwardedFor TraefikFrontendRequestHeaders = Prefix + SuffixFrontendRequestHeaders TraefikFrontendResponseHeaders = Prefix + SuffixFrontendResponseHeaders TraefikFrontendAllowedHosts = Prefix + SuffixFrontendHeadersAllowedHosts TraefikFrontendHostsProxyHeaders = Prefix + SuffixFrontendHeadersHostsProxyHeaders TraefikFrontendSSLRedirect = Prefix + SuffixFrontendHeadersSSLRedirect TraefikFrontendSSLTemporaryRedirect = Prefix + SuffixFrontendHeadersSSLTemporaryRedirect TraefikFrontendSSLHost = Prefix + SuffixFrontendHeadersSSLHost TraefikFrontendSSLProxyHeaders = Prefix + SuffixFrontendHeadersSSLProxyHeaders TraefikFrontendSTSSeconds = Prefix + SuffixFrontendHeadersSTSSeconds TraefikFrontendSTSIncludeSubdomains = Prefix + SuffixFrontendHeadersSTSIncludeSubdomains TraefikFrontendSTSPreload = Prefix + SuffixFrontendHeadersSTSPreload TraefikFrontendForceSTSHeader = Prefix + SuffixFrontendHeadersForceSTSHeader TraefikFrontendFrameDeny = Prefix + SuffixFrontendHeadersFrameDeny TraefikFrontendCustomFrameOptionsValue = Prefix + SuffixFrontendHeadersCustomFrameOptionsValue TraefikFrontendContentTypeNosniff = Prefix + SuffixFrontendHeadersContentTypeNosniff TraefikFrontendBrowserXSSFilter = Prefix + SuffixFrontendHeadersBrowserXSSFilter TraefikFrontendCustomBrowserXSSValue = Prefix + SuffixFrontendHeadersCustomBrowserXSSValue TraefikFrontendContentSecurityPolicy = Prefix + SuffixFrontendHeadersContentSecurityPolicy TraefikFrontendPublicKey = Prefix + SuffixFrontendHeadersPublicKey TraefikFrontendReferrerPolicy = Prefix + SuffixFrontendHeadersReferrerPolicy TraefikFrontendIsDevelopment = Prefix + SuffixFrontendHeadersIsDevelopment BaseFrontendErrorPage = "frontend.errors." SuffixErrorPageBackend = "backend" SuffixErrorPageQuery = "query" SuffixErrorPageStatus = "status" BaseFrontendRateLimit = "frontend.rateLimit.rateSet." SuffixRateLimitPeriod = "period" SuffixRateLimitAverage = "average" SuffixRateLimitBurst = "burst" )
Traefik labels
Variables ¶
var ( // RegexpBaseFrontendErrorPage used to extract error pages from service's label RegexpBaseFrontendErrorPage = regexp.MustCompile(`^frontend\.errors\.(?P<name>[^ .]+)\.(?P<field>[^ .]+)$`) // RegexpFrontendErrorPage used to extract error pages from label RegexpFrontendErrorPage = regexp.MustCompile(`^traefik\.frontend\.errors\.(?P<name>[^ .]+)\.(?P<field>[^ .]+)$`) // RegexpBaseFrontendRateLimit used to extract rate limits from service's label RegexpBaseFrontendRateLimit = regexp.MustCompile(`^frontend\.rateLimit\.rateSet\.(?P<name>[^ .]+)\.(?P<field>[^ .]+)$`) // RegexpFrontendRateLimit used to extract rate limits from label RegexpFrontendRateLimit = regexp.MustCompile(`^traefik\.frontend\.rateLimit\.rateSet\.(?P<name>[^ .]+)\.(?P<field>[^ .]+)$`) )
var ( // SegmentPropertiesRegexp used to extract the name of the segment and the name of the property for this segment // All properties are under the format traefik.<segment_name>.frontend.*= except the port/portIndex/weight/protocol/backend directly after traefik.<segment_name>. SegmentPropertiesRegexp = regexp.MustCompile(`^traefik\.(?P<segment_name>.+?)\.(?P<property_name>port|portIndex|weight|protocol|backend|frontend\.(.+))$`) // PortRegexp used to extract the port label of the segment PortRegexp = regexp.MustCompile(`^traefik\.(?P<segment_name>.+?)\.port$`) )
Functions ¶
func FindSegmentSubmatch ¶
FindSegmentSubmatch split segment labels
func GetBoolValue ¶
GetBoolValue get bool value associated to a label
func GetBuffering ¶
GetBuffering Create buffering from labels
func GetCircuitBreaker ¶
func GetCircuitBreaker(labels map[string]string) *types.CircuitBreaker
GetCircuitBreaker Create circuit breaker from labels
func GetErrorPages ¶
GetErrorPages Create error pages from labels
func GetFuncBool ¶
GetFuncBool a func related to GetBoolValue
func GetFuncInt ¶
GetFuncInt a func related to GetIntValue
func GetFuncSliceString ¶
GetFuncSliceString a func related to GetSliceStringValue
func GetFuncString ¶
GetFuncString a func related to GetStringValue
func GetHeaders ¶
GetHeaders Create headers from labels
func GetHealthCheck ¶
func GetHealthCheck(labels map[string]string) *types.HealthCheck
GetHealthCheck Create health check from labels
func GetInt64Value ¶
GetInt64Value get int64 value associated to a label
func GetIntValue ¶
GetIntValue get int value associated to a label
func GetLoadBalancer ¶
func GetLoadBalancer(labels map[string]string) *types.LoadBalancer
GetLoadBalancer Create load balancer from labels
func GetMapValue ¶
GetMapValue get Map value associated to a label
func GetMaxConn ¶
GetMaxConn Create max connection from labels
func GetRateLimit ¶
GetRateLimit Create rate limits from labels
func GetRedirect ¶
GetRedirect Create redirect from labels
func GetServiceLabel ¶
GetServiceLabel converts a key value of Label*, given a serviceName, into a pattern <LabelPrefix>.<serviceName>.<property> i.e. For LabelFrontendRule and serviceName=app it will return "traefik.app.frontend.rule" Deprecated
func GetSliceStringValue ¶
GetSliceStringValue get a slice of string associated to a label
func GetStringMultipleStrict ¶
func GetStringMultipleStrict(labels map[string]string, labelNames ...string) (map[string]string, error)
GetStringMultipleStrict get multiple string values associated to several labels Fail if one label is missing
func GetStringValue ¶
GetStringValue get string value associated to a label
func GetWhiteList ¶
GetWhiteList Create white list from labels
func ParseErrorPages ¶
func ParseErrorPages(labels map[string]string, labelPrefix string, labelRegex *regexp.Regexp) map[string]*types.ErrorPage
ParseErrorPages parse error pages to create ErrorPage struct
func ParseMapValue ¶
ParseMapValue get Map value for a label value
func ParseRateSets ¶
func ParseRateSets(labels map[string]string, labelPrefix string, labelRegex *regexp.Regexp) map[string]*types.Rate
ParseRateSets parse rate limits to create Rate struct
func SplitAndTrimString ¶
SplitAndTrimString splits separatedString at the separator character and trims each piece, filtering out empty pieces. Returns the list of pieces or nil if the input did not contain a non-empty piece.
Types ¶
type SegmentProperties ¶
type SegmentProperties map[string]SegmentPropertyValues
SegmentProperties is a map of segment properties per segment, which we can get with label[segmentName][propertyName]. It yields a property value.
func ExtractServiceProperties ¶
func ExtractServiceProperties(labels map[string]string) SegmentProperties
ExtractServiceProperties Extract services labels Deprecated
func ExtractServicePropertiesP ¶
func ExtractServicePropertiesP(labels *map[string]string) SegmentProperties
ExtractServicePropertiesP Extract services labels Deprecated
func ExtractTraefikLabels ¶
func ExtractTraefikLabels(originLabels map[string]string) SegmentProperties
ExtractTraefikLabels transform labels to segment labels
func (SegmentProperties) GetSegmentNames ¶
func (s SegmentProperties) GetSegmentNames() []string
GetSegmentNames get all segment names
type SegmentPropertyValues ¶
SegmentPropertyValues is a map of segment properties an example value is: weight=42