Factorize labels
* refactor(accesslog): factorize file name. * traefik.frontend.rule * traefik.frontend.value * traefik.backend.circuitbreaker.expression * traefik.enable * traefik.backend.loadbalancer.method * traefik.backend.loadbalancer.sticky * traefik.backend.maxconn.amount * traefik.backend.maxconn.extractorfunc * traefik.port * traefik.tags * traefik.backend * traefik.weight * traefik.domain * traefik.protocol * traefik.frontend.passHostHeader * traefik.frontend.whitelistSourceRange * traefik.frontend.priority * traefik.frontend.entryPoints * traefik.frontend.auth.basic * traefik.backend.id * traefik.backend.circuitbreaker * traefik.frontend.rule.type * traefik.portIndex * refactor(docker): specific labels * refactor(rancher): specific labels * traefik.backend.healthcheck.* * refactor(providers): factorize labels.
This commit is contained in:
parent
2e84b1e556
commit
d653a348b1
20 changed files with 390 additions and 330 deletions
|
@ -23,7 +23,7 @@ func TestDockerGetFrontendName(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.rule": "Headers:User-Agent,bat/0.1.0",
|
||||
types.LabelFrontendRule: "Headers:User-Agent,bat/0.1.0",
|
||||
})),
|
||||
expected: "Headers-User-Agent-bat-0-1-0",
|
||||
},
|
||||
|
@ -36,19 +36,19 @@ func TestDockerGetFrontendName(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.rule": "Host:foo.bar",
|
||||
types.LabelFrontendRule: "Host:foo.bar",
|
||||
})),
|
||||
expected: "Host-foo-bar",
|
||||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.rule": "Path:/test",
|
||||
types.LabelFrontendRule: "Path:/test",
|
||||
})),
|
||||
expected: "Path-test",
|
||||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.rule": "PathPrefix:/test2",
|
||||
types.LabelFrontendRule: "PathPrefix:/test2",
|
||||
})),
|
||||
expected: "PathPrefix-test2",
|
||||
},
|
||||
|
@ -85,7 +85,7 @@ func TestDockerGetFrontendRule(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.rule": "Host:foo.bar",
|
||||
types.LabelFrontendRule: "Host:foo.bar",
|
||||
})),
|
||||
expected: "Host:foo.bar",
|
||||
}, {
|
||||
|
@ -97,7 +97,7 @@ func TestDockerGetFrontendRule(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.rule": "Path:/test",
|
||||
types.LabelFrontendRule: "Path:/test",
|
||||
})),
|
||||
expected: "Path:/test",
|
||||
},
|
||||
|
@ -134,7 +134,7 @@ func TestDockerGetBackend(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.backend": "foobar",
|
||||
types.LabelBackend: "foobar",
|
||||
})),
|
||||
expected: "foobar",
|
||||
},
|
||||
|
@ -173,7 +173,7 @@ func TestDockerGetIPAddress(t *testing.T) {
|
|||
{
|
||||
container: containerJSON(
|
||||
labels(map[string]string{
|
||||
"traefik.docker.network": "testnet",
|
||||
labelDockerNetwork: "testnet",
|
||||
}),
|
||||
withNetwork("testnet", ipv4("10.11.12.13")),
|
||||
),
|
||||
|
@ -182,7 +182,7 @@ func TestDockerGetIPAddress(t *testing.T) {
|
|||
{
|
||||
container: containerJSON(
|
||||
labels(map[string]string{
|
||||
"traefik.docker.network": "testnet2",
|
||||
labelDockerNetwork: "testnet2",
|
||||
}),
|
||||
withNetwork("testnet", ipv4("10.11.12.13")),
|
||||
withNetwork("testnet2", ipv4("10.11.12.14")),
|
||||
|
@ -237,13 +237,13 @@ func TestDockerGetPort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.port": "8080",
|
||||
types.LabelPort: "8080",
|
||||
})),
|
||||
expected: "8080",
|
||||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.port": "8080",
|
||||
types.LabelPort: "8080",
|
||||
}), ports(nat.PortMap{
|
||||
"80/tcp": {},
|
||||
})),
|
||||
|
@ -251,7 +251,7 @@ func TestDockerGetPort(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.port": "8080",
|
||||
types.LabelPort: "8080",
|
||||
}), ports(nat.PortMap{
|
||||
"8080/tcp": {},
|
||||
"80/tcp": {},
|
||||
|
@ -285,7 +285,7 @@ func TestDockerGetWeight(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.weight": "10",
|
||||
types.LabelWeight: "10",
|
||||
})),
|
||||
expected: "10",
|
||||
},
|
||||
|
@ -316,7 +316,7 @@ func TestDockerGetDomain(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.domain": "foo.bar",
|
||||
types.LabelDomain: "foo.bar",
|
||||
})),
|
||||
expected: "foo.bar",
|
||||
},
|
||||
|
@ -349,7 +349,7 @@ func TestDockerGetProtocol(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.protocol": "https",
|
||||
types.LabelProtocol: "https",
|
||||
})),
|
||||
expected: "https",
|
||||
},
|
||||
|
@ -380,7 +380,7 @@ func TestDockerGetPassHostHeader(t *testing.T) {
|
|||
},
|
||||
{
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.passHostHeader": "false",
|
||||
types.LabelFrontendPassHostHeader: "false",
|
||||
})),
|
||||
expected: "false",
|
||||
},
|
||||
|
@ -414,14 +414,14 @@ func TestDockerGetWhitelistSourceRange(t *testing.T) {
|
|||
{
|
||||
desc: "whitelist-label with empty string",
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.whitelistSourceRange": "",
|
||||
types.LabelTraefikFrontendWhitelistSourceRange: "",
|
||||
})),
|
||||
expected: nil,
|
||||
},
|
||||
{
|
||||
desc: "whitelist-label with IPv4 mask",
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.whitelistSourceRange": "1.2.3.4/16",
|
||||
types.LabelTraefikFrontendWhitelistSourceRange: "1.2.3.4/16",
|
||||
})),
|
||||
expected: []string{
|
||||
"1.2.3.4/16",
|
||||
|
@ -430,7 +430,7 @@ func TestDockerGetWhitelistSourceRange(t *testing.T) {
|
|||
{
|
||||
desc: "whitelist-label with IPv6 mask",
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.whitelistSourceRange": "fe80::/16",
|
||||
types.LabelTraefikFrontendWhitelistSourceRange: "fe80::/16",
|
||||
})),
|
||||
expected: []string{
|
||||
"fe80::/16",
|
||||
|
@ -439,7 +439,7 @@ func TestDockerGetWhitelistSourceRange(t *testing.T) {
|
|||
{
|
||||
desc: "whitelist-label with multiple masks",
|
||||
container: containerJSON(labels(map[string]string{
|
||||
"traefik.frontend.whitelistSourceRange": "1.1.1.1/24, 1234:abcd::42/32",
|
||||
types.LabelTraefikFrontendWhitelistSourceRange: "1.1.1.1/24, 1234:abcd::42/32",
|
||||
})),
|
||||
expected: []string{
|
||||
"1.1.1.1/24",
|
||||
|
@ -576,7 +576,7 @@ func TestDockerTraefikFilter(t *testing.T) {
|
|||
},
|
||||
Config: &container.Config{
|
||||
Labels: map[string]string{
|
||||
"traefik.enable": "false",
|
||||
types.LabelEnable: "false",
|
||||
},
|
||||
},
|
||||
NetworkSettings: &docker.NetworkSettings{
|
||||
|
@ -600,7 +600,7 @@ func TestDockerTraefikFilter(t *testing.T) {
|
|||
},
|
||||
Config: &container.Config{
|
||||
Labels: map[string]string{
|
||||
"traefik.frontend.rule": "Host:foo.bar",
|
||||
types.LabelFrontendRule: "Host:foo.bar",
|
||||
},
|
||||
},
|
||||
NetworkSettings: &docker.NetworkSettings{
|
||||
|
@ -665,7 +665,7 @@ func TestDockerTraefikFilter(t *testing.T) {
|
|||
},
|
||||
Config: &container.Config{
|
||||
Labels: map[string]string{
|
||||
"traefik.port": "80",
|
||||
types.LabelPort: "80",
|
||||
},
|
||||
},
|
||||
NetworkSettings: &docker.NetworkSettings{
|
||||
|
@ -690,7 +690,7 @@ func TestDockerTraefikFilter(t *testing.T) {
|
|||
},
|
||||
Config: &container.Config{
|
||||
Labels: map[string]string{
|
||||
"traefik.enable": "true",
|
||||
types.LabelEnable: "true",
|
||||
},
|
||||
},
|
||||
NetworkSettings: &docker.NetworkSettings{
|
||||
|
@ -714,7 +714,7 @@ func TestDockerTraefikFilter(t *testing.T) {
|
|||
},
|
||||
Config: &container.Config{
|
||||
Labels: map[string]string{
|
||||
"traefik.enable": "anything",
|
||||
types.LabelEnable: "anything",
|
||||
},
|
||||
},
|
||||
NetworkSettings: &docker.NetworkSettings{
|
||||
|
@ -738,7 +738,7 @@ func TestDockerTraefikFilter(t *testing.T) {
|
|||
},
|
||||
Config: &container.Config{
|
||||
Labels: map[string]string{
|
||||
"traefik.frontend.rule": "Host:foo.bar",
|
||||
types.LabelFrontendRule: "Host:foo.bar",
|
||||
},
|
||||
},
|
||||
NetworkSettings: &docker.NetworkSettings{
|
||||
|
@ -782,7 +782,7 @@ func TestDockerTraefikFilter(t *testing.T) {
|
|||
},
|
||||
Config: &container.Config{
|
||||
Labels: map[string]string{
|
||||
"traefik.enable": "true",
|
||||
types.LabelEnable: "true",
|
||||
},
|
||||
},
|
||||
NetworkSettings: &docker.NetworkSettings{
|
||||
|
@ -806,7 +806,7 @@ func TestDockerTraefikFilter(t *testing.T) {
|
|||
},
|
||||
Config: &container.Config{
|
||||
Labels: map[string]string{
|
||||
"traefik.enable": "true",
|
||||
types.LabelEnable: "true",
|
||||
},
|
||||
},
|
||||
NetworkSettings: &docker.NetworkSettings{
|
||||
|
@ -829,8 +829,8 @@ func TestDockerTraefikFilter(t *testing.T) {
|
|||
},
|
||||
Config: &container.Config{
|
||||
Labels: map[string]string{
|
||||
"traefik.enable": "true",
|
||||
"traefik.frontend.rule": "Host:i.love.this.host",
|
||||
types.LabelEnable: "true",
|
||||
types.LabelFrontendRule: "Host:i.love.this.host",
|
||||
},
|
||||
},
|
||||
NetworkSettings: &docker.NetworkSettings{
|
||||
|
@ -912,9 +912,9 @@ func TestDockerLoadDockerConfig(t *testing.T) {
|
|||
containerJSON(
|
||||
name("test1"),
|
||||
labels(map[string]string{
|
||||
"traefik.backend": "foobar",
|
||||
"traefik.frontend.entryPoints": "http,https",
|
||||
"traefik.frontend.auth.basic": "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/,test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
|
||||
types.LabelBackend: "foobar",
|
||||
types.LabelFrontendEntryPoints: "http,https",
|
||||
types.LabelFrontendAuthBasic: "test:$apr1$H6uskkkW$IgXLP6ewTrSuBkTrqE8wj/,test2:$apr1$d9hr9HBB$4HxwgUir3HP4EsggP/QNo0",
|
||||
}),
|
||||
ports(nat.PortMap{
|
||||
"80/tcp": {},
|
||||
|
@ -924,7 +924,7 @@ func TestDockerLoadDockerConfig(t *testing.T) {
|
|||
containerJSON(
|
||||
name("test2"),
|
||||
labels(map[string]string{
|
||||
"traefik.backend": "foobar",
|
||||
types.LabelBackend: "foobar",
|
||||
}),
|
||||
ports(nat.PortMap{
|
||||
"80/tcp": {},
|
||||
|
@ -977,12 +977,12 @@ func TestDockerLoadDockerConfig(t *testing.T) {
|
|||
containerJSON(
|
||||
name("test1"),
|
||||
labels(map[string]string{
|
||||
"traefik.backend": "foobar",
|
||||
"traefik.frontend.entryPoints": "http,https",
|
||||
"traefik.backend.maxconn.amount": "1000",
|
||||
"traefik.backend.maxconn.extractorfunc": "somethingelse",
|
||||
"traefik.backend.loadbalancer.method": "drr",
|
||||
"traefik.backend.circuitbreaker.expression": "NetworkErrorRatio() > 0.5",
|
||||
types.LabelBackend: "foobar",
|
||||
types.LabelFrontendEntryPoints: "http,https",
|
||||
types.LabelBackendMaxconnAmount: "1000",
|
||||
types.LabelBackendMaxconnExtractorfunc: "somethingelse",
|
||||
types.LabelBackendLoadbalancerMethod: "drr",
|
||||
types.LabelBackendCircuitbreakerExpression: "NetworkErrorRatio() > 0.5",
|
||||
}),
|
||||
ports(nat.PortMap{
|
||||
"80/tcp": {},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue