From c9b871a03a92f93704a090cf42e556e5a7ae9638 Mon Sep 17 00:00:00 2001 From: Fernandez Ludovic Date: Mon, 1 Jan 2018 03:37:24 +0100 Subject: [PATCH] feat(consulcatalog): add WhitelistSourceRange tags. --- provider/consul/consul_catalog_config.go | 15 ++++++++------- templates/consul_catalog.tmpl | 7 +++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/provider/consul/consul_catalog_config.go b/provider/consul/consul_catalog_config.go index 8634dc892..e72e48752 100644 --- a/provider/consul/consul_catalog_config.go +++ b/provider/consul/consul_catalog_config.go @@ -39,13 +39,14 @@ func (p *CatalogProvider) buildConfiguration(catalog []catalogUpdate) *types.Con "getMaxConn": p.getMaxConn, // Frontend functions - "getFrontendRule": p.getFrontendRule, - "getBasicAuth": p.getFuncSliceAttribute(label.SuffixFrontendAuthBasic), - "getEntryPoints": getEntryPoints, // Deprecated [breaking] - "getFrontEndEntryPoints": p.getFuncSliceAttribute(label.SuffixFrontendEntryPoints), // TODO [breaking] rename to getEntryPoints when getEntryPoints will be removed - "getPriority": p.getFuncIntAttribute(label.SuffixFrontendPriority, 0), - "getPassHostHeader": p.getFuncBoolAttribute(label.SuffixFrontendPassHostHeader, true), - "getPassTLSCert": p.getFuncBoolAttribute(label.SuffixFrontendPassTLSCert, label.DefaultPassTLSCert), + "getFrontendRule": p.getFrontendRule, + "getBasicAuth": p.getFuncSliceAttribute(label.SuffixFrontendAuthBasic), + "getEntryPoints": getEntryPoints, // Deprecated [breaking] + "getFrontEndEntryPoints": p.getFuncSliceAttribute(label.SuffixFrontendEntryPoints), // TODO [breaking] rename to getEntryPoints when getEntryPoints will be removed + "getPriority": p.getFuncIntAttribute(label.SuffixFrontendPriority, 0), + "getPassHostHeader": p.getFuncBoolAttribute(label.SuffixFrontendPassHostHeader, true), + "getPassTLSCert": p.getFuncBoolAttribute(label.SuffixFrontendPassTLSCert, label.DefaultPassTLSCert), + "getWhitelistSourceRange": p.getFuncSliceAttribute(label.SuffixFrontendWhitelistSourceRange), } var allNodes []*api.ServiceEntry diff --git a/templates/consul_catalog.tmpl b/templates/consul_catalog.tmpl index 0d70a44cf..66df8bec3 100644 --- a/templates/consul_catalog.tmpl +++ b/templates/consul_catalog.tmpl @@ -48,6 +48,13 @@ "{{.}}", {{end}}] + {{ $whitelistSourceRange := getWhitelistSourceRange $service.Attributes }} + {{if $whitelistSourceRange }} + whitelistSourceRange = [{{range $whitelistSourceRange}} + "{{.}}", + {{end}}] + {{end}} + basicAuth = [{{range getBasicAuth $service.Attributes }} "{{.}}", {{end}}]