mirror of
https://github.com/containous/traefik.git
synced 2024-12-23 17:34:13 +03:00
refactor(ecs): template readability.
This commit is contained in:
parent
7e5c258266
commit
f195ef27f3
@ -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)
|
||||
})
|
||||
|
@ -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]
|
||||
[backends.backend-{{ $serviceName }}.loadBalancer.stickiness]
|
||||
cookieName = "{{getStickinessCookieName $instances}}"
|
||||
{{end}}
|
||||
|
||||
{{ if hasHealthCheckLabels $instances }}
|
||||
[backends.backend-{{ $serviceName }}.healthcheck]
|
||||
[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}}
|
||||
{{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]
|
||||
{{range $serviceName, $instances := .Services}}
|
||||
{{range filterFrontends $instances}}
|
||||
|
||||
[frontends.frontend-{{ $serviceName }}]
|
||||
backend = "backend-{{ $serviceName }}"
|
||||
passHostHeader = {{ getPassHostHeader .}}
|
||||
priority = {{ getPriority .}}
|
||||
passHostHeader = {{ getPassHostHeader .}}
|
||||
|
||||
entryPoints = [{{range getEntryPoints .}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
basicAuth = [{{range getBasicAuth .}}
|
||||
"{{.}}",
|
||||
{{end}}]
|
||||
|
||||
[frontends.frontend-{{ $serviceName }}.routes.route-frontend-{{ $serviceName }}]
|
||||
rule = "{{getFrontendRule .}}"
|
||||
{{end}}
|
||||
|
||||
{{end}}
|
||||
{{end}}
|
Loading…
Reference in New Issue
Block a user