From 4f044cf2f95bfef99f3e4630b08e2dff1f541138 Mon Sep 17 00:00:00 2001 From: Samuel BERTHE Date: Fri, 8 Apr 2016 15:08:28 +0200 Subject: [PATCH] feat(consul-catalog-provider): + setting unique backend name + backend redirecting to internal container ip --- provider/consul_catalog_test.go | 3 ++- templates/consul_catalog.tmpl | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/provider/consul_catalog_test.go b/provider/consul_catalog_test.go index 9cf309838..413a35cec 100644 --- a/provider/consul_catalog_test.go +++ b/provider/consul_catalog_test.go @@ -63,6 +63,7 @@ func TestConsulCatalogBuildConfig(t *testing.T) { { Service: &api.AgentService{ Service: "test", + Address: "127.0.0.1", Port: 80, }, Node: &api.Node{ @@ -86,7 +87,7 @@ func TestConsulCatalogBuildConfig(t *testing.T) { expectedBackends: map[string]*types.Backend{ "backend-test": { Servers: map[string]types.Server{ - "server-localhost-80": { + "test--127-0-0-1--80": { URL: "http://127.0.0.1:80", }, }, diff --git a/templates/consul_catalog.tmpl b/templates/consul_catalog.tmpl index a51cd341b..d7c5adbc7 100644 --- a/templates/consul_catalog.tmpl +++ b/templates/consul_catalog.tmpl @@ -1,6 +1,6 @@ [backends]{{range .Nodes}} - [backends.backend-{{getBackend .}}.servers.server-{{.Node.Node | replace "." "-"}}-{{.Service.Port}}] - url = "http://{{.Node.Address}}:{{.Service.Port}}" + [backends.backend-{{getBackend .}}.servers.{{.Service.Service | replace "." "-"}}--{{.Service.Address | replace "." "-"}}--{{.Service.Port}}] + url = "http://{{.Service.Address}}:{{.Service.Port}}" {{end}} [frontends]{{range .Services}}