From 3726cb52c708fc1d29420650836ebfc50b34ecce Mon Sep 17 00:00:00 2001 From: Daniel Nephin Date: Thu, 10 Jun 2021 17:19:16 -0400 Subject: [PATCH] http: add PrimaryDatacenter to the /v1/agent/self response This field is available in DebugConfig, but that field is not stable and could change at any time. The consul-k8s needs to be able to detect the primary DC for tests, so adding this field to the stable part of the API response. --- agent/agent_endpoint.go | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/agent/agent_endpoint.go b/agent/agent_endpoint.go index babb906f09..add31531bb 100644 --- a/agent/agent_endpoint.go +++ b/agent/agent_endpoint.go @@ -74,19 +74,21 @@ func (s *HTTPHandlers) AgentSelf(resp http.ResponseWriter, req *http.Request) (i } config := struct { - Datacenter string - NodeName string - NodeID string - Revision string - Server bool - Version string + Datacenter string + PrimaryDatacenter string + NodeName string + NodeID string + Revision string + Server bool + Version string }{ - Datacenter: s.agent.config.Datacenter, - NodeName: s.agent.config.NodeName, - NodeID: string(s.agent.config.NodeID), - Revision: s.agent.config.Revision, - Server: s.agent.config.ServerMode, - Version: s.agent.config.Version, + Datacenter: s.agent.config.Datacenter, + PrimaryDatacenter: s.agent.config.PrimaryDatacenter, + NodeName: s.agent.config.NodeName, + NodeID: string(s.agent.config.NodeID), + Revision: s.agent.config.Revision, + Server: s.agent.config.ServerMode, + Version: s.agent.config.Version, } return Self{ Config: config,