refactor(ecs): add hasLoadBalancerLabel function.
This commit is contained in:
parent
722ea28e3a
commit
07a6d48a27
3 changed files with 12 additions and 3 deletions
|
@ -17,6 +17,7 @@ func (p *Provider) buildConfiguration(services map[string][]ecsInstance) (*types
|
|||
"filterFrontends": filterFrontends,
|
||||
"getFrontendRule": p.getFrontendRule,
|
||||
"getBasicAuth": getFuncSliceString(label.TraefikFrontendAuthBasic),
|
||||
"hasLoadBalancerLabel": hasLoadBalancerLabel,
|
||||
"getLoadBalancerMethod": getFuncFirstStringValue(label.TraefikBackendLoadBalancerMethod, label.DefaultBackendLoadBalancerMethod),
|
||||
"getSticky": getSticky,
|
||||
"hasStickinessLabel": getFuncFirstBoolValue(label.TraefikBackendLoadBalancerStickiness, false),
|
||||
|
@ -77,6 +78,15 @@ func filterFrontends(instances []ecsInstance) []ecsInstance {
|
|||
}, instances).([]ecsInstance)
|
||||
}
|
||||
|
||||
func hasLoadBalancerLabel(instances []ecsInstance) bool {
|
||||
method := hasFirst(instances, label.TraefikBackendLoadBalancerMethod)
|
||||
sticky := hasFirst(instances, label.TraefikBackendLoadBalancerSticky)
|
||||
stickiness := hasFirst(instances, label.TraefikBackendLoadBalancerStickiness)
|
||||
cookieName := hasFirst(instances, label.TraefikBackendLoadBalancerStickinessCookieName)
|
||||
|
||||
return method || sticky || stickiness || cookieName
|
||||
}
|
||||
|
||||
// Label functions
|
||||
|
||||
func getFuncStringValue(labelName string, defaultValue string) func(i ecsInstance) string {
|
||||
|
|
|
@ -105,9 +105,6 @@ func TestBuildConfiguration(t *testing.T) {
|
|||
},
|
||||
},
|
||||
"backend-testing": {
|
||||
LoadBalancer: &types.LoadBalancer{
|
||||
Method: "wrr",
|
||||
},
|
||||
HealthCheck: &types.HealthCheck{
|
||||
Path: "/health",
|
||||
Interval: "1s",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue