From 69bb10d42f76498658bc17254d765ba3f9bed850 Mon Sep 17 00:00:00 2001 From: Umputun Date: Wed, 28 Apr 2021 13:40:59 -0500 Subject: [PATCH] fix default docker dest to include container --- app/discovery/provider/docker.go | 2 +- app/discovery/provider/docker_test.go | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/discovery/provider/docker.go b/app/discovery/provider/docker.go index ee3f6e4..9ceb36d 100644 --- a/app/discovery/provider/docker.go +++ b/app/discovery/provider/docker.go @@ -70,7 +70,7 @@ func (d *Docker) List() ([]discovery.URLMapper, error) { res := make([]discovery.URLMapper, 0, len(containers)) for _, c := range containers { enabled, explicit := false, false - srcURL := "^/(.*)" + srcURL := fmt.Sprintf("^/%s/(.*)", c.Name) if d.AutoAPI { enabled = true srcURL = fmt.Sprintf("^/api/%s/(.*)", c.Name) diff --git a/app/discovery/provider/docker_test.go b/app/discovery/provider/docker_test.go index 534e049..5c3ec39 100644 --- a/app/discovery/provider/docker_test.go +++ b/app/discovery/provider/docker_test.go @@ -59,15 +59,15 @@ func TestDocker_List(t *testing.T) { assert.Equal(t, "example.com", res[0].Server) assert.Equal(t, "http://127.0.0.2:12345/ping", res[0].PingURL) - assert.Equal(t, "^/a/(.*)", res[1].SrcMatch.String()) - assert.Equal(t, "http://127.0.0.2:12348/a/$1", res[1].Dst) - assert.Equal(t, "http://127.0.0.2:12348/ping", res[1].PingURL) - assert.Equal(t, "example.com", res[1].Server) + assert.Equal(t, "^/c2/(.*)", res[1].SrcMatch.String()) + assert.Equal(t, "http://127.0.0.3:12346/$1", res[1].Dst) + assert.Equal(t, "http://127.0.0.3:12346/ping", res[1].PingURL) + assert.Equal(t, "*", res[1].Server) - assert.Equal(t, "^/(.*)", res[2].SrcMatch.String()) - assert.Equal(t, "http://127.0.0.3:12346/$1", res[2].Dst) - assert.Equal(t, "http://127.0.0.3:12346/ping", res[2].PingURL) - assert.Equal(t, "*", res[2].Server) + assert.Equal(t, "^/a/(.*)", res[2].SrcMatch.String()) + assert.Equal(t, "http://127.0.0.2:12348/a/$1", res[2].Dst) + assert.Equal(t, "http://127.0.0.2:12348/ping", res[2].PingURL) + assert.Equal(t, "example.com", res[2].Server) } func TestDocker_ListWithAutoAPI(t *testing.T) {