From fbb5c28c80a71ee7a386fae4b78286d4221bd784 Mon Sep 17 00:00:00 2001 From: Matt Keeler Date: Tue, 28 Apr 2020 09:44:26 -0400 Subject: [PATCH] Updates to allow for using an enterprise specific token as the agents token This is needed to allow for managed Consul instances to register themselves in the catalog with one of the managed service provider tokens. --- agent/agent.go | 2 +- agent/token/store.go | 4 ++++ agent/token/store_oss.go | 5 +++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/agent/agent.go b/agent/agent.go index 805cdd1e4..c95910e7a 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -1412,7 +1412,7 @@ func (a *Agent) consulConfig() (*consul.Config, error) { } base.ConfigEntryBootstrap = a.config.ConfigEntryBootstrap - + return a.enterpriseConsulConfig(base) } diff --git a/agent/token/store.go b/agent/token/store.go index 72a772904..1d83cfa7e 100644 --- a/agent/token/store.go +++ b/agent/token/store.go @@ -113,6 +113,10 @@ func (t *Store) AgentToken() string { t.l.RLock() defer t.l.RUnlock() + if tok := t.enterpriseAgentToken(); tok != "" { + return tok + } + if t.agentToken != "" { return t.agentToken } diff --git a/agent/token/store_oss.go b/agent/token/store_oss.go index 31744dee9..0a182d826 100644 --- a/agent/token/store_oss.go +++ b/agent/token/store_oss.go @@ -5,3 +5,8 @@ package token // Stub for enterpriseTokens type enterpriseTokens struct { } + +// enterpriseAgentToken OSS stub +func (s *Store) enterpriseAgentToken() string { + return "" +}