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

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

View file

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

View file

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

View file

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