1
0
Fork 0

clarify automatic service creation/assignment with labels

This commit is contained in:
mpl 2019-09-26 12:48:05 +02:00 committed by Traefiker Bot
parent c8fa059064
commit c6e783e7c3
6 changed files with 156 additions and 5 deletions

View file

@ -798,6 +798,57 @@ func Test_buildConfiguration(t *testing.T) {
},
},
},
{
desc: "one router, one specified but undefined service -> specified one is assigned, but automatic is created instead",
containers: []dockerData{
{
ServiceName: "Test",
Name: "Test",
Labels: map[string]string{
"traefik.http.routers.Router1.rule": "Host(`foo.com`)",
"traefik.http.routers.Router1.service": "Service1",
},
NetworkSettings: networkSettings{
Ports: nat.PortMap{
nat.Port("80/tcp"): []nat.PortBinding{},
},
Networks: map[string]*networkData{
"bridge": {
Name: "bridge",
Addr: "127.0.0.1",
},
},
},
},
},
expected: &dynamic.Configuration{
TCP: &dynamic.TCPConfiguration{
Routers: map[string]*dynamic.TCPRouter{},
Services: map[string]*dynamic.TCPService{},
},
HTTP: &dynamic.HTTPConfiguration{
Routers: map[string]*dynamic.Router{
"Router1": {
Service: "Service1",
Rule: "Host(`foo.com`)",
},
},
Middlewares: map[string]*dynamic.Middleware{},
Services: map[string]*dynamic.Service{
"Test": {
LoadBalancer: &dynamic.ServersLoadBalancer{
Servers: []dynamic.Server{
{
URL: "http://127.0.0.1:80",
},
},
PassHostHeader: true,
},
},
},
},
},
},
{
desc: "two containers with same service name and different passhostheader",
containers: []dockerData{