Server weight zero
This commit is contained in:
parent
edbcd01fbc
commit
8168d2fdc1
84 changed files with 378 additions and 273 deletions
|
@ -39,8 +39,8 @@ func (p *Provider) buildConfigurationV2(catalog []catalogUpdate) *types.Configur
|
|||
"getFrontendRule": p.getFrontendRule,
|
||||
"getBasicAuth": label.GetFuncSliceString(label.TraefikFrontendAuthBasic),
|
||||
"getFrontEndEntryPoints": label.GetFuncSliceString(label.TraefikFrontendEntryPoints),
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getPassTLSCert": label.GetFuncBool(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getWhiteList": label.GetWhiteList,
|
||||
"getRedirect": label.GetRedirect,
|
||||
|
@ -192,7 +192,7 @@ func getServerName(node *api.ServiceEntry, index int) string {
|
|||
}
|
||||
|
||||
func (p *Provider) getWeight(tags []string) int {
|
||||
weight := p.getIntAttribute(label.SuffixWeight, tags, label.DefaultWeightInt)
|
||||
weight := p.getIntAttribute(label.SuffixWeight, tags, label.DefaultWeight)
|
||||
|
||||
// Deprecated
|
||||
deprecatedWeightTag := "backend." + label.SuffixWeight
|
||||
|
@ -200,7 +200,7 @@ func (p *Provider) getWeight(tags []string) int {
|
|||
log.Warnf("Deprecated configuration found: %s. Please use %s.",
|
||||
p.getPrefixedName(deprecatedWeightTag), p.getPrefixedName(label.SuffixWeight))
|
||||
|
||||
weight = p.getIntAttribute(deprecatedWeightTag, tags, label.DefaultWeightInt)
|
||||
weight = p.getIntAttribute(deprecatedWeightTag, tags, label.DefaultWeight)
|
||||
}
|
||||
|
||||
return weight
|
||||
|
|
|
@ -36,8 +36,8 @@ func (p *Provider) buildConfigurationV1(catalog []catalogUpdate) *types.Configur
|
|||
"getFrontendRule": p.getFrontendRuleV1,
|
||||
"getBasicAuth": p.getFuncSliceAttribute(label.SuffixFrontendAuthBasic),
|
||||
"getEntryPoints": getEntryPointsV1,
|
||||
"getPriority": p.getFuncIntAttribute(label.SuffixFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPassHostHeader": p.getFuncBoolAttribute(label.SuffixFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPriority": p.getFuncIntAttribute(label.SuffixFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getPassHostHeader": p.getFuncBoolAttribute(label.SuffixFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getPassTLSCert": p.getFuncBoolAttribute(label.SuffixFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
}
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ func (p *Provider) buildConfigurationV2(containersInspected []dockerData) *types
|
|||
|
||||
// Frontend functions
|
||||
"getBackendName": getBackendName,
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getPassTLSCert": label.GetFuncBool(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getEntryPoints": label.GetFuncSliceString(label.TraefikFrontendEntryPoints),
|
||||
"getBasicAuth": label.GetFuncSliceString(label.TraefikFrontendAuthBasic),
|
||||
|
@ -318,7 +318,7 @@ func (p *Provider) getServers(containers []dockerData) map[string]types.Server {
|
|||
|
||||
servers[provider.Normalize(serverName)] = types.Server{
|
||||
URL: fmt.Sprintf("%s://%s:%s", protocol, ip, port),
|
||||
Weight: label.GetIntValue(container.SegmentLabels, label.TraefikWeight, label.DefaultWeightInt),
|
||||
Weight: label.GetIntValue(container.SegmentLabels, label.TraefikWeight, label.DefaultWeight),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ func TestDockerBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-test": {
|
||||
URL: "http://127.0.0.1:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
|
|
@ -59,7 +59,7 @@ func TestSwarmBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-test": {
|
||||
URL: "http://127.0.0.1:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -59,7 +59,7 @@ func TestSegmentBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-sauternes-foo-0": {
|
||||
URL: "http://127.0.0.1:2503",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
|
|
@ -21,7 +21,7 @@ func (p *Provider) buildConfigurationV1(containersInspected []dockerData) *types
|
|||
// Backend functions
|
||||
"getIPAddress": p.getIPAddress,
|
||||
"getPort": getPortV1,
|
||||
"getWeight": getFuncIntLabelV1(label.TraefikWeight, label.DefaultWeightInt),
|
||||
"getWeight": getFuncIntLabelV1(label.TraefikWeight, label.DefaultWeight),
|
||||
"getProtocol": getFuncStringLabelV1(label.TraefikProtocol, label.DefaultProtocol),
|
||||
|
||||
"hasCircuitBreakerLabel": hasFuncV1(label.TraefikBackendCircuitBreakerExpression),
|
||||
|
@ -38,8 +38,8 @@ func (p *Provider) buildConfigurationV1(containersInspected []dockerData) *types
|
|||
// Frontend functions
|
||||
"getBackend": getBackendNameV1,
|
||||
"getBackendName": getBackendNameV1,
|
||||
"getPriority": getFuncIntLabelV1(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPassHostHeader": getFuncBoolLabelV1(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPriority": getFuncIntLabelV1(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getPassHostHeader": getFuncBoolLabelV1(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getPassTLSCert": getFuncBoolLabelV1(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getEntryPoints": getFuncSliceStringLabelV1(label.TraefikFrontendEntryPoints),
|
||||
"getBasicAuth": getFuncSliceStringLabelV1(label.TraefikFrontendAuthBasic),
|
||||
|
@ -100,15 +100,15 @@ func (p *Provider) buildConfigurationV1(containersInspected []dockerData) *types
|
|||
// Services - Backend server functions
|
||||
"getServicePort": getServicePortV1,
|
||||
"getServiceProtocol": getFuncServiceStringLabelV1(label.SuffixProtocol, label.DefaultProtocol),
|
||||
"getServiceWeight": getFuncServiceStringLabelV1(label.SuffixWeight, label.DefaultWeight),
|
||||
"getServiceWeight": getFuncServiceIntLabelV1(label.SuffixWeight, label.DefaultWeight),
|
||||
// Services - Frontend functions
|
||||
"getServiceEntryPoints": getFuncServiceSliceStringLabelV1(label.SuffixFrontendEntryPoints),
|
||||
"getServiceWhitelistSourceRange": getFuncServiceSliceStringLabelV1(label.SuffixFrontendWhiteListSourceRange),
|
||||
"getServiceBasicAuth": getFuncServiceSliceStringLabelV1(label.SuffixFrontendAuthBasic),
|
||||
"getServiceFrontendRule": p.getServiceFrontendRuleV1,
|
||||
"getServicePassHostHeader": getFuncServiceBoolLabelV1(label.SuffixFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getServicePassHostHeader": getFuncServiceBoolLabelV1(label.SuffixFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getServicePassTLSCert": getFuncServiceBoolLabelV1(label.SuffixFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getServicePriority": getFuncServiceIntLabelV1(label.SuffixFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getServicePriority": getFuncServiceIntLabelV1(label.SuffixFrontendPriority, label.DefaultFrontendPriority),
|
||||
"hasServiceRedirect": hasServiceRedirectV1,
|
||||
"getServiceRedirectEntryPoint": getFuncServiceStringLabelV1(label.SuffixFrontendRedirectEntryPoint, ""),
|
||||
"getServiceRedirectReplacement": getFuncServiceStringLabelV1(label.SuffixFrontendRedirectReplacement, ""),
|
||||
|
|
|
@ -56,7 +56,7 @@ func TestDockerBuildConfigurationV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-test": {
|
||||
URL: "http://127.0.0.1:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
@ -584,17 +584,17 @@ func TestDockerGetFuncStringLabelV1(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
container: containerJSON(),
|
||||
labelName: label.TraefikWeight,
|
||||
defaultValue: label.DefaultWeight,
|
||||
expected: "0",
|
||||
labelName: label.TraefikProtocol,
|
||||
defaultValue: label.DefaultProtocol,
|
||||
expected: "http",
|
||||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
label.TraefikWeight: "10",
|
||||
label.TraefikProtocol: "https",
|
||||
})),
|
||||
labelName: label.TraefikWeight,
|
||||
defaultValue: label.DefaultWeight,
|
||||
expected: "10",
|
||||
labelName: label.TraefikProtocol,
|
||||
defaultValue: label.DefaultProtocol,
|
||||
expected: "https",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ func TestSwarmBuildConfigurationV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-test": {
|
||||
URL: "http://127.0.0.1:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -420,19 +420,19 @@ func TestSwarmGetFuncStringLabelV1(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
service: swarmService(),
|
||||
labelName: label.TraefikWeight,
|
||||
defaultValue: label.DefaultWeight,
|
||||
labelName: label.TraefikProtocol,
|
||||
defaultValue: label.DefaultProtocol,
|
||||
networks: map[string]*docker.NetworkResource{},
|
||||
expected: "0",
|
||||
expected: "http",
|
||||
},
|
||||
{
|
||||
service: swarmService(serviceLabels(map[string]string{
|
||||
label.TraefikWeight: "10",
|
||||
label.TraefikProtocol: "https",
|
||||
})),
|
||||
labelName: label.TraefikWeight,
|
||||
defaultValue: label.DefaultWeight,
|
||||
labelName: label.TraefikProtocol,
|
||||
defaultValue: label.DefaultProtocol,
|
||||
networks: map[string]*docker.NetworkResource{},
|
||||
expected: "10",
|
||||
expected: "https",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ func TestDockerServiceBuildConfigurationV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"service-0": {
|
||||
URL: "http://127.0.0.1:2503",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
@ -272,25 +272,25 @@ func TestDockerGetFuncServiceStringLabelV1(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
container: containerJSON(),
|
||||
suffixLabel: label.SuffixWeight,
|
||||
defaultValue: label.DefaultWeight,
|
||||
expected: "0",
|
||||
suffixLabel: label.SuffixProtocol,
|
||||
defaultValue: label.DefaultProtocol,
|
||||
expected: "http",
|
||||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
label.TraefikWeight: "200",
|
||||
label.TraefikProtocol: "https",
|
||||
})),
|
||||
suffixLabel: label.SuffixWeight,
|
||||
defaultValue: label.DefaultWeight,
|
||||
expected: "200",
|
||||
suffixLabel: label.SuffixProtocol,
|
||||
defaultValue: label.DefaultProtocol,
|
||||
expected: "https",
|
||||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.myservice.weight": "31337",
|
||||
label.Prefix + "myservice." + label.SuffixProtocol: "https",
|
||||
})),
|
||||
suffixLabel: label.SuffixWeight,
|
||||
defaultValue: label.DefaultWeight,
|
||||
expected: "31337",
|
||||
suffixLabel: label.SuffixProtocol,
|
||||
defaultValue: label.DefaultProtocol,
|
||||
expected: "https",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -42,9 +42,9 @@ func (p *Provider) buildConfigurationV2(instances []ecsInstance) (*types.Configu
|
|||
// Frontend functions
|
||||
"filterFrontends": filterFrontends,
|
||||
"getFrontendRule": p.getFrontendRule,
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getPassTLSCert": label.GetFuncBool(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getBasicAuth": label.GetFuncSliceString(label.TraefikFrontendAuthBasic),
|
||||
"getEntryPoints": label.GetFuncSliceString(label.TraefikFrontendEntryPoints),
|
||||
"getRedirect": label.GetRedirect,
|
||||
|
@ -133,7 +133,7 @@ func getServers(instances []ecsInstance) map[string]types.Server {
|
|||
serverName := provider.Normalize(fmt.Sprintf("server-%s-%s", instance.Name, instance.ID))
|
||||
servers[serverName] = types.Server{
|
||||
URL: fmt.Sprintf("%s://%s:%s", protocol, host, port),
|
||||
Weight: label.GetIntValue(instance.TraefikLabels, label.TraefikWeight, 0),
|
||||
Weight: label.GetIntValue(instance.TraefikLabels, label.TraefikWeight, label.DefaultWeight),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,8 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
"backend-instance": {
|
||||
Servers: map[string]types.Server{
|
||||
"server-instance-1": {
|
||||
URL: "http://10.0.0.1:1337",
|
||||
URL: "http://10.0.0.1:1337",
|
||||
Weight: label.DefaultWeight,
|
||||
}},
|
||||
},
|
||||
},
|
||||
|
@ -99,7 +100,8 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
},
|
||||
Servers: map[string]types.Server{
|
||||
"server-instance-1": {
|
||||
URL: "http://10.0.0.1:1337",
|
||||
URL: "http://10.0.0.1:1337",
|
||||
Weight: label.DefaultWeight,
|
||||
}},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -31,7 +31,7 @@ func (p *Provider) buildConfigurationV1(instances []ecsInstance) (*types.Configu
|
|||
"getPort": getPort,
|
||||
|
||||
"getProtocol": getFuncStringValueV1(label.TraefikProtocol, label.DefaultProtocol),
|
||||
"getWeight": getFuncIntValueV1(label.TraefikWeight, label.DefaultWeightInt),
|
||||
"getWeight": getFuncIntValueV1(label.TraefikWeight, label.DefaultWeight),
|
||||
"getLoadBalancerMethod": getFuncFirstStringValueV1(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod),
|
||||
"getLoadBalancerSticky": getStickyV1,
|
||||
"hasStickinessLabel": getFuncFirstBoolValueV1(label.TraefikBackendLoadBalancerStickiness, false),
|
||||
|
@ -43,9 +43,9 @@ func (p *Provider) buildConfigurationV1(instances []ecsInstance) (*types.Configu
|
|||
// Frontend functions
|
||||
"filterFrontends": filterFrontends,
|
||||
"getFrontendRule": p.getFrontendRule,
|
||||
"getPassHostHeader": getFuncBoolValueV1(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPassHostHeader": getFuncBoolValueV1(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getPassTLSCert": getFuncBoolValueV1(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getPriority": getFuncIntValueV1(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPriority": getFuncIntValueV1(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getBasicAuth": getFuncSliceStringV1(label.TraefikFrontendAuthBasic),
|
||||
"getEntryPoints": getFuncSliceStringV1(label.TraefikFrontendEntryPoints),
|
||||
}
|
||||
|
|
|
@ -45,7 +45,8 @@ func TestBuildConfigurationV1(t *testing.T) {
|
|||
"backend-testing": {
|
||||
Servers: map[string]types.Server{
|
||||
"server-testing1": {
|
||||
URL: "http://10.0.0.1:1337",
|
||||
URL: "http://10.0.0.1:1337",
|
||||
Weight: label.DefaultWeight,
|
||||
}},
|
||||
LoadBalancer: &types.LoadBalancer{
|
||||
Method: "wrr",
|
||||
|
@ -100,7 +101,8 @@ func TestBuildConfigurationV1(t *testing.T) {
|
|||
},
|
||||
Servers: map[string]types.Server{
|
||||
"server-testing1": {
|
||||
URL: "http://10.0.0.1:1337",
|
||||
URL: "http://10.0.0.1:1337",
|
||||
Weight: label.DefaultWeight,
|
||||
}},
|
||||
LoadBalancer: &types.LoadBalancer{
|
||||
Method: "wrr",
|
||||
|
|
|
@ -52,6 +52,6 @@ func getProtocol(instance eureka.InstanceInfo) string {
|
|||
return label.DefaultProtocol
|
||||
}
|
||||
|
||||
func getWeight(instance eureka.InstanceInfo) string {
|
||||
return label.GetStringValue(instance.Metadata.Map, label.TraefikWeight, label.DefaultWeight)
|
||||
func getWeight(instance eureka.InstanceInfo) int {
|
||||
return label.GetIntValue(instance.Metadata.Map, label.TraefikWeight, label.DefaultWeight)
|
||||
}
|
||||
|
|
|
@ -91,11 +91,11 @@ func TestGetProtocol(t *testing.T) {
|
|||
|
||||
func TestGetWeight(t *testing.T) {
|
||||
testCases := []struct {
|
||||
expectedWeight string
|
||||
expectedWeight int
|
||||
instanceInfo eureka.InstanceInfo
|
||||
}{
|
||||
{
|
||||
expectedWeight: "0",
|
||||
expectedWeight: label.DefaultWeight,
|
||||
instanceInfo: eureka.InstanceInfo{
|
||||
Port: &eureka.Port{
|
||||
Port: 80, Enabled: true,
|
||||
|
@ -106,7 +106,7 @@ func TestGetWeight(t *testing.T) {
|
|||
},
|
||||
},
|
||||
{
|
||||
expectedWeight: "10",
|
||||
expectedWeight: 10,
|
||||
instanceInfo: eureka.InstanceInfo{
|
||||
Port: &eureka.Port{
|
||||
Port: 80, Enabled: true,
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/containous/flaeg"
|
||||
"github.com/containous/traefik/provider/label"
|
||||
"github.com/containous/traefik/tls"
|
||||
"github.com/containous/traefik/types"
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -448,11 +449,11 @@ func sampleConfiguration() *types.Configuration {
|
|||
Servers: map[string]types.Server{
|
||||
"http://10.10.0.1:8080": {
|
||||
URL: "http://10.10.0.1:8080",
|
||||
Weight: 1,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"http://10.21.0.1:8080": {
|
||||
URL: "http://10.21.0.1:8080",
|
||||
Weight: 1,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
@ -464,7 +465,7 @@ func sampleConfiguration() *types.Configuration {
|
|||
Servers: map[string]types.Server{
|
||||
"https://example.com": {
|
||||
URL: "https://example.com",
|
||||
Weight: 1,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
@ -476,11 +477,11 @@ func sampleConfiguration() *types.Configuration {
|
|||
Servers: map[string]types.Server{
|
||||
"https://10.15.0.1:8443": {
|
||||
URL: "https://10.15.0.1:8443",
|
||||
Weight: 1,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"https://10.15.0.2:9443": {
|
||||
URL: "https://10.15.0.2:9443",
|
||||
Weight: 1,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
|
|
@ -267,7 +267,7 @@ func (p *Provider) loadIngresses(k8sClient Client) (*types.Configuration, error)
|
|||
|
||||
templateObjects.Backends[baseName].Servers[name] = types.Server{
|
||||
URL: url,
|
||||
Weight: 1,
|
||||
Weight: label.DefaultWeight,
|
||||
}
|
||||
} else {
|
||||
endpoints, exists, err := k8sClient.GetEndpoints(service.Namespace, service.Name)
|
||||
|
@ -295,7 +295,7 @@ func (p *Provider) loadIngresses(k8sClient Client) (*types.Configuration, error)
|
|||
}
|
||||
templateObjects.Backends[baseName].Servers[name] = types.Server{
|
||||
URL: url,
|
||||
Weight: 1,
|
||||
Weight: label.DefaultWeight,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -116,9 +116,9 @@ func TestFiller(t *testing.T) {
|
|||
{Key: "traefik/backends/backend.with.dot.too/servers", Value: []byte("")},
|
||||
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot", Value: []byte("")},
|
||||
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot.without.url", Value: []byte("")},
|
||||
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot.without.url/weight", Value: []byte("0")},
|
||||
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot.without.url/weight", Value: []byte("1")},
|
||||
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot/url", Value: []byte("http://172.17.0.2:80")},
|
||||
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot/weight", Value: []byte("0")},
|
||||
{Key: "traefik/backends/backend.with.dot.too/servers/server.with.dot/weight", Value: []byte("1")},
|
||||
{Key: "traefik/frontends/frontend.with.dot", Value: []byte("")},
|
||||
{Key: "traefik/frontends/frontend.with.dot/backend", Value: []byte("backend.with.dot.too")},
|
||||
{Key: "traefik/frontends/frontend.with.dot/errors", Value: []byte("")},
|
||||
|
@ -157,8 +157,8 @@ func TestFiller(t *testing.T) {
|
|||
withLimit("bar", "3", "6", "9"))),
|
||||
backend("backend.with.dot.too",
|
||||
withPair("servers/server.with.dot/url", "http://172.17.0.2:80"),
|
||||
withPair("servers/server.with.dot/weight", "0"),
|
||||
withPair("servers/server.with.dot.without.url/weight", "0")),
|
||||
withPair("servers/server.with.dot/weight", "1"),
|
||||
withPair("servers/server.with.dot.without.url/weight", "1")),
|
||||
)
|
||||
assert.EqualValues(t, expected, pairs1)
|
||||
|
||||
|
@ -181,8 +181,8 @@ func TestFiller(t *testing.T) {
|
|||
withPair("ratelimit/rateset/bar/period", "9")),
|
||||
entry("backends/backend.with.dot.too",
|
||||
withPair("servers/server.with.dot/url", "http://172.17.0.2:80"),
|
||||
withPair("servers/server.with.dot/weight", "0"),
|
||||
withPair("servers/server.with.dot.without.url/weight", "0")),
|
||||
withPair("servers/server.with.dot/weight", "1"),
|
||||
withPair("servers/server.with.dot.without.url/weight", "1")),
|
||||
)
|
||||
assert.EqualValues(t, expected, pairs2)
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ func (p *Provider) buildConfiguration() *types.Configuration {
|
|||
|
||||
// Frontend functions
|
||||
"getBackendName": p.getFuncString(pathFrontendBackend, ""),
|
||||
"getPriority": p.getFuncInt(pathFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPriority": p.getFuncInt(pathFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getPassHostHeader": p.getPassHostHeader(),
|
||||
"getPassTLSCert": p.getFuncBool(pathFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getEntryPoints": p.getFuncList(pathFrontendEntryPoints),
|
||||
|
@ -89,12 +89,12 @@ func (p *Provider) getPassHostHeader() func(rootPath string) bool {
|
|||
value, err := strconv.ParseBool(rawValue)
|
||||
if err != nil {
|
||||
log.Errorf("Invalid value for %s %s: %s", rootPath, pathFrontendPassHostHeader, rawValue)
|
||||
return label.DefaultPassHostHeaderBool
|
||||
return label.DefaultPassHostHeader
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
return p.getBool(label.DefaultPassHostHeaderBool, rootPath, pathFrontendPassHostHeaderDeprecated)
|
||||
return p.getBool(label.DefaultPassHostHeader, rootPath, pathFrontendPassHostHeaderDeprecated)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -402,7 +402,7 @@ func (p *Provider) getServers(rootPath string) map[string]types.Server {
|
|||
serverName := p.last(serverKey)
|
||||
servers[serverName] = types.Server{
|
||||
URL: serverURL,
|
||||
Weight: p.getInt(0, serverKey, pathBackendServerWeight),
|
||||
Weight: p.getInt(label.DefaultWeight, serverKey, pathBackendServerWeight),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
withPair("routes/route.with.dot/rule", "Host:test.localhost")),
|
||||
backend("backend.with.dot.too",
|
||||
withPair("servers/server.with.dot/url", "http://172.17.0.2:80"),
|
||||
withPair("servers/server.with.dot/weight", "0"),
|
||||
withPair("servers/server.with.dot.without.url/weight", "0")),
|
||||
withPair("servers/server.with.dot/weight", strconv.Itoa(label.DefaultWeight)),
|
||||
withPair("servers/server.with.dot.without.url/weight", strconv.Itoa(label.DefaultWeight))),
|
||||
),
|
||||
expected: &types.Configuration{
|
||||
Backends: map[string]*types.Backend{
|
||||
|
@ -42,7 +42,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server.with.dot": {
|
||||
URL: "http://172.17.0.2:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -82,8 +82,8 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
withPair(pathBackendBufferingMemRequestBodyBytes, "2097152"),
|
||||
withPair(pathBackendBufferingRetryExpression, "IsNetworkError() && Attempts() <= 2"),
|
||||
withPair("servers/server1/url", "http://172.17.0.2:80"),
|
||||
withPair("servers/server1/weight", "0"),
|
||||
withPair("servers/server2/weight", "0")),
|
||||
withPair("servers/server1/weight", strconv.Itoa(label.DefaultWeight)),
|
||||
withPair("servers/server2/weight", strconv.Itoa(label.DefaultWeight))),
|
||||
frontend("frontend1",
|
||||
withPair(pathFrontendBackend, "backend1"),
|
||||
withPair(pathFrontendPriority, "6"),
|
||||
|
@ -148,7 +148,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server1": {
|
||||
URL: "http://172.17.0.2:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: &types.CircuitBreaker{
|
||||
|
@ -2012,7 +2012,7 @@ func TestProviderGetServers(t *testing.T) {
|
|||
expected: map[string]types.Server{
|
||||
"server1": {
|
||||
URL: "http://172.17.0.2:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -2027,7 +2027,7 @@ func TestProviderGetServers(t *testing.T) {
|
|||
expected: map[string]types.Server{
|
||||
"server1": {
|
||||
URL: "http://172.17.0.2:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"server2": {
|
||||
URL: "http://172.17.0.3:80",
|
||||
|
|
|
@ -17,19 +17,21 @@ const (
|
|||
|
||||
// Default values
|
||||
const (
|
||||
DefaultWeight = "0" // TODO [breaking] use int value
|
||||
DefaultWeightInt = 0 // TODO rename to DefaultWeight
|
||||
DefaultWeight = 1
|
||||
DefaultProtocol = "http"
|
||||
DefaultPassHostHeader = "true" // TODO [breaking] use bool value
|
||||
DefaultPassHostHeaderBool = true // TODO rename to DefaultPassHostHeader
|
||||
DefaultPassHostHeader = true
|
||||
DefaultPassTLSCert = false
|
||||
DefaultFrontendPriority = "0" // TODO [breaking] int value
|
||||
DefaultFrontendPriorityInt = 0 // TODO rename to DefaultFrontendPriority
|
||||
DefaultFrontendPriority = 0
|
||||
DefaultCircuitBreakerExpression = "NetworkErrorRatio() > 1"
|
||||
DefaultBackendLoadBalancerMethod = "wrr"
|
||||
DefaultBackendMaxconnExtractorFunc = "request.host"
|
||||
DefaultBackendLoadbalancerStickinessCookieName = ""
|
||||
DefaultBackendHealthCheckPort = 0
|
||||
|
||||
// TODO need to be remove in extra-service-fabric
|
||||
DefaultWeightInt = 1 // Deprecated
|
||||
DefaultPassHostHeaderBool = true // Deprecated
|
||||
DefaultFrontendPriorityInt = 0 // Deprecated
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
|
@ -602,17 +602,17 @@ func TestGetFuncString(t *testing.T) {
|
|||
}{
|
||||
{
|
||||
labels: nil,
|
||||
labelName: TraefikWeight,
|
||||
defaultValue: DefaultWeight,
|
||||
expected: "0",
|
||||
labelName: TraefikProtocol,
|
||||
defaultValue: DefaultProtocol,
|
||||
expected: "http",
|
||||
},
|
||||
{
|
||||
labels: map[string]string{
|
||||
TraefikWeight: "10",
|
||||
TraefikProtocol: "https",
|
||||
},
|
||||
labelName: TraefikWeight,
|
||||
defaultValue: DefaultWeight,
|
||||
expected: "10",
|
||||
labelName: TraefikProtocol,
|
||||
defaultValue: DefaultProtocol,
|
||||
expected: "https",
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -43,9 +43,9 @@ func (p *Provider) buildConfigurationV2(applications *marathon.Applications) *ty
|
|||
"getSegmentNameSuffix": getSegmentNameSuffix,
|
||||
"getFrontendRule": p.getFrontendRule,
|
||||
"getFrontendName": p.getFrontendName,
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getPassTLSCert": label.GetFuncBool(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getEntryPoints": label.GetFuncSliceString(label.TraefikFrontendEntryPoints),
|
||||
"getBasicAuth": label.GetFuncSliceString(label.TraefikFrontendAuthBasic),
|
||||
"getRedirect": label.GetRedirect,
|
||||
|
@ -339,7 +339,7 @@ func (p *Provider) getServer(app appData, task marathon.Task) (string, *types.Se
|
|||
|
||||
return serverName, &types.Server{
|
||||
URL: fmt.Sprintf("%s://%s:%v", protocol, host, port),
|
||||
Weight: label.GetIntValue(app.SegmentLabels, label.TraefikWeight, label.DefaultWeightInt),
|
||||
Weight: label.GetIntValue(app.SegmentLabels, label.TraefikWeight, label.DefaultWeight),
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-app-taskID": {
|
||||
URL: "http://localhost:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
@ -119,7 +119,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-app-taskID": {
|
||||
URL: "http://localhost:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
MaxConn: nil,
|
||||
|
@ -152,7 +152,7 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-app-taskID": {
|
||||
URL: "http://localhost:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -420,11 +420,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-foo-v000-taskID-service-main": {
|
||||
URL: "http://localhost:8080",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"server-foo-v001-taskID-service-main": {
|
||||
URL: "http://localhost:8081",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -503,7 +503,7 @@ func TestBuildConfigurationSegments(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-app-taskID-service-web": {
|
||||
URL: "http://localhost:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
MaxConn: &types.MaxConn{
|
||||
|
@ -515,7 +515,7 @@ func TestBuildConfigurationSegments(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-app-taskID-service-admin": {
|
||||
URL: "http://localhost:81",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
MaxConn: &types.MaxConn{
|
||||
|
@ -1278,15 +1278,15 @@ func TestGetServers(t *testing.T) {
|
|||
expected: map[string]types.Server{
|
||||
"server-A": {
|
||||
URL: "http://1.1.1.1:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"server-B": {
|
||||
URL: "http://1.1.1.2:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"server-C": {
|
||||
URL: "http://1.1.1.3:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -27,7 +27,7 @@ func (p *Provider) buildConfigurationV1(applications *marathon.Applications) *ty
|
|||
"getPort": getPortV1,
|
||||
"getServers": p.getServersV1,
|
||||
|
||||
"getWeight": getFuncIntServiceV1(label.SuffixWeight, label.DefaultWeightInt),
|
||||
"getWeight": getFuncIntServiceV1(label.SuffixWeight, label.DefaultWeight),
|
||||
"getProtocol": getFuncStringServiceV1(label.SuffixProtocol, label.DefaultProtocol),
|
||||
"hasCircuitBreakerLabels": hasFuncV1(label.TraefikBackendCircuitBreakerExpression),
|
||||
"getCircuitBreakerExpression": getFuncStringV1(label.TraefikBackendCircuitBreakerExpression, label.DefaultCircuitBreakerExpression),
|
||||
|
@ -46,9 +46,9 @@ func (p *Provider) buildConfigurationV1(applications *marathon.Applications) *ty
|
|||
// Frontend functions
|
||||
"getServiceNames": getServiceNamesV1,
|
||||
"getServiceNameSuffix": getSegmentNameSuffix,
|
||||
"getPassHostHeader": getFuncBoolServiceV1(label.SuffixFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPassHostHeader": getFuncBoolServiceV1(label.SuffixFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getPassTLSCert": getFuncBoolServiceV1(label.SuffixFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getPriority": getFuncIntServiceV1(label.SuffixFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPriority": getFuncIntServiceV1(label.SuffixFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getEntryPoints": getFuncSliceStringServiceV1(label.SuffixFrontendEntryPoints),
|
||||
"getFrontendRule": p.getFrontendRuleV1,
|
||||
"getFrontendName": p.getFrontendNameV1,
|
||||
|
@ -323,7 +323,7 @@ func (p *Provider) getServersV1(application marathon.Application, serviceName st
|
|||
serverName := provider.Normalize("server-" + task.ID + getSegmentNameSuffix(serviceName))
|
||||
servers[serverName] = types.Server{
|
||||
URL: fmt.Sprintf("%s://%s:%v", protocol, host, port),
|
||||
Weight: label.GetIntValue(labels, getLabelNameV1(serviceName, label.SuffixWeight), label.DefaultWeightInt),
|
||||
Weight: label.GetIntValue(labels, getLabelNameV1(serviceName, label.SuffixWeight), label.DefaultWeight),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ func TestBuildConfigurationV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-task": {
|
||||
URL: "http://localhost:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
@ -112,7 +112,7 @@ func TestBuildConfigurationV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-task": {
|
||||
URL: "http://localhost:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
MaxConn: nil,
|
||||
|
@ -143,7 +143,7 @@ func TestBuildConfigurationV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-task": {
|
||||
URL: "http://localhost:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -306,7 +306,7 @@ func TestBuildConfigurationServicesV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-task-service-web": {
|
||||
URL: "http://localhost:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
MaxConn: &types.MaxConn{
|
||||
|
@ -318,7 +318,7 @@ func TestBuildConfigurationServicesV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-task-service-admin": {
|
||||
URL: "http://localhost:81",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
MaxConn: &types.MaxConn{
|
||||
|
|
|
@ -39,8 +39,8 @@ func (p *Provider) buildConfigurationV2(tasks []state.Task) *types.Configuration
|
|||
"getFrontEndName": getFrontendName,
|
||||
"getEntryPoints": label.GetFuncSliceString(label.TraefikFrontendEntryPoints),
|
||||
"getBasicAuth": label.GetFuncSliceString(label.TraefikFrontendAuthBasic),
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getPassTLSCert": label.GetFuncBool(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getFrontendRule": p.getFrontendRule,
|
||||
"getRedirect": label.GetRedirect,
|
||||
|
@ -184,7 +184,7 @@ func (p *Provider) getServers(tasks []taskData) map[string]types.Server {
|
|||
serverName := "server-" + getID(task)
|
||||
servers[serverName] = types.Server{
|
||||
URL: fmt.Sprintf("%s://%s:%s", protocol, host, port),
|
||||
Weight: getIntValue(task.TraefikLabels, label.TraefikWeight, label.DefaultWeightInt, math.MaxInt32),
|
||||
Weight: getIntValue(task.TraefikLabels, label.TraefikWeight, label.DefaultWeight, math.MaxInt32),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,11 +90,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-ID1": {
|
||||
URL: "http://10.10.10.10:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"server-ID2": {
|
||||
URL: "http://10.10.10.11:81",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -102,11 +102,11 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-ID3": {
|
||||
URL: "http://20.10.10.10:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"server-ID4": {
|
||||
URL: "http://20.10.10.11:81",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -617,7 +617,7 @@ func TestGetServers(t *testing.T) {
|
|||
expected: map[string]types.Server{
|
||||
"server-ID1": {
|
||||
URL: "http://10.10.10.10:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"server-ID2": {
|
||||
URL: "http://10.10.10.11:81",
|
||||
|
|
|
@ -24,7 +24,7 @@ func (p *Provider) buildConfigurationV1(tasks []state.Task) *types.Configuration
|
|||
"getBackendName": getBackendNameV1,
|
||||
"getHost": p.getHostV1,
|
||||
"getProtocol": getFuncApplicationStringValueV1(label.TraefikProtocol, label.DefaultProtocol),
|
||||
"getWeight": getFuncApplicationIntValueV1(label.TraefikWeight, label.DefaultWeightInt),
|
||||
"getWeight": getFuncApplicationIntValueV1(label.TraefikWeight, label.DefaultWeight),
|
||||
"getBackend": getBackendV1,
|
||||
"getPort": p.getPort,
|
||||
|
||||
|
@ -33,8 +33,8 @@ func (p *Provider) buildConfigurationV1(tasks []state.Task) *types.Configuration
|
|||
"getFrontEndName": getFrontendNameV1,
|
||||
"getEntryPoints": getFuncSliceStringValueV1(label.TraefikFrontendEntryPoints),
|
||||
"getBasicAuth": getFuncSliceStringValueV1(label.TraefikFrontendAuthBasic),
|
||||
"getPriority": getFuncIntValueV1(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPassHostHeader": getFuncBoolValueV1(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPriority": getFuncIntValueV1(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getPassHostHeader": getFuncBoolValueV1(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getFrontendRule": p.getFrontendRuleV1,
|
||||
}
|
||||
|
||||
|
|
|
@ -86,11 +86,11 @@ func TestBuildConfigurationV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-ID1": {
|
||||
URL: "http://10.10.10.10:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"server-ID2": {
|
||||
URL: "http://10.10.10.11:81",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -98,11 +98,11 @@ func TestBuildConfigurationV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-ID3": {
|
||||
URL: "http://20.10.10.10:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
"server-ID4": {
|
||||
URL: "http://20.10.10.11:81",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -29,8 +29,8 @@ func (p *Provider) buildConfigurationV2(services []rancherData) *types.Configura
|
|||
// Frontend functions
|
||||
"getBackendName": getBackendName,
|
||||
"getFrontendRule": p.getFrontendRule,
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPriority": label.GetFuncInt(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getPassHostHeader": label.GetFuncBool(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getPassTLSCert": label.GetFuncBool(label.TraefikFrontendPassTLSCert, label.DefaultPassTLSCert),
|
||||
"getEntryPoints": label.GetFuncSliceString(label.TraefikFrontendEntryPoints),
|
||||
"getBasicAuth": label.GetFuncSliceString(label.TraefikFrontendAuthBasic),
|
||||
|
@ -170,7 +170,7 @@ func getServers(service rancherData) map[string]types.Server {
|
|||
|
||||
protocol := label.GetStringValue(service.SegmentLabels, label.TraefikProtocol, label.DefaultProtocol)
|
||||
port := label.GetStringValue(service.SegmentLabels, label.TraefikPort, "")
|
||||
weight := label.GetIntValue(service.SegmentLabels, label.TraefikWeight, label.DefaultWeightInt)
|
||||
weight := label.GetIntValue(service.SegmentLabels, label.TraefikWeight, label.DefaultWeight)
|
||||
|
||||
serverName := "server-" + strconv.Itoa(index)
|
||||
servers[serverName] = types.Server{
|
||||
|
|
|
@ -454,7 +454,7 @@ func TestProviderBuildConfiguration(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-0": {
|
||||
URL: "http://127.0.0.1:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
@ -855,7 +855,7 @@ func TestGetServers(t *testing.T) {
|
|||
expected: map[string]types.Server{
|
||||
"server-0": {
|
||||
URL: "http://10.10.10.0:",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -18,7 +18,7 @@ func (p *Provider) buildConfigurationV1(services []rancherData) *types.Configura
|
|||
// Backend functions
|
||||
"getPort": getFuncStringV1(label.TraefikPort, ""),
|
||||
"getProtocol": getFuncStringV1(label.TraefikProtocol, label.DefaultProtocol),
|
||||
"getWeight": getFuncIntV1(label.TraefikWeight, label.DefaultWeightInt),
|
||||
"getWeight": getFuncIntV1(label.TraefikWeight, label.DefaultWeight),
|
||||
"hasCircuitBreakerLabel": hasFuncV1(label.TraefikBackendCircuitBreakerExpression),
|
||||
"getCircuitBreakerExpression": getFuncStringV1(label.TraefikBackendCircuitBreakerExpression, label.DefaultCircuitBreakerExpression),
|
||||
"hasLoadBalancerLabel": hasLoadBalancerLabel,
|
||||
|
@ -33,8 +33,8 @@ func (p *Provider) buildConfigurationV1(services []rancherData) *types.Configura
|
|||
// Frontend functions
|
||||
"getBackend": getBackendNameV1,
|
||||
"getFrontendRule": p.getFrontendRuleV1,
|
||||
"getPriority": getFuncIntV1(label.TraefikFrontendPriority, label.DefaultFrontendPriorityInt),
|
||||
"getPassHostHeader": getFuncBoolV1(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeaderBool),
|
||||
"getPriority": getFuncIntV1(label.TraefikFrontendPriority, label.DefaultFrontendPriority),
|
||||
"getPassHostHeader": getFuncBoolV1(label.TraefikFrontendPassHostHeader, label.DefaultPassHostHeader),
|
||||
"getEntryPoints": getFuncSliceStringV1(label.TraefikFrontendEntryPoints),
|
||||
"getBasicAuth": getFuncSliceStringV1(label.TraefikFrontendAuthBasic),
|
||||
"hasRedirect": hasRedirect,
|
||||
|
|
|
@ -149,7 +149,7 @@ func TestProviderBuildConfigurationV1(t *testing.T) {
|
|||
Servers: map[string]types.Server{
|
||||
"server-0": {
|
||||
URL: "http://127.0.0.1:80",
|
||||
Weight: 0,
|
||||
Weight: label.DefaultWeight,
|
||||
},
|
||||
},
|
||||
CircuitBreaker: nil,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue