Use name@provider instead of provider@name.

This commit is contained in:
Ludovic Fernandez 2019-06-21 09:54:04 +02:00 committed by Traefiker Bot
parent 1e779f7135
commit adc9a65ae3
35 changed files with 472 additions and 472 deletions

View file

@ -121,8 +121,8 @@ If you use multiple `providers` and wish to reference a middleware declared in a
image: your-docker-image image: your-docker-image
labels: labels:
# Attach file@add-foo-prefix middleware (declared in file) # Attach add-foo-prefix@file middleware (declared in file)
- "traefik.http.routers.my-container.middlewares=file@add-foo-prefix" - "traefik.http.routers.my-container.middlewares=add-foo-prefix@file"
``` ```
## Available Middlewares ## Available Middlewares

View file

@ -581,7 +581,7 @@ func CheckAccessLogFormat(c *check.C, line string, i int) {
c.Assert(results, checker.HasLen, 14) c.Assert(results, checker.HasLen, 14)
c.Assert(results[accesslog.OriginStatus], checker.Matches, `^(-|\d{3})$`) c.Assert(results[accesslog.OriginStatus], checker.Matches, `^(-|\d{3})$`)
c.Assert(results[accesslog.RequestCount], checker.Equals, fmt.Sprintf("%d", i+1)) c.Assert(results[accesslog.RequestCount], checker.Equals, fmt.Sprintf("%d", i+1))
c.Assert(results[accesslog.RouterName], checker.HasPrefix, "\"docker@rt-") c.Assert(results[accesslog.RouterName], checker.Matches, `"rt-.+@docker"`)
c.Assert(results[accesslog.ServiceURL], checker.HasPrefix, "\"http://") c.Assert(results[accesslog.ServiceURL], checker.HasPrefix, "\"http://")
c.Assert(results[accesslog.Duration], checker.Matches, `^\d+ms$`) c.Assert(results[accesslog.Duration], checker.Matches, `^\d+ms$`)
} }
@ -596,7 +596,7 @@ func checkAccessLogExactValues(c *check.C, line string, i int, v accessLogValue)
} }
c.Assert(results[accesslog.OriginStatus], checker.Equals, v.code) c.Assert(results[accesslog.OriginStatus], checker.Equals, v.code)
c.Assert(results[accesslog.RequestCount], checker.Equals, fmt.Sprintf("%d", i+1)) c.Assert(results[accesslog.RequestCount], checker.Equals, fmt.Sprintf("%d", i+1))
c.Assert(results[accesslog.RouterName], checker.Matches, `^"?(docker@)?`+v.routerName+`.*$`) c.Assert(results[accesslog.RouterName], checker.Matches, `^"?`+v.routerName+`.*(@docker)?$`)
c.Assert(results[accesslog.ServiceURL], checker.Matches, `^"?`+v.serviceURL+`.*$`) c.Assert(results[accesslog.ServiceURL], checker.Matches, `^"?`+v.serviceURL+`.*$`)
c.Assert(results[accesslog.Duration], checker.Matches, `^\d+ms$`) c.Assert(results[accesslog.Duration], checker.Matches, `^\d+ms$`)
} }

View file

@ -77,7 +77,7 @@ func (s *DockerComposeSuite) TestComposeScale(c *check.C) {
services := rtconf.Services services := rtconf.Services
c.Assert(services, checker.HasLen, 1) c.Assert(services, checker.HasLen, 1)
for k, v := range services { for k, v := range services {
c.Assert(k, checker.Equals, "docker@"+composeService+"_integrationtest"+composeProject) c.Assert(k, checker.Equals, composeService+"_integrationtest"+composeProject+"@docker")
c.Assert(v.LoadBalancer.Servers, checker.HasLen, serviceCount) c.Assert(v.LoadBalancer.Servers, checker.HasLen, serviceCount)
// We could break here, but we don't just to keep us honest. // We could break here, but we don't just to keep us honest.
} }

View file

@ -13,7 +13,7 @@ level = "DEBUG"
address = ":8001" address = ":8001"
[api] [api]
middlewares = ["file@authentication"] middlewares = ["authentication@file"]
[ping] [ping]

View file

@ -444,8 +444,8 @@ func (s *SimpleSuite) TestMultiprovider(c *check.C) {
Routers: map[string]*config.Router{ Routers: map[string]*config.Router{
"router1": { "router1": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Middlewares: []string{"file@customheader"}, Middlewares: []string{"customheader@file"},
Service: "file@service", Service: "service@file",
Rule: "PathPrefix(`/`)", Rule: "PathPrefix(`/`)",
}, },
}, },

View file

@ -1,6 +1,6 @@
{ {
"routers": { "routers": {
"kubernetescrd@default/test-crd-6b204d94623b3df4370c": { "default/test-crd-6b204d94623b3df4370c@kubernetescrd": {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
@ -8,7 +8,7 @@
"rule": "Host(`foo.com`) \u0026\u0026 PathPrefix(`/bar`)", "rule": "Host(`foo.com`) \u0026\u0026 PathPrefix(`/bar`)",
"priority": 12 "priority": 12
}, },
"kubernetescrd@default/test2-crd-23c7f4c450289ee29016": { "default/test2-crd-23c7f4c450289ee29016@kubernetescrd": {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
@ -20,19 +20,19 @@
} }
}, },
"middlewares": { "middlewares": {
"kubernetescrd@default/stripprefix": { "default/stripprefix@kubernetescrd": {
"stripPrefix": { "stripPrefix": {
"prefixes": [ "prefixes": [
"/tobestripped" "/tobestripped"
] ]
}, },
"usedBy": [ "usedBy": [
"kubernetescrd@default/test2-crd-23c7f4c450289ee29016" "default/test2-crd-23c7f4c450289ee29016@kubernetescrd"
] ]
} }
}, },
"services": { "services": {
"kubernetescrd@default/test-crd-6b204d94623b3df4370c": { "default/test-crd-6b204d94623b3df4370c@kubernetescrd": {
"loadbalancer": { "loadbalancer": {
"servers": [ "servers": [
{ {
@ -45,14 +45,14 @@
"passHostHeader": true "passHostHeader": true
}, },
"usedBy": [ "usedBy": [
"kubernetescrd@default/test-crd-6b204d94623b3df4370c" "default/test-crd-6b204d94623b3df4370c@kubernetescrd"
], ],
"serverStatus": { "serverStatus": {
"http://10.42.0.4:80": "UP", "http://10.42.0.4:80": "UP",
"http://10.42.0.5:80": "UP" "http://10.42.0.5:80": "UP"
} }
}, },
"kubernetescrd@default/test2-crd-23c7f4c450289ee29016": { "default/test2-crd-23c7f4c450289ee29016@kubernetescrd": {
"loadbalancer": { "loadbalancer": {
"servers": [ "servers": [
{ {
@ -65,7 +65,7 @@
"passHostHeader": true "passHostHeader": true
}, },
"usedBy": [ "usedBy": [
"kubernetescrd@default/test2-crd-23c7f4c450289ee29016" "default/test2-crd-23c7f4c450289ee29016@kubernetescrd"
], ],
"serverStatus": { "serverStatus": {
"http://10.42.0.4:80": "UP", "http://10.42.0.4:80": "UP",
@ -74,7 +74,7 @@
} }
}, },
"tcpRouters": { "tcpRouters": {
"kubernetescrd@default/test3-crd-673acf455cb2dab0b43a": { "default/test3-crd-673acf455cb2dab0b43a@kubernetescrd": {
"entryPoints": [ "entryPoints": [
"footcp" "footcp"
], ],
@ -83,7 +83,7 @@
} }
}, },
"tcpServices": { "tcpServices": {
"kubernetescrd@default/test3-crd-673acf455cb2dab0b43a": { "default/test3-crd-673acf455cb2dab0b43a@kubernetescrd": {
"loadbalancer": { "loadbalancer": {
"servers": [ "servers": [
{ {
@ -95,7 +95,7 @@
] ]
}, },
"usedBy": [ "usedBy": [
"kubernetescrd@default/test3-crd-673acf455cb2dab0b43a" "default/test3-crd-673acf455cb2dab0b43a@kubernetescrd"
] ]
} }
} }

View file

@ -1,13 +1,13 @@
{ {
"routers": { "routers": {
"kubernetes@whoami-test/whoami": { "whoami-test/whoami@kubernetes": {
"entryPoints": null, "entryPoints": null,
"service": "default/whoami/http", "service": "default/whoami/http",
"rule": "Host(`whoami.test`) \u0026\u0026 PathPrefix(`/whoami`)" "rule": "Host(`whoami.test`) \u0026\u0026 PathPrefix(`/whoami`)"
} }
}, },
"services": { "services": {
"kubernetes@default/whoami/http": { "default/whoami/http@kubernetes": {
"loadbalancer": { "loadbalancer": {
"servers": [ "servers": [
{ {
@ -20,7 +20,7 @@
"passHostHeader": true "passHostHeader": true
}, },
"usedBy": [ "usedBy": [
"kubernetes@whoami-test/whoami" "whoami-test/whoami@kubernetes"
], ],
"serverStatus": { "serverStatus": {
"http://10.42.0.2:80": "UP", "http://10.42.0.2:80": "UP",

View file

@ -89,7 +89,7 @@ func (s *TracingSuite) TestZipkinRateLimit(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusTooManyRequests)) err = try.GetRequest("http://127.0.0.1:8000/ratelimit", 500*time.Millisecond, try.StatusCodeIs(http.StatusTooManyRequests))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward service1/file@router1", "file@ratelimit")) err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward service1/router1@file", "ratelimit@file"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
} }
@ -117,7 +117,7 @@ func (s *TracingSuite) TestZipkinRetry(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8000/retry", 500*time.Millisecond, try.StatusCodeIs(http.StatusBadGateway)) err = try.GetRequest("http://127.0.0.1:8000/retry", 500*time.Millisecond, try.StatusCodeIs(http.StatusBadGateway))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward service2/file@router2", "file@retry")) err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("forward service2/router2@file", "retry@file"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
} }
@ -144,6 +144,6 @@ func (s *TracingSuite) TestZipkinAuth(c *check.C) {
err = try.GetRequest("http://127.0.0.1:8000/auth", 500*time.Millisecond, try.StatusCodeIs(http.StatusUnauthorized)) err = try.GetRequest("http://127.0.0.1:8000/auth", 500*time.Millisecond, try.StatusCodeIs(http.StatusUnauthorized))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("entrypoint web", "file@basic-auth")) err = try.GetRequest("http://"+s.ZipkinIP+":9411/api/v2/spans?serviceName=tracing", 20*time.Second, try.BodyContains("entrypoint web", "basic-auth@file"))
c.Assert(err, checker.IsNil) c.Assert(err, checker.IsNil)
} }

View file

@ -464,5 +464,5 @@ func getIntParam(request *http.Request, key string, defaultValue int) (int, erro
} }
func getProviderName(id string) string { func getProviderName(id string) string {
return strings.SplitN(id, ".", 2)[0] return strings.SplitN(id, "@", 2)[1]
} }

View file

@ -47,20 +47,20 @@ func TestHandlerTCP_API(t *testing.T) {
path: "/api/tcp/routers", path: "/api/tcp/routers",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@test": { "test@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar.other`)", Rule: "Host(`foo.bar.other`)",
TLS: &config.RouterTCPTLSConfig{ TLS: &config.RouterTCPTLSConfig{
Passthrough: false, Passthrough: false,
}, },
}, },
}, },
"myprovider@bar": { "bar@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
@ -77,24 +77,24 @@ func TestHandlerTCP_API(t *testing.T) {
path: "/api/tcp/routers?page=2&per_page=1", path: "/api/tcp/routers?page=2&per_page=1",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@bar": { "bar@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
"myprovider@baz": { "baz@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`toto.bar`)", Rule: "Host(`toto.bar`)",
}, },
}, },
"myprovider@test": { "test@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar.other`)", Rule: "Host(`foo.bar.other`)",
}, },
}, },
@ -108,13 +108,13 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
{ {
desc: "one TCP router by id", desc: "one TCP router by id",
path: "/api/tcp/routers/myprovider@bar", path: "/api/tcp/routers/bar@myprovider",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@bar": { "bar@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
@ -127,13 +127,13 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
{ {
desc: "one TCP router by id, that does not exist", desc: "one TCP router by id, that does not exist",
path: "/api/tcp/routers/myprovider@foo", path: "/api/tcp/routers/foo@myprovider",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@bar": { "bar@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
@ -145,7 +145,7 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
{ {
desc: "one TCP router by id, but no config", desc: "one TCP router by id, but no config",
path: "/api/tcp/routers/myprovider@bar", path: "/api/tcp/routers/bar@myprovider",
conf: config.RuntimeConfiguration{}, conf: config.RuntimeConfiguration{},
expected: expected{ expected: expected{
statusCode: http.StatusNotFound, statusCode: http.StatusNotFound,
@ -166,7 +166,7 @@ func TestHandlerTCP_API(t *testing.T) {
path: "/api/tcp/services", path: "/api/tcp/services",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@bar": { "bar@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -176,9 +176,9 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo", "myprovider@test"}, UsedBy: []string{"foo@myprovider", "test@myprovider"},
}, },
"myprovider@baz": { "baz@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -188,7 +188,7 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo"}, UsedBy: []string{"foo@myprovider"},
}, },
}, },
}, },
@ -203,7 +203,7 @@ func TestHandlerTCP_API(t *testing.T) {
path: "/api/tcp/services?page=2&per_page=1", path: "/api/tcp/services?page=2&per_page=1",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@bar": { "bar@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -213,9 +213,9 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo", "myprovider@test"}, UsedBy: []string{"foo@myprovider", "test@myprovider"},
}, },
"myprovider@baz": { "baz@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -225,9 +225,9 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo"}, UsedBy: []string{"foo@myprovider"},
}, },
"myprovider@test": { "test@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -248,10 +248,10 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
{ {
desc: "one tcp service by id", desc: "one tcp service by id",
path: "/api/tcp/services/myprovider@bar", path: "/api/tcp/services/bar@myprovider",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@bar": { "bar@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -261,7 +261,7 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo", "myprovider@test"}, UsedBy: []string{"foo@myprovider", "test@myprovider"},
}, },
}, },
}, },
@ -272,10 +272,10 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
{ {
desc: "one tcp service by id, that does not exist", desc: "one tcp service by id, that does not exist",
path: "/api/tcp/services/myprovider@nono", path: "/api/tcp/services/nono@myprovider",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@bar": { "bar@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -285,7 +285,7 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo", "myprovider@test"}, UsedBy: []string{"foo@myprovider", "test@myprovider"},
}, },
}, },
}, },
@ -295,7 +295,7 @@ func TestHandlerTCP_API(t *testing.T) {
}, },
{ {
desc: "one tcp service by id, but no config", desc: "one tcp service by id, but no config",
path: "/api/tcp/services/myprovider@foo", path: "/api/tcp/services/foo@myprovider",
conf: config.RuntimeConfiguration{}, conf: config.RuntimeConfiguration{},
expected: expected{ expected: expected{
statusCode: http.StatusNotFound, statusCode: http.StatusNotFound,
@ -379,20 +379,20 @@ func TestHandlerHTTP_API(t *testing.T) {
path: "/api/http/routers", path: "/api/http/routers",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@test": { "test@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar.other`)", Rule: "Host(`foo.bar.other`)",
Middlewares: []string{"addPrefixTest", "auth"}, Middlewares: []string{"addPrefixTest", "auth"},
}, },
}, },
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
Middlewares: []string{"auth", "anotherprovider@addPrefixTest"}, Middlewares: []string{"auth", "addPrefixTest@anotherprovider"},
}, },
}, },
}, },
@ -408,25 +408,25 @@ func TestHandlerHTTP_API(t *testing.T) {
path: "/api/http/routers?page=2&per_page=1", path: "/api/http/routers?page=2&per_page=1",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
Middlewares: []string{"auth", "anotherprovider@addPrefixTest"}, Middlewares: []string{"auth", "addPrefixTest@anotherprovider"},
}, },
}, },
"myprovider@baz": { "baz@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`toto.bar`)", Rule: "Host(`toto.bar`)",
}, },
}, },
"myprovider@test": { "test@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar.other`)", Rule: "Host(`foo.bar.other`)",
Middlewares: []string{"addPrefixTest", "auth"}, Middlewares: []string{"addPrefixTest", "auth"},
}, },
@ -473,15 +473,15 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
{ {
desc: "one router by id", desc: "one router by id",
path: "/api/http/routers/myprovider@bar", path: "/api/http/routers/bar@myprovider",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
Middlewares: []string{"auth", "anotherprovider@addPrefixTest"}, Middlewares: []string{"auth", "addPrefixTest@anotherprovider"},
}, },
}, },
}, },
@ -493,15 +493,15 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
{ {
desc: "one router by id, that does not exist", desc: "one router by id, that does not exist",
path: "/api/http/routers/myprovider@foo", path: "/api/http/routers/foo@myprovider",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
Middlewares: []string{"auth", "anotherprovider@addPrefixTest"}, Middlewares: []string{"auth", "addPrefixTest@anotherprovider"},
}, },
}, },
}, },
@ -512,7 +512,7 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
{ {
desc: "one router by id, but no config", desc: "one router by id, but no config",
path: "/api/http/routers/myprovider@foo", path: "/api/http/routers/foo@myprovider",
conf: config.RuntimeConfiguration{}, conf: config.RuntimeConfiguration{},
expected: expected{ expected: expected{
statusCode: http.StatusNotFound, statusCode: http.StatusNotFound,
@ -533,7 +533,7 @@ func TestHandlerHTTP_API(t *testing.T) {
path: "/api/http/services", path: "/api/http/services",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@bar": func() *config.ServiceInfo { "bar@myprovider": func() *config.ServiceInfo {
si := &config.ServiceInfo{ si := &config.ServiceInfo{
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
@ -544,12 +544,12 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo", "myprovider@test"}, UsedBy: []string{"foo@myprovider", "test@myprovider"},
} }
si.UpdateStatus("http://127.0.0.1", "UP") si.UpdateStatus("http://127.0.0.1", "UP")
return si return si
}(), }(),
"myprovider@baz": func() *config.ServiceInfo { "baz@myprovider": func() *config.ServiceInfo {
si := &config.ServiceInfo{ si := &config.ServiceInfo{
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
@ -560,7 +560,7 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo"}, UsedBy: []string{"foo@myprovider"},
} }
si.UpdateStatus("http://127.0.0.2", "UP") si.UpdateStatus("http://127.0.0.2", "UP")
return si return si
@ -578,7 +578,7 @@ func TestHandlerHTTP_API(t *testing.T) {
path: "/api/http/services?page=2&per_page=1", path: "/api/http/services?page=2&per_page=1",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@bar": func() *config.ServiceInfo { "bar@myprovider": func() *config.ServiceInfo {
si := &config.ServiceInfo{ si := &config.ServiceInfo{
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
@ -589,12 +589,12 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo", "myprovider@test"}, UsedBy: []string{"foo@myprovider", "test@myprovider"},
} }
si.UpdateStatus("http://127.0.0.1", "UP") si.UpdateStatus("http://127.0.0.1", "UP")
return si return si
}(), }(),
"myprovider@baz": func() *config.ServiceInfo { "baz@myprovider": func() *config.ServiceInfo {
si := &config.ServiceInfo{ si := &config.ServiceInfo{
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
@ -605,12 +605,12 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo"}, UsedBy: []string{"foo@myprovider"},
} }
si.UpdateStatus("http://127.0.0.2", "UP") si.UpdateStatus("http://127.0.0.2", "UP")
return si return si
}(), }(),
"myprovider@test": func() *config.ServiceInfo { "test@myprovider": func() *config.ServiceInfo {
si := &config.ServiceInfo{ si := &config.ServiceInfo{
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
@ -621,7 +621,7 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo", "myprovider@test"}, UsedBy: []string{"foo@myprovider", "test@myprovider"},
} }
si.UpdateStatus("http://127.0.0.4", "UP") si.UpdateStatus("http://127.0.0.4", "UP")
return si return si
@ -636,10 +636,10 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
{ {
desc: "one service by id", desc: "one service by id",
path: "/api/http/services/myprovider@bar", path: "/api/http/services/bar@myprovider",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@bar": func() *config.ServiceInfo { "bar@myprovider": func() *config.ServiceInfo {
si := &config.ServiceInfo{ si := &config.ServiceInfo{
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
@ -650,7 +650,7 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo", "myprovider@test"}, UsedBy: []string{"foo@myprovider", "test@myprovider"},
} }
si.UpdateStatus("http://127.0.0.1", "UP") si.UpdateStatus("http://127.0.0.1", "UP")
return si return si
@ -664,10 +664,10 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
{ {
desc: "one service by id, that does not exist", desc: "one service by id, that does not exist",
path: "/api/http/services/myprovider@nono", path: "/api/http/services/nono@myprovider",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@bar": func() *config.ServiceInfo { "bar@myprovider": func() *config.ServiceInfo {
si := &config.ServiceInfo{ si := &config.ServiceInfo{
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
@ -678,7 +678,7 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
}, },
}, },
UsedBy: []string{"myprovider@foo", "myprovider@test"}, UsedBy: []string{"foo@myprovider", "test@myprovider"},
} }
si.UpdateStatus("http://127.0.0.1", "UP") si.UpdateStatus("http://127.0.0.1", "UP")
return si return si
@ -691,7 +691,7 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
{ {
desc: "one service by id, but no config", desc: "one service by id, but no config",
path: "/api/http/services/myprovider@foo", path: "/api/http/services/foo@myprovider",
conf: config.RuntimeConfiguration{}, conf: config.RuntimeConfiguration{},
expected: expected{ expected: expected{
statusCode: http.StatusNotFound, statusCode: http.StatusNotFound,
@ -712,29 +712,29 @@ func TestHandlerHTTP_API(t *testing.T) {
path: "/api/http/middlewares", path: "/api/http/middlewares",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
BasicAuth: &config.BasicAuth{ BasicAuth: &config.BasicAuth{
Users: []string{"admin:admin"}, Users: []string{"admin:admin"},
}, },
}, },
UsedBy: []string{"myprovider@bar", "myprovider@test"}, UsedBy: []string{"bar@myprovider", "test@myprovider"},
}, },
"myprovider@addPrefixTest": { "addPrefixTest@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/titi", Prefix: "/titi",
}, },
}, },
UsedBy: []string{"myprovider@test"}, UsedBy: []string{"test@myprovider"},
}, },
"anotherprovider@addPrefixTest": { "addPrefixTest@anotherprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/toto", Prefix: "/toto",
}, },
}, },
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
}, },
@ -749,29 +749,29 @@ func TestHandlerHTTP_API(t *testing.T) {
path: "/api/http/middlewares?page=2&per_page=1", path: "/api/http/middlewares?page=2&per_page=1",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
BasicAuth: &config.BasicAuth{ BasicAuth: &config.BasicAuth{
Users: []string{"admin:admin"}, Users: []string{"admin:admin"},
}, },
}, },
UsedBy: []string{"myprovider@bar", "myprovider@test"}, UsedBy: []string{"bar@myprovider", "test@myprovider"},
}, },
"myprovider@addPrefixTest": { "addPrefixTest@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/titi", Prefix: "/titi",
}, },
}, },
UsedBy: []string{"myprovider@test"}, UsedBy: []string{"test@myprovider"},
}, },
"anotherprovider@addPrefixTest": { "addPrefixTest@anotherprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/toto", Prefix: "/toto",
}, },
}, },
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
}, },
@ -783,32 +783,32 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
{ {
desc: "one middleware by id", desc: "one middleware by id",
path: "/api/http/middlewares/myprovider@auth", path: "/api/http/middlewares/auth@myprovider",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
BasicAuth: &config.BasicAuth{ BasicAuth: &config.BasicAuth{
Users: []string{"admin:admin"}, Users: []string{"admin:admin"},
}, },
}, },
UsedBy: []string{"myprovider@bar", "myprovider@test"}, UsedBy: []string{"bar@myprovider", "test@myprovider"},
}, },
"myprovider@addPrefixTest": { "addPrefixTest@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/titi", Prefix: "/titi",
}, },
}, },
UsedBy: []string{"myprovider@test"}, UsedBy: []string{"test@myprovider"},
}, },
"anotherprovider@addPrefixTest": { "addPrefixTest@anotherprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/toto", Prefix: "/toto",
}, },
}, },
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
}, },
@ -819,16 +819,16 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
{ {
desc: "one middleware by id, that does not exist", desc: "one middleware by id, that does not exist",
path: "/api/http/middlewares/myprovider@foo", path: "/api/http/middlewares/foo@myprovider",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
BasicAuth: &config.BasicAuth{ BasicAuth: &config.BasicAuth{
Users: []string{"admin:admin"}, Users: []string{"admin:admin"},
}, },
}, },
UsedBy: []string{"myprovider@bar", "myprovider@test"}, UsedBy: []string{"bar@myprovider", "test@myprovider"},
}, },
}, },
}, },
@ -838,7 +838,7 @@ func TestHandlerHTTP_API(t *testing.T) {
}, },
{ {
desc: "one middleware by id, but no config", desc: "one middleware by id, but no config",
path: "/api/http/middlewares/myprovider@foo", path: "/api/http/middlewares/foo@myprovider",
conf: config.RuntimeConfiguration{}, conf: config.RuntimeConfiguration{},
expected: expected{ expected: expected{
statusCode: http.StatusNotFound, statusCode: http.StatusNotFound,
@ -912,7 +912,7 @@ func TestHandler_Configuration(t *testing.T) {
path: "/api/rawdata", path: "/api/rawdata",
conf: config.RuntimeConfiguration{ conf: config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
@ -925,21 +925,21 @@ func TestHandler_Configuration(t *testing.T) {
}, },
}, },
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
BasicAuth: &config.BasicAuth{ BasicAuth: &config.BasicAuth{
Users: []string{"admin:admin"}, Users: []string{"admin:admin"},
}, },
}, },
}, },
"myprovider@addPrefixTest": { "addPrefixTest@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/titi", Prefix: "/titi",
}, },
}, },
}, },
"anotherprovider@addPrefixTest": { "addPrefixTest@anotherprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/toto", Prefix: "/toto",
@ -948,25 +948,25 @@ func TestHandler_Configuration(t *testing.T) {
}, },
}, },
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
Middlewares: []string{"auth", "anotherprovider@addPrefixTest"}, Middlewares: []string{"auth", "addPrefixTest@anotherprovider"},
}, },
}, },
"myprovider@test": { "test@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar.other`)", Rule: "Host(`foo.bar.other`)",
Middlewares: []string{"addPrefixTest", "auth"}, Middlewares: []string{"addPrefixTest", "auth"},
}, },
}, },
}, },
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@tcpfoo-service": { "tcpfoo-service@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -979,23 +979,22 @@ func TestHandler_Configuration(t *testing.T) {
}, },
}, },
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@tcpbar": { "tcpbar@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@tcpfoo-service", Service: "tcpfoo-service@myprovider",
Rule: "HostSNI(`foo.bar`)", Rule: "HostSNI(`foo.bar`)",
}, },
}, },
"myprovider@tcptest": { "tcptest@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@tcpfoo-service", Service: "tcpfoo-service@myprovider",
Rule: "HostSNI(`foo.bar.other`)", Rule: "HostSNI(`foo.bar.other`)",
}, },
}, },
}, },
}, },
expected: expected{ expected: expected{
statusCode: http.StatusOK, statusCode: http.StatusOK,
json: "testdata/getrawdata.json", json: "testdata/getrawdata.json",
@ -1011,6 +1010,7 @@ func TestHandler_Configuration(t *testing.T) {
// TODO: server status // TODO: server status
rtConf := &test.conf rtConf := &test.conf
rtConf.PopulateUsedBy() rtConf.PopulateUsedBy()
handler := New(static.Configuration{API: &static.API{}, Global: &static.Global{}}, rtConf) handler := New(static.Configuration{API: &static.API{}, Global: &static.Global{}}, rtConf)
router := mux.NewRouter() router := mux.NewRouter()
@ -1054,10 +1054,10 @@ func TestHandler_Configuration(t *testing.T) {
func generateHTTPRouters(nbRouters int) map[string]*config.RouterInfo { func generateHTTPRouters(nbRouters int) map[string]*config.RouterInfo {
routers := make(map[string]*config.RouterInfo, nbRouters) routers := make(map[string]*config.RouterInfo, nbRouters)
for i := 0; i < nbRouters; i++ { for i := 0; i < nbRouters; i++ {
routers[fmt.Sprintf("myprovider@bar%2d", i)] = &config.RouterInfo{ routers[fmt.Sprintf("bar%2d@myprovider", i)] = &config.RouterInfo{
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar" + strconv.Itoa(i) + "`)", Rule: "Host(`foo.bar" + strconv.Itoa(i) + "`)",
}, },
} }

View file

@ -1,17 +1,17 @@
{ {
"routers": { "routers": {
"myprovider@bar": { "bar@myprovider": {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"middlewares": [ "middlewares": [
"auth", "auth",
"anotherprovider@addPrefixTest" "addPrefixTest@anotherprovider"
], ],
"service": "myprovider@foo-service", "service": "foo-service@myprovider",
"rule": "Host(`foo.bar`)" "rule": "Host(`foo.bar`)"
}, },
"myprovider@test": { "test@myprovider": {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
@ -19,41 +19,41 @@
"addPrefixTest", "addPrefixTest",
"auth" "auth"
], ],
"service": "myprovider@foo-service", "service": "foo-service@myprovider",
"rule": "Host(`foo.bar.other`)" "rule": "Host(`foo.bar.other`)"
} }
}, },
"middlewares": { "middlewares": {
"anotherprovider@addPrefixTest": { "addPrefixTest@anotherprovider": {
"addPrefix": { "addPrefix": {
"prefix": "/toto" "prefix": "/toto"
}, },
"usedBy": [ "usedBy": [
"myprovider@bar" "bar@myprovider"
] ]
}, },
"myprovider@addPrefixTest": { "addPrefixTest@myprovider": {
"addPrefix": { "addPrefix": {
"prefix": "/titi" "prefix": "/titi"
}, },
"usedBy": [ "usedBy": [
"myprovider@test" "test@myprovider"
] ]
}, },
"myprovider@auth": { "auth@myprovider": {
"basicAuth": { "basicAuth": {
"users": [ "users": [
"admin:admin" "admin:admin"
] ]
}, },
"usedBy": [ "usedBy": [
"myprovider@bar", "bar@myprovider",
"myprovider@test" "test@myprovider"
] ]
} }
}, },
"services": { "services": {
"myprovider@foo-service": { "foo-service@myprovider": {
"loadbalancer": { "loadbalancer": {
"servers": [ "servers": [
{ {
@ -63,29 +63,29 @@
"passHostHeader": false "passHostHeader": false
}, },
"usedBy": [ "usedBy": [
"myprovider@bar", "bar@myprovider",
"myprovider@test" "test@myprovider"
] ]
} }
}, },
"tcpRouters": { "tcpRouters": {
"myprovider@tcpbar": { "tcpbar@myprovider": {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"service": "myprovider@tcpfoo-service", "service": "tcpfoo-service@myprovider",
"rule": "HostSNI(`foo.bar`)" "rule": "HostSNI(`foo.bar`)"
}, },
"myprovider@tcptest": { "tcptest@myprovider": {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"service": "myprovider@tcpfoo-service", "service": "tcpfoo-service@myprovider",
"rule": "HostSNI(`foo.bar.other`)" "rule": "HostSNI(`foo.bar.other`)"
} }
}, },
"tcpServices": { "tcpServices": {
"myprovider@tcpfoo-service": { "tcpfoo-service@myprovider": {
"loadbalancer": { "loadbalancer": {
"servers": [ "servers": [
{ {
@ -94,8 +94,8 @@
] ]
}, },
"usedBy": [ "usedBy": [
"myprovider@tcpbar", "tcpbar@myprovider",
"myprovider@tcptest" "tcptest@myprovider"
] ]
} }
} }

View file

@ -4,10 +4,10 @@
"admin:admin" "admin:admin"
] ]
}, },
"name": "myprovider@auth", "name": "auth@myprovider",
"provider": "myprovider@auth", "provider": "myprovider",
"usedBy": [ "usedBy": [
"myprovider@bar", "bar@myprovider",
"myprovider@test" "test@myprovider"
] ]
} }

View file

@ -3,10 +3,10 @@
"addPrefix": { "addPrefix": {
"prefix": "/titi" "prefix": "/titi"
}, },
"name": "myprovider@addPrefixTest", "name": "addPrefixTest@myprovider",
"provider": "myprovider@addPrefixTest", "provider": "myprovider",
"usedBy": [ "usedBy": [
"myprovider@test" "test@myprovider"
] ]
} }
] ]

View file

@ -3,20 +3,20 @@
"addPrefix": { "addPrefix": {
"prefix": "/toto" "prefix": "/toto"
}, },
"name": "anotherprovider@addPrefixTest", "name": "addPrefixTest@anotherprovider",
"provider": "anotherprovider@addPrefixTest", "provider": "anotherprovider",
"usedBy": [ "usedBy": [
"myprovider@bar" "bar@myprovider"
] ]
}, },
{ {
"addPrefix": { "addPrefix": {
"prefix": "/titi" "prefix": "/titi"
}, },
"name": "myprovider@addPrefixTest", "name": "addPrefixTest@myprovider",
"provider": "myprovider@addPrefixTest", "provider": "myprovider",
"usedBy": [ "usedBy": [
"myprovider@test" "test@myprovider"
] ]
}, },
{ {
@ -25,11 +25,11 @@
"admin:admin" "admin:admin"
] ]
}, },
"name": "myprovider@auth", "name": "auth@myprovider",
"provider": "myprovider@auth", "provider": "myprovider",
"usedBy": [ "usedBy": [
"myprovider@bar", "bar@myprovider",
"myprovider@test" "test@myprovider"
] ]
} }
] ]

View file

@ -4,10 +4,10 @@
], ],
"middlewares": [ "middlewares": [
"auth", "auth",
"anotherprovider@addPrefixTest" "addPrefixTest@anotherprovider"
], ],
"name": "myprovider@bar", "name": "bar@myprovider",
"provider": "myprovider@bar", "provider": "myprovider",
"rule": "Host(`foo.bar`)", "rule": "Host(`foo.bar`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
} }

View file

@ -3,45 +3,45 @@
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"name": "myprovider@bar14", "name": "bar14@myprovider",
"provider": "myprovider@bar14", "provider": "myprovider",
"rule": "Host(`foo.bar14`)", "rule": "Host(`foo.bar14`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
}, },
{ {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"name": "myprovider@bar15", "name": "bar15@myprovider",
"provider": "myprovider@bar15", "provider": "myprovider",
"rule": "Host(`foo.bar15`)", "rule": "Host(`foo.bar15`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
}, },
{ {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"name": "myprovider@bar16", "name": "bar16@myprovider",
"provider": "myprovider@bar16", "provider": "myprovider",
"rule": "Host(`foo.bar16`)", "rule": "Host(`foo.bar16`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
}, },
{ {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"name": "myprovider@bar17", "name": "bar17@myprovider",
"provider": "myprovider@bar17", "provider": "myprovider",
"rule": "Host(`foo.bar17`)", "rule": "Host(`foo.bar17`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
}, },
{ {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"name": "myprovider@bar18", "name": "bar18@myprovider",
"provider": "myprovider@bar18", "provider": "myprovider",
"rule": "Host(`foo.bar18`)", "rule": "Host(`foo.bar18`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
} }
] ]

View file

@ -3,9 +3,9 @@
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"name": "myprovider@baz", "name": "baz@myprovider",
"provider": "myprovider@baz", "provider": "myprovider",
"rule": "Host(`toto.bar`)", "rule": "Host(`toto.bar`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
} }
] ]

View file

@ -5,12 +5,12 @@
], ],
"middlewares": [ "middlewares": [
"auth", "auth",
"anotherprovider@addPrefixTest" "addPrefixTest@anotherprovider"
], ],
"name": "myprovider@bar", "name": "bar@myprovider",
"provider": "myprovider@bar", "provider": "myprovider",
"rule": "Host(`foo.bar`)", "rule": "Host(`foo.bar`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
}, },
{ {
"entryPoints": [ "entryPoints": [
@ -20,9 +20,9 @@
"addPrefixTest", "addPrefixTest",
"auth" "auth"
], ],
"name": "myprovider@test", "name": "test@myprovider",
"provider": "myprovider@test", "provider": "myprovider",
"rule": "Host(`foo.bar.other`)", "rule": "Host(`foo.bar.other`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
} }
] ]

View file

@ -7,13 +7,13 @@
} }
] ]
}, },
"name": "myprovider@bar", "name": "bar@myprovider",
"provider": "myprovider@bar", "provider": "myprovider",
"serverStatus": { "serverStatus": {
"http://127.0.0.1": "UP" "http://127.0.0.1": "UP"
}, },
"usedBy": [ "usedBy": [
"myprovider@foo", "foo@myprovider",
"myprovider@test" "test@myprovider"
] ]
} }

View file

@ -8,13 +8,13 @@
} }
] ]
}, },
"name": "myprovider@baz", "name": "baz@myprovider",
"provider": "myprovider@baz", "provider": "myprovider",
"serverStatus": { "serverStatus": {
"http://127.0.0.2": "UP" "http://127.0.0.2": "UP"
}, },
"usedBy": [ "usedBy": [
"myprovider@foo" "foo@myprovider"
] ]
} }
] ]

View file

@ -8,14 +8,14 @@
} }
] ]
}, },
"name": "myprovider@bar", "name": "bar@myprovider",
"provider": "myprovider@bar", "provider": "myprovider",
"serverStatus": { "serverStatus": {
"http://127.0.0.1": "UP" "http://127.0.0.1": "UP"
}, },
"usedBy": [ "usedBy": [
"myprovider@foo", "foo@myprovider",
"myprovider@test" "test@myprovider"
] ]
}, },
{ {
@ -27,13 +27,13 @@
} }
] ]
}, },
"name": "myprovider@baz", "name": "baz@myprovider",
"provider": "myprovider@baz", "provider": "myprovider",
"serverStatus": { "serverStatus": {
"http://127.0.0.2": "UP" "http://127.0.0.2": "UP"
}, },
"usedBy": [ "usedBy": [
"myprovider@foo" "foo@myprovider"
] ]
} }
] ]

View file

@ -2,8 +2,8 @@
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"name": "myprovider@bar", "name": "bar@myprovider",
"provider": "myprovider@bar", "provider": "myprovider",
"rule": "Host(`foo.bar`)", "rule": "Host(`foo.bar`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
} }

View file

@ -3,9 +3,9 @@
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"name": "myprovider@baz", "name": "baz@myprovider",
"provider": "myprovider@baz", "provider": "myprovider",
"rule": "Host(`toto.bar`)", "rule": "Host(`toto.bar`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
} }
] ]

View file

@ -3,19 +3,19 @@
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"name": "myprovider@bar", "name": "bar@myprovider",
"provider": "myprovider@bar", "provider": "myprovider",
"rule": "Host(`foo.bar`)", "rule": "Host(`foo.bar`)",
"service": "myprovider@foo-service" "service": "foo-service@myprovider"
}, },
{ {
"entryPoints": [ "entryPoints": [
"web" "web"
], ],
"name": "myprovider@test", "name": "test@myprovider",
"provider": "myprovider@test", "provider": "myprovider",
"rule": "Host(`foo.bar.other`)", "rule": "Host(`foo.bar.other`)",
"service": "myprovider@foo-service", "service": "foo-service@myprovider",
"tls": { "tls": {
"passthrough": false "passthrough": false
} }

View file

@ -6,10 +6,10 @@
} }
] ]
}, },
"name": "myprovider@bar", "name": "bar@myprovider",
"provider": "myprovider@bar", "provider": "myprovider",
"usedBy": [ "usedBy": [
"myprovider@foo", "foo@myprovider",
"myprovider@test" "test@myprovider"
] ]
} }

View file

@ -7,10 +7,10 @@
} }
] ]
}, },
"name": "myprovider@baz", "name": "baz@myprovider",
"provider": "myprovider@baz", "provider": "myprovider",
"usedBy": [ "usedBy": [
"myprovider@foo" "foo@myprovider"
] ]
} }
] ]

View file

@ -7,11 +7,11 @@
} }
] ]
}, },
"name": "myprovider@bar", "name": "bar@myprovider",
"provider": "myprovider@bar", "provider": "myprovider",
"usedBy": [ "usedBy": [
"myprovider@foo", "foo@myprovider",
"myprovider@test" "test@myprovider"
] ]
}, },
{ {
@ -22,10 +22,10 @@
} }
] ]
}, },
"name": "myprovider@baz", "name": "baz@myprovider",
"provider": "myprovider@baz", "provider": "myprovider",
"usedBy": [ "usedBy": [
"myprovider@foo" "foo@myprovider"
] ]
} }
] ]

View file

@ -265,7 +265,7 @@ type TCPServiceInfo struct {
func getProviderName(elementName string) string { func getProviderName(elementName string) string {
parts := strings.Split(elementName, "@") parts := strings.Split(elementName, "@")
if len(parts) > 1 { if len(parts) > 1 {
return parts[0] return parts[1]
} }
return "" return ""
} }
@ -273,7 +273,7 @@ func getProviderName(elementName string) string {
func getQualifiedName(provider, elementName string) string { func getQualifiedName(provider, elementName string) string {
parts := strings.Split(elementName, "@") parts := strings.Split(elementName, "@")
if len(parts) == 1 { if len(parts) == 1 {
return provider + "@" + elementName return elementName + "@" + provider
} }
return elementName return elementName
} }

View file

@ -25,23 +25,23 @@ func TestPopulateUsedby(t *testing.T) {
desc: "One service used by two routers", desc: "One service used by two routers",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@foo": { "foo@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
}, },
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
}, },
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
@ -59,12 +59,12 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@foo": {}, "foo@myprovider": {},
"myprovider@bar": {}, "bar@myprovider": {},
}, },
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@bar", "myprovider@foo"}, UsedBy: []string{"bar@myprovider", "foo@myprovider"},
}, },
}, },
}, },
@ -73,7 +73,7 @@ func TestPopulateUsedby(t *testing.T) {
desc: "One service used by two routers, but one router with wrong rule", desc: "One service used by two routers, but one router with wrong rule",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
@ -84,17 +84,17 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@foo": { "foo@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "WrongRule(`bar.foo`)", Rule: "WrongRule(`bar.foo`)",
}, },
}, },
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
@ -102,12 +102,12 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@foo": {}, "foo@myprovider": {},
"myprovider@bar": {}, "bar@myprovider": {},
}, },
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@bar", "myprovider@foo"}, UsedBy: []string{"bar@myprovider", "foo@myprovider"},
}, },
}, },
}, },
@ -116,17 +116,17 @@ func TestPopulateUsedby(t *testing.T) {
desc: "Broken Service used by one Router", desc: "Broken Service used by one Router",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: nil, LoadBalancer: nil,
}, },
}, },
}, },
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
@ -134,11 +134,11 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": {}, "bar@myprovider": {},
}, },
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
}, },
@ -147,7 +147,7 @@ func TestPopulateUsedby(t *testing.T) {
desc: "2 different Services each used by a disctinct router.", desc: "2 different Services each used by a disctinct router.",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
@ -165,7 +165,7 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
}, },
"myprovider@bar-service": { "bar-service@myprovider": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
@ -185,17 +185,17 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@foo": { "foo@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
}, },
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
@ -203,15 +203,15 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": {}, "bar@myprovider": {},
"myprovider@foo": {}, "foo@myprovider": {},
}, },
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@foo"}, UsedBy: []string{"foo@myprovider"},
}, },
"myprovider@bar-service": { "bar-service@myprovider": {
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
}, },
@ -220,7 +220,7 @@ func TestPopulateUsedby(t *testing.T) {
desc: "2 middlewares both used by 2 Routers", desc: "2 middlewares both used by 2 Routers",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
@ -233,14 +233,14 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
BasicAuth: &config.BasicAuth{ BasicAuth: &config.BasicAuth{
Users: []string{"admin:admin"}, Users: []string{"admin:admin"},
}, },
}, },
}, },
"myprovider@addPrefixTest": { "addPrefixTest@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/toto", Prefix: "/toto",
@ -249,18 +249,18 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
Middlewares: []string{"auth", "addPrefixTest"}, Middlewares: []string{"auth", "addPrefixTest"},
}, },
}, },
"myprovider@test": { "test@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar.other`)", Rule: "Host(`foo.bar.other`)",
Middlewares: []string{"addPrefixTest", "auth"}, Middlewares: []string{"addPrefixTest", "auth"},
}, },
@ -269,20 +269,20 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": {}, "bar@myprovider": {},
"myprovider@test": {}, "test@myprovider": {},
}, },
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@bar", "myprovider@test"}, UsedBy: []string{"bar@myprovider", "test@myprovider"},
}, },
}, },
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
UsedBy: []string{"myprovider@bar", "myprovider@test"}, UsedBy: []string{"bar@myprovider", "test@myprovider"},
}, },
"myprovider@addPrefixTest": { "addPrefixTest@myprovider": {
UsedBy: []string{"myprovider@bar", "myprovider@test"}, UsedBy: []string{"bar@myprovider", "test@myprovider"},
}, },
}, },
}, },
@ -291,7 +291,7 @@ func TestPopulateUsedby(t *testing.T) {
desc: "Unknown middleware is not used by the Router", desc: "Unknown middleware is not used by the Router",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
@ -304,7 +304,7 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
BasicAuth: &config.BasicAuth{ BasicAuth: &config.BasicAuth{
Users: []string{"admin:admin"}, Users: []string{"admin:admin"},
@ -313,10 +313,10 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
Middlewares: []string{"unknown"}, Middlewares: []string{"unknown"},
}, },
@ -325,8 +325,8 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
}, },
@ -335,7 +335,7 @@ func TestPopulateUsedby(t *testing.T) {
desc: "Broken middleware is used by Router", desc: "Broken middleware is used by Router",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
@ -348,7 +348,7 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
BasicAuth: &config.BasicAuth{ BasicAuth: &config.BasicAuth{
Users: []string{"badConf"}, Users: []string{"badConf"},
@ -357,28 +357,28 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
Middlewares: []string{"myprovider@auth"}, Middlewares: []string{"auth@myprovider"},
}, },
}, },
}, },
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": {}, "bar@myprovider": {},
}, },
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
}, },
@ -387,7 +387,7 @@ func TestPopulateUsedby(t *testing.T) {
desc: "2 middlewares from 2 disctinct providers both used by 2 Routers", desc: "2 middlewares from 2 disctinct providers both used by 2 Routers",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
@ -400,21 +400,21 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
BasicAuth: &config.BasicAuth{ BasicAuth: &config.BasicAuth{
Users: []string{"admin:admin"}, Users: []string{"admin:admin"},
}, },
}, },
}, },
"myprovider@addPrefixTest": { "addPrefixTest@myprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/titi", Prefix: "/titi",
}, },
}, },
}, },
"anotherprovider@addPrefixTest": { "addPrefixTest@anotherprovider": {
Middleware: &config.Middleware{ Middleware: &config.Middleware{
AddPrefix: &config.AddPrefix{ AddPrefix: &config.AddPrefix{
Prefix: "/toto", Prefix: "/toto",
@ -423,18 +423,18 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": { "bar@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
Middlewares: []string{"auth", "anotherprovider@addPrefixTest"}, Middlewares: []string{"auth", "addPrefixTest@anotherprovider"},
}, },
}, },
"myprovider@test": { "test@myprovider": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar.other`)", Rule: "Host(`foo.bar.other`)",
Middlewares: []string{"addPrefixTest", "auth"}, Middlewares: []string{"addPrefixTest", "auth"},
}, },
@ -443,23 +443,23 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
Routers: map[string]*config.RouterInfo{ Routers: map[string]*config.RouterInfo{
"myprovider@bar": {}, "bar@myprovider": {},
"myprovider@test": {}, "test@myprovider": {},
}, },
Services: map[string]*config.ServiceInfo{ Services: map[string]*config.ServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@bar", "myprovider@test"}, UsedBy: []string{"bar@myprovider", "test@myprovider"},
}, },
}, },
Middlewares: map[string]*config.MiddlewareInfo{ Middlewares: map[string]*config.MiddlewareInfo{
"myprovider@auth": { "auth@myprovider": {
UsedBy: []string{"myprovider@bar", "myprovider@test"}, UsedBy: []string{"bar@myprovider", "test@myprovider"},
}, },
"myprovider@addPrefixTest": { "addPrefixTest@myprovider": {
UsedBy: []string{"myprovider@test"}, UsedBy: []string{"test@myprovider"},
}, },
"anotherprovider@addPrefixTest": { "addPrefixTest@anotherprovider": {
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
}, },
@ -470,23 +470,23 @@ func TestPopulateUsedby(t *testing.T) {
desc: "TCP, One service used by two routers", desc: "TCP, One service used by two routers",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@foo": { "foo@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
}, },
"myprovider@bar": { "bar@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
}, },
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -506,12 +506,12 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@foo": {}, "foo@myprovider": {},
"myprovider@bar": {}, "bar@myprovider": {},
}, },
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@bar", "myprovider@foo"}, UsedBy: []string{"bar@myprovider", "foo@myprovider"},
}, },
}, },
}, },
@ -520,7 +520,7 @@ func TestPopulateUsedby(t *testing.T) {
desc: "TCP, One service used by two routers, but one router with wrong rule", desc: "TCP, One service used by two routers, but one router with wrong rule",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -533,17 +533,17 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@foo": { "foo@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "WrongRule(`bar.foo`)", Rule: "WrongRule(`bar.foo`)",
}, },
}, },
"myprovider@bar": { "bar@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
@ -551,12 +551,12 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@foo": {}, "foo@myprovider": {},
"myprovider@bar": {}, "bar@myprovider": {},
}, },
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@bar", "myprovider@foo"}, UsedBy: []string{"bar@myprovider", "foo@myprovider"},
}, },
}, },
}, },
@ -565,17 +565,17 @@ func TestPopulateUsedby(t *testing.T) {
desc: "TCP, Broken Service used by one Router", desc: "TCP, Broken Service used by one Router",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: nil, LoadBalancer: nil,
}, },
}, },
}, },
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@bar": { "bar@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
@ -583,11 +583,11 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@bar": {}, "bar@myprovider": {},
}, },
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
}, },
@ -596,7 +596,7 @@ func TestPopulateUsedby(t *testing.T) {
desc: "TCP, 2 different Services each used by a disctinct router.", desc: "TCP, 2 different Services each used by a disctinct router.",
conf: &config.RuntimeConfiguration{ conf: &config.RuntimeConfiguration{
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -612,7 +612,7 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
}, },
"myprovider@bar-service": { "bar-service@myprovider": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -630,17 +630,17 @@ func TestPopulateUsedby(t *testing.T) {
}, },
}, },
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@foo": { "foo@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
}, },
"myprovider@bar": { "bar@myprovider": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
@ -648,15 +648,15 @@ func TestPopulateUsedby(t *testing.T) {
}, },
expected: config.RuntimeConfiguration{ expected: config.RuntimeConfiguration{
TCPRouters: map[string]*config.TCPRouterInfo{ TCPRouters: map[string]*config.TCPRouterInfo{
"myprovider@bar": {}, "bar@myprovider": {},
"myprovider@foo": {}, "foo@myprovider": {},
}, },
TCPServices: map[string]*config.TCPServiceInfo{ TCPServices: map[string]*config.TCPServiceInfo{
"myprovider@foo-service": { "foo-service@myprovider": {
UsedBy: []string{"myprovider@foo"}, UsedBy: []string{"foo@myprovider"},
}, },
"myprovider@bar-service": { "bar-service@myprovider": {
UsedBy: []string{"myprovider@bar"}, UsedBy: []string{"bar@myprovider"},
}, },
}, },
}, },
@ -716,7 +716,7 @@ func TestGetTCPRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.Router{ Routers: map[string]*config.Router{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
}, },
@ -725,7 +725,7 @@ func TestGetTCPRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.TCPRouter{ Routers: map[string]*config.TCPRouter{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "HostSNI(`bar.foo`)", Rule: "HostSNI(`bar.foo`)",
}, },
}, },
@ -741,17 +741,17 @@ func TestGetTCPRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.Router{ Routers: map[string]*config.Router{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
"bar": { "bar": {
EntryPoints: []string{"webs"}, EntryPoints: []string{"webs"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
"foobar": { "foobar": {
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "Host(`bar.foobar`)", Rule: "Host(`bar.foobar`)",
}, },
}, },
@ -760,17 +760,17 @@ func TestGetTCPRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.TCPRouter{ Routers: map[string]*config.TCPRouter{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "HostSNI(`bar.foo`)", Rule: "HostSNI(`bar.foo`)",
}, },
"bar": { "bar": {
EntryPoints: []string{"webs"}, EntryPoints: []string{"webs"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "HostSNI(`foo.bar`)", Rule: "HostSNI(`foo.bar`)",
}, },
"foobar": { "foobar": {
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "HostSNI(`bar.foobar`)", Rule: "HostSNI(`bar.foobar`)",
}, },
}, },
@ -782,14 +782,14 @@ func TestGetTCPRoutersByEntrypoints(t *testing.T) {
"foo": { "foo": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "HostSNI(`bar.foo`)", Rule: "HostSNI(`bar.foo`)",
}, },
}, },
"foobar": { "foobar": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "HostSNI(`bar.foobar`)", Rule: "HostSNI(`bar.foobar`)",
}, },
}, },
@ -803,17 +803,17 @@ func TestGetTCPRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.Router{ Routers: map[string]*config.Router{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
"bar": { "bar": {
EntryPoints: []string{"webs"}, EntryPoints: []string{"webs"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
"foobar": { "foobar": {
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "Host(`bar.foobar`)", Rule: "Host(`bar.foobar`)",
}, },
}, },
@ -822,17 +822,17 @@ func TestGetTCPRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.TCPRouter{ Routers: map[string]*config.TCPRouter{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "HostSNI(`bar.foo`)", Rule: "HostSNI(`bar.foo`)",
}, },
"bar": { "bar": {
EntryPoints: []string{"webs"}, EntryPoints: []string{"webs"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "HostSNI(`foo.bar`)", Rule: "HostSNI(`foo.bar`)",
}, },
"foobar": { "foobar": {
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "HostSNI(`bar.foobar`)", Rule: "HostSNI(`bar.foobar`)",
}, },
}, },
@ -844,14 +844,14 @@ func TestGetTCPRoutersByEntrypoints(t *testing.T) {
"foo": { "foo": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "HostSNI(`bar.foo`)", Rule: "HostSNI(`bar.foo`)",
}, },
}, },
"foobar": { "foobar": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "HostSNI(`bar.foobar`)", Rule: "HostSNI(`bar.foobar`)",
}, },
}, },
@ -861,14 +861,14 @@ func TestGetTCPRoutersByEntrypoints(t *testing.T) {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"webs"}, EntryPoints: []string{"webs"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "HostSNI(`foo.bar`)", Rule: "HostSNI(`foo.bar`)",
}, },
}, },
"foobar": { "foobar": {
TCPRouter: &config.TCPRouter{ TCPRouter: &config.TCPRouter{
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "HostSNI(`bar.foobar`)", Rule: "HostSNI(`bar.foobar`)",
}, },
}, },
@ -914,7 +914,7 @@ func TestGetRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.Router{ Routers: map[string]*config.Router{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
}, },
@ -923,7 +923,7 @@ func TestGetRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.TCPRouter{ Routers: map[string]*config.TCPRouter{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "HostSNI(`bar.foo`)", Rule: "HostSNI(`bar.foo`)",
}, },
}, },
@ -939,17 +939,17 @@ func TestGetRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.Router{ Routers: map[string]*config.Router{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
"bar": { "bar": {
EntryPoints: []string{"webs"}, EntryPoints: []string{"webs"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
"foobar": { "foobar": {
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "Host(`bar.foobar`)", Rule: "Host(`bar.foobar`)",
}, },
}, },
@ -958,17 +958,17 @@ func TestGetRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.TCPRouter{ Routers: map[string]*config.TCPRouter{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "HostSNI(`bar.foo`)", Rule: "HostSNI(`bar.foo`)",
}, },
"bar": { "bar": {
EntryPoints: []string{"webs"}, EntryPoints: []string{"webs"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "HostSNI(`foo.bar`)", Rule: "HostSNI(`foo.bar`)",
}, },
"foobar": { "foobar": {
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "HostSNI(`bar.foobar`)", Rule: "HostSNI(`bar.foobar`)",
}, },
}, },
@ -980,14 +980,14 @@ func TestGetRoutersByEntrypoints(t *testing.T) {
"foo": { "foo": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
}, },
"foobar": { "foobar": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "Host(`bar.foobar`)", Rule: "Host(`bar.foobar`)",
}, },
}, },
@ -1001,17 +1001,17 @@ func TestGetRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.Router{ Routers: map[string]*config.Router{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
"bar": { "bar": {
EntryPoints: []string{"webs"}, EntryPoints: []string{"webs"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
"foobar": { "foobar": {
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "Host(`bar.foobar`)", Rule: "Host(`bar.foobar`)",
}, },
}, },
@ -1020,17 +1020,17 @@ func TestGetRoutersByEntrypoints(t *testing.T) {
Routers: map[string]*config.TCPRouter{ Routers: map[string]*config.TCPRouter{
"foo": { "foo": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "HostSNI(`bar.foo`)", Rule: "HostSNI(`bar.foo`)",
}, },
"bar": { "bar": {
EntryPoints: []string{"webs"}, EntryPoints: []string{"webs"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "HostSNI(`foo.bar`)", Rule: "HostSNI(`foo.bar`)",
}, },
"foobar": { "foobar": {
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "HostSNI(`bar.foobar`)", Rule: "HostSNI(`bar.foobar`)",
}, },
}, },
@ -1042,14 +1042,14 @@ func TestGetRoutersByEntrypoints(t *testing.T) {
"foo": { "foo": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "myprovider@foo-service", Service: "foo-service@myprovider",
Rule: "Host(`bar.foo`)", Rule: "Host(`bar.foo`)",
}, },
}, },
"foobar": { "foobar": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "Host(`bar.foobar`)", Rule: "Host(`bar.foobar`)",
}, },
}, },
@ -1059,14 +1059,14 @@ func TestGetRoutersByEntrypoints(t *testing.T) {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"webs"}, EntryPoints: []string{"webs"},
Service: "myprovider@bar-service", Service: "bar-service@myprovider",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
"foobar": { "foobar": {
Router: &config.Router{ Router: &config.Router{
EntryPoints: []string{"web", "webs"}, EntryPoints: []string{"web", "webs"},
Service: "myprovider@foobar-service", Service: "foobar-service@myprovider",
Rule: "Host(`bar.foobar`)", Rule: "Host(`bar.foobar`)",
}, },
}, },

View file

@ -41,13 +41,13 @@ func TestAggregator(t *testing.T) {
}, },
expected: &config.HTTPConfiguration{ expected: &config.HTTPConfiguration{
Routers: map[string]*config.Router{ Routers: map[string]*config.Router{
"provider-1@router-1": {}, "router-1@provider-1": {},
}, },
Middlewares: map[string]*config.Middleware{ Middlewares: map[string]*config.Middleware{
"provider-1@middleware-1": {}, "middleware-1@provider-1": {},
}, },
Services: map[string]*config.Service{ Services: map[string]*config.Service{
"provider-1@service-1": {}, "service-1@provider-1": {},
}, },
}, },
}, },
@ -83,16 +83,16 @@ func TestAggregator(t *testing.T) {
}, },
expected: &config.HTTPConfiguration{ expected: &config.HTTPConfiguration{
Routers: map[string]*config.Router{ Routers: map[string]*config.Router{
"provider-1@router-1": {}, "router-1@provider-1": {},
"provider-2@router-1": {}, "router-1@provider-2": {},
}, },
Middlewares: map[string]*config.Middleware{ Middlewares: map[string]*config.Middleware{
"provider-1@middleware-1": {}, "middleware-1@provider-1": {},
"provider-2@middleware-1": {}, "middleware-1@provider-2": {},
}, },
Services: map[string]*config.Service{ Services: map[string]*config.Service{
"provider-1@service-1": {}, "service-1@provider-1": {},
"provider-2@service-1": {}, "service-1@provider-2": {},
}, },
}, },
}, },

View file

@ -21,11 +21,11 @@ func AddProviderInContext(ctx context.Context, elementName string) context.Conte
return ctx return ctx
} }
if name, ok := ctx.Value(providerKey).(string); ok && name == parts[0] { if name, ok := ctx.Value(providerKey).(string); ok && name == parts[1] {
return ctx return ctx
} }
return context.WithValue(ctx, providerKey, parts[0]) return context.WithValue(ctx, providerKey, parts[1])
} }
// GetQualifiedName Gets the fully qualified name. // GetQualifiedName Gets the fully qualified name.
@ -41,5 +41,5 @@ func GetQualifiedName(ctx context.Context, elementName string) string {
// MakeQualifiedName Creates a qualified name for an element // MakeQualifiedName Creates a qualified name for an element
func MakeQualifiedName(providerName string, elementName string) string { func MakeQualifiedName(providerName string, elementName string) string {
return providerName + "@" + elementName return elementName + "@" + providerName
} }

View file

@ -74,41 +74,41 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
expected: map[string]string{"middleware-1": "value-middleware-1"}, expected: map[string]string{"middleware-1": "value-middleware-1"},
}, },
{ {
desc: "Should prefix the middlewareName with the provider in the context", desc: "Should suffix the middlewareName with the provider in the context",
buildChain: []string{"middleware-1"}, buildChain: []string{"middleware-1"},
configuration: map[string]*config.Middleware{ configuration: map[string]*config.Middleware{
"provider-1@middleware-1": { "middleware-1@provider-1": {
Headers: &config.Headers{ Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"provider-1.middleware-1": "value-middleware-1"}, CustomRequestHeaders: map[string]string{"middleware-1@provider-1": "value-middleware-1"},
}, },
}, },
}, },
expected: map[string]string{"provider-1.middleware-1": "value-middleware-1"}, expected: map[string]string{"middleware-1@provider-1": "value-middleware-1"},
contextProvider: "provider-1", contextProvider: "provider-1",
}, },
{ {
desc: "Should not prefix a qualified middlewareName with the provider in the context", desc: "Should not suffix a qualified middlewareName with the provider in the context",
buildChain: []string{"provider-1@middleware-1"}, buildChain: []string{"middleware-1@provider-1"},
configuration: map[string]*config.Middleware{ configuration: map[string]*config.Middleware{
"provider-1@middleware-1": { "middleware-1@provider-1": {
Headers: &config.Headers{ Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"provider-1.middleware-1": "value-middleware-1"}, CustomRequestHeaders: map[string]string{"middleware-1@provider-1": "value-middleware-1"},
}, },
}, },
}, },
expected: map[string]string{"provider-1.middleware-1": "value-middleware-1"}, expected: map[string]string{"middleware-1@provider-1": "value-middleware-1"},
contextProvider: "provider-1", contextProvider: "provider-1",
}, },
{ {
desc: "Should be context aware if a chain references another middleware", desc: "Should be context aware if a chain references another middleware",
buildChain: []string{"provider-1@middleware-chain-1"}, buildChain: []string{"middleware-chain-1@provider-1"},
configuration: map[string]*config.Middleware{ configuration: map[string]*config.Middleware{
"provider-1@middleware-1": { "middleware-1@provider-1": {
Headers: &config.Headers{ Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"middleware-1": "value-middleware-1"}, CustomRequestHeaders: map[string]string{"middleware-1": "value-middleware-1"},
}, },
}, },
"provider-1@middleware-chain-1": { "middleware-chain-1@provider-1": {
Chain: &config.Chain{ Chain: &config.Chain{
Middlewares: []string{"middleware-1"}, Middlewares: []string{"middleware-1"},
}, },
@ -118,31 +118,31 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
}, },
{ {
desc: "Should handle nested chains with different context", desc: "Should handle nested chains with different context",
buildChain: []string{"provider-1@middleware-chain-1", "middleware-chain-1"}, buildChain: []string{"middleware-chain-1@provider-1", "middleware-chain-1"},
configuration: map[string]*config.Middleware{ configuration: map[string]*config.Middleware{
"provider-1@middleware-1": { "middleware-1@provider-1": {
Headers: &config.Headers{ Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"middleware-1": "value-middleware-1"}, CustomRequestHeaders: map[string]string{"middleware-1": "value-middleware-1"},
}, },
}, },
"provider-1@middleware-2": { "middleware-2@provider-1": {
Headers: &config.Headers{ Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"middleware-2": "value-middleware-2"}, CustomRequestHeaders: map[string]string{"middleware-2": "value-middleware-2"},
}, },
}, },
"provider-1@middleware-chain-1": { "middleware-chain-1@provider-1": {
Chain: &config.Chain{ Chain: &config.Chain{
Middlewares: []string{"middleware-1"}, Middlewares: []string{"middleware-1"},
}, },
}, },
"provider-1@middleware-chain-2": { "middleware-chain-2@provider-1": {
Chain: &config.Chain{ Chain: &config.Chain{
Middlewares: []string{"middleware-2"}, Middlewares: []string{"middleware-2"},
}, },
}, },
"provider-2@middleware-chain-1": { "middleware-chain-1@provider-2": {
Chain: &config.Chain{ Chain: &config.Chain{
Middlewares: []string{"provider-1@middleware-2", "provider-1@middleware-chain-2"}, Middlewares: []string{"middleware-2@provider-1", "middleware-chain-2@provider-1"},
}, },
}, },
}, },
@ -176,28 +176,28 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
}, },
{ {
desc: "Detects recursion in Middleware chain", desc: "Detects recursion in Middleware chain",
buildChain: []string{"provider@m1"}, buildChain: []string{"m1@provider"},
configuration: map[string]*config.Middleware{ configuration: map[string]*config.Middleware{
"provider2@ok": { "ok@provider2": {
Retry: &config.Retry{}, Retry: &config.Retry{},
}, },
"provider@m1": { "m1@provider": {
Chain: &config.Chain{ Chain: &config.Chain{
Middlewares: []string{"provider2@m2"}, Middlewares: []string{"m2@provider2"},
}, },
}, },
"provider2@m2": { "m2@provider2": {
Chain: &config.Chain{ Chain: &config.Chain{
Middlewares: []string{"ok", "provider@m3"}, Middlewares: []string{"ok", "m3@provider"},
}, },
}, },
"provider@m3": { "m3@provider": {
Chain: &config.Chain{ Chain: &config.Chain{
Middlewares: []string{"m1"}, Middlewares: []string{"m1"},
}, },
}, },
}, },
expectedError: errors.New("could not instantiate middleware provider@m1: recursion detected in provider@m1->provider2@m2->provider@m3->provider@m1"), expectedError: errors.New("could not instantiate middleware m1@provider: recursion detected in m1@provider->m2@provider2->m3@provider->m1@provider"),
}, },
{ {
buildChain: []string{"ok", "m0"}, buildChain: []string{"ok", "m0"},
@ -261,7 +261,7 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
ctx := context.Background() ctx := context.Background()
if len(test.contextProvider) > 0 { if len(test.contextProvider) > 0 {
ctx = internal.AddProviderInContext(ctx, test.contextProvider+"@foobar") ctx = internal.AddProviderInContext(ctx, "foobar@"+test.contextProvider)
} }
rtConf := config.NewRuntimeConfig(config.Configuration{ rtConf := config.NewRuntimeConfig(config.Configuration{

View file

@ -204,14 +204,14 @@ func TestRouterManager_Get(t *testing.T) {
{ {
desc: "no middleware with provider name", desc: "no middleware with provider name",
routersConfig: map[string]*config.Router{ routersConfig: map[string]*config.Router{
"provider-1@foo": { "foo@provider-1": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "foo-service", Service: "foo-service",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
serviceConfig: map[string]*config.Service{ serviceConfig: map[string]*config.Service{
"provider-1@foo-service": { "foo-service@provider-1": {
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
{ {
@ -227,14 +227,14 @@ func TestRouterManager_Get(t *testing.T) {
{ {
desc: "no middleware with specified provider name", desc: "no middleware with specified provider name",
routersConfig: map[string]*config.Router{ routersConfig: map[string]*config.Router{
"provider-1@foo": { "foo@provider-1": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Service: "provider-2@foo-service", Service: "foo-service@provider-2",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
serviceConfig: map[string]*config.Service{ serviceConfig: map[string]*config.Service{
"provider-2@foo-service": { "foo-service@provider-2": {
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
{ {
@ -250,15 +250,15 @@ func TestRouterManager_Get(t *testing.T) {
{ {
desc: "middleware: chain with provider name", desc: "middleware: chain with provider name",
routersConfig: map[string]*config.Router{ routersConfig: map[string]*config.Router{
"provider-1@foo": { "foo@provider-1": {
EntryPoints: []string{"web"}, EntryPoints: []string{"web"},
Middlewares: []string{"provider-2@chain-middle", "headers-middle"}, Middlewares: []string{"chain-middle@provider-2", "headers-middle"},
Service: "foo-service", Service: "foo-service",
Rule: "Host(`foo.bar`)", Rule: "Host(`foo.bar`)",
}, },
}, },
serviceConfig: map[string]*config.Service{ serviceConfig: map[string]*config.Service{
"provider-1@foo-service": { "foo-service@provider-1": {
LoadBalancer: &config.LoadBalancerService{ LoadBalancer: &config.LoadBalancerService{
Servers: []config.Server{ Servers: []config.Server{
{ {
@ -269,15 +269,15 @@ func TestRouterManager_Get(t *testing.T) {
}, },
}, },
middlewaresConfig: map[string]*config.Middleware{ middlewaresConfig: map[string]*config.Middleware{
"provider-2@chain-middle": { "chain-middle@provider-2": {
Chain: &config.Chain{Middlewares: []string{"auth-middle"}}, Chain: &config.Chain{Middlewares: []string{"auth-middle"}},
}, },
"provider-2@auth-middle": { "auth-middle@provider-2": {
BasicAuth: &config.BasicAuth{ BasicAuth: &config.BasicAuth{
Users: []string{"toto:titi"}, Users: []string{"toto:titi"},
}, },
}, },
"provider-1@headers-middle": { "headers-middle@provider-1": {
Headers: &config.Headers{ Headers: &config.Headers{
CustomRequestHeaders: map[string]string{"X-Apero": "beer"}, CustomRequestHeaders: map[string]string{"X-Apero": "beer"},
}, },

View file

@ -303,9 +303,9 @@ func TestManager_Build(t *testing.T) {
}, },
{ {
desc: "Service name with provider", desc: "Service name with provider",
serviceName: "provider-1@serviceName", serviceName: "serviceName@provider-1",
configs: map[string]*config.ServiceInfo{ configs: map[string]*config.ServiceInfo{
"provider-1@serviceName": { "serviceName@provider-1": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{}, LoadBalancer: &config.LoadBalancerService{},
}, },
@ -316,7 +316,7 @@ func TestManager_Build(t *testing.T) {
desc: "Service name with provider in context", desc: "Service name with provider in context",
serviceName: "serviceName", serviceName: "serviceName",
configs: map[string]*config.ServiceInfo{ configs: map[string]*config.ServiceInfo{
"provider-1@serviceName": { "serviceName@provider-1": {
Service: &config.Service{ Service: &config.Service{
LoadBalancer: &config.LoadBalancerService{}, LoadBalancer: &config.LoadBalancerService{},
}, },
@ -335,7 +335,7 @@ func TestManager_Build(t *testing.T) {
ctx := context.Background() ctx := context.Background()
if len(test.providerName) > 0 { if len(test.providerName) > 0 {
ctx = internal.AddProviderInContext(ctx, test.providerName+"@foobar") ctx = internal.AddProviderInContext(ctx, "foobar@"+test.providerName)
} }
_, err := manager.BuildHTTP(ctx, test.serviceName, nil) _, err := manager.BuildHTTP(ctx, test.serviceName, nil)

View file

@ -77,9 +77,9 @@ func TestManager_BuildTCP(t *testing.T) {
}, },
{ {
desc: "Service name with provider", desc: "Service name with provider",
serviceName: "provider-1@serviceName", serviceName: "serviceName@provider-1",
configs: map[string]*config.TCPServiceInfo{ configs: map[string]*config.TCPServiceInfo{
"provider-1@serviceName": { "serviceName@provider-1": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{}, LoadBalancer: &config.TCPLoadBalancerService{},
}, },
@ -90,7 +90,7 @@ func TestManager_BuildTCP(t *testing.T) {
desc: "Service name with provider in context", desc: "Service name with provider in context",
serviceName: "serviceName", serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{ configs: map[string]*config.TCPServiceInfo{
"provider-1@serviceName": { "serviceName@provider-1": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{}, LoadBalancer: &config.TCPLoadBalancerService{},
}, },
@ -102,7 +102,7 @@ func TestManager_BuildTCP(t *testing.T) {
desc: "Server with correct host:port as address", desc: "Server with correct host:port as address",
serviceName: "serviceName", serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{ configs: map[string]*config.TCPServiceInfo{
"provider-1@serviceName": { "serviceName@provider-1": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -120,7 +120,7 @@ func TestManager_BuildTCP(t *testing.T) {
desc: "Server with correct ip:port as address", desc: "Server with correct ip:port as address",
serviceName: "serviceName", serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{ configs: map[string]*config.TCPServiceInfo{
"provider-1@serviceName": { "serviceName@provider-1": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -138,7 +138,7 @@ func TestManager_BuildTCP(t *testing.T) {
desc: "missing port in address with hostname, server is skipped, error is logged", desc: "missing port in address with hostname, server is skipped, error is logged",
serviceName: "serviceName", serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{ configs: map[string]*config.TCPServiceInfo{
"provider-1@serviceName": { "serviceName@provider-1": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -156,7 +156,7 @@ func TestManager_BuildTCP(t *testing.T) {
desc: "missing port in address with ip, server is skipped, error is logged", desc: "missing port in address with ip, server is skipped, error is logged",
serviceName: "serviceName", serviceName: "serviceName",
configs: map[string]*config.TCPServiceInfo{ configs: map[string]*config.TCPServiceInfo{
"provider-1@serviceName": { "serviceName@provider-1": {
TCPService: &config.TCPService{ TCPService: &config.TCPService{
LoadBalancer: &config.TCPLoadBalancerService{ LoadBalancer: &config.TCPLoadBalancerService{
Servers: []config.TCPServer{ Servers: []config.TCPServer{
@ -183,7 +183,7 @@ func TestManager_BuildTCP(t *testing.T) {
ctx := context.Background() ctx := context.Background()
if len(test.providerName) > 0 { if len(test.providerName) > 0 {
ctx = internal.AddProviderInContext(ctx, test.providerName+"@foobar") ctx = internal.AddProviderInContext(ctx, "foobar@"+test.providerName)
} }
handler, err := manager.BuildTCP(ctx, test.serviceName) handler, err := manager.BuildTCP(ctx, test.serviceName)