1
0
Fork 0

Server weight zero

This commit is contained in:
Ludovic Fernandez 2018-04-11 16:30:04 +02:00 committed by Traefiker Bot
parent edbcd01fbc
commit 8168d2fdc1
84 changed files with 378 additions and 273 deletions

View file

@ -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),
}
}

View file

@ -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,

View file

@ -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,
},
},
},

View file

@ -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,

View file

@ -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, ""),

View file

@ -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",
},
}

View file

@ -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",
},
}

View file

@ -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",
},
}