diff --git a/provider/ecs/config_test.go b/provider/ecs/config_test.go index 899ab28e6..da663c553 100644 --- a/provider/ecs/config_test.go +++ b/provider/ecs/config_test.go @@ -12,7 +12,6 @@ import ( ) func TestBuildConfiguration(t *testing.T) { - provider := &Provider{} tests := []struct { desc string services map[string][]ecsInstance @@ -134,6 +133,9 @@ func TestBuildConfiguration(t *testing.T) { for _, test := range tests { t.Run(test.desc, func(t *testing.T) { + t.Parallel() + + provider := &Provider{} got, err := provider.buildConfiguration(test.services) assert.Equal(t, test.err, err) assert.Equal(t, test.expected, got) @@ -317,6 +319,8 @@ func TestChunkedTaskArns(t *testing.T) { for _, test := range tests { test := test t.Run(test.desc, func(t *testing.T) { + t.Parallel() + var tasks []*string for v := 0; v < test.count; v++ { tasks = append(tasks, &testVal) @@ -331,7 +335,6 @@ func TestChunkedTaskArns(t *testing.T) { assert.Equal(t, test.expectedLengths, outCount, "Chunking %d elements", test.count) }) - } } @@ -352,6 +355,7 @@ func TestGetHost(t *testing.T) { test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() + actual := getHost(test.instanceInfo) assert.Equal(t, test.expected, actual) }) @@ -389,6 +393,7 @@ func TestGetPort(t *testing.T) { test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() + actual := getPort(test.instanceInfo) assert.Equal(t, test.expected, actual) }) @@ -464,6 +469,7 @@ func TestGetFuncSliceString(t *testing.T) { test := test t.Run(test.desc, func(t *testing.T) { t.Parallel() + actual := getFuncSliceString(label.TraefikFrontendEntryPoints)(test.instanceInfo) assert.Equal(t, test.expected, actual) }) diff --git a/templates/ecs.tmpl b/templates/ecs.tmpl index 7e280c17c..9f92a278a 100644 --- a/templates/ecs.tmpl +++ b/templates/ecs.tmpl @@ -1,37 +1,47 @@ -[backends]{{range $serviceName, $instances := .Services}} - [backends.backend-{{ $serviceName }}.loadbalancer] +[backends] +{{range $serviceName, $instances := .Services}} + + [backends.backend-{{ $serviceName }}.loadBalancer] method = "{{ getLoadBalancerMethod $instances}}" sticky = {{ getSticky $instances}} - {{if hasStickinessLabel $instances}} - [backends.backend-{{ $serviceName }}.loadbalancer.stickiness] + {{if hasStickinessLabel $instances}} + [backends.backend-{{ $serviceName }}.loadBalancer.stickiness] cookieName = "{{getStickinessCookieName $instances}}" {{end}} - {{ if hasHealthCheckLabels $instances }} - [backends.backend-{{ $serviceName }}.healthcheck] - path = "{{getHealthCheckPath $instances }}" - interval = "{{getHealthCheckInterval $instances }}" - {{end}} - {{range $index, $i := $instances}} - [backends.backend-{{ $i.Name }}.servers.server-{{ $i.Name }}{{ $i.ID }}] - url = "{{ getProtocol $i }}://{{ getHost $i }}:{{ getPort $i }}" - weight = {{ getWeight $i}} + {{ if hasHealthCheckLabels $instances }} + [backends.backend-{{ $serviceName }}.healthCheck] + path = "{{getHealthCheckPath $instances }}" + interval = "{{getHealthCheckInterval $instances }}" {{end}} + + {{range $index, $instance := $instances}} + [backends.backend-{{ $instance.Name }}.servers.server-{{ $instance.Name }}{{ $instance.ID }}] + url = "{{ getProtocol $instance }}://{{ getHost $instance }}:{{ getPort $instance }}" + weight = {{ getWeight $instance}} + {{end}} + {{end}} -[frontends]{{range $serviceName, $instances := .Services}} - {{range filterFrontends $instances}} - [frontends.frontend-{{ $serviceName }}] - backend = "backend-{{ $serviceName }}" - passHostHeader = {{ getPassHostHeader .}} - priority = {{ getPriority .}} - entryPoints = [{{range getEntryPoints .}} +[frontends] +{{range $serviceName, $instances := .Services}} +{{range filterFrontends $instances}} + + [frontends.frontend-{{ $serviceName }}] + backend = "backend-{{ $serviceName }}" + priority = {{ getPriority .}} + passHostHeader = {{ getPassHostHeader .}} + + entryPoints = [{{range getEntryPoints .}} "{{.}}", - {{end}}] - basicAuth = [{{range getBasicAuth .}} + {{end}}] + + basicAuth = [{{range getBasicAuth .}} "{{.}}", - {{end}}] + {{end}}] + [frontends.frontend-{{ $serviceName }}.routes.route-frontend-{{ $serviceName }}] rule = "{{getFrontendRule .}}" - {{end}} + +{{end}} {{end}} \ No newline at end of file