From 7a4c73acaf98d47a3d68a8e1eeee54735b14a21b 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 805cdd1e48..c95910e7a5 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 72a772904a..1d83cfa7e2 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 31744dee9f..0a182d8265 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 "" +}