From b1e8d351abdcdd19a2354901931677db5fc6256a Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Tue, 14 Oct 2014 15:42:49 -0700 Subject: [PATCH] agent: re-use ConsulServiceID from consul package --- command/agent/agent.go | 11 ++++------- command/agent/agent_test.go | 4 ++-- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/command/agent/agent.go b/command/agent/agent.go index eb284efa8a..ee9e58f06e 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -14,9 +14,6 @@ import ( "github.com/hashicorp/serf/serf" ) -// The internal service ID of the consul service -const internalServiceID = "consul" - /* The agent is the long running process that is run on every machine. It exposes an RPC interface that is used by the CLI to control the @@ -120,8 +117,8 @@ func Create(config *Config, logOutput io.Writer) (*Agent, error) { // Automatically register the "consul" service on server nodes consulService := structs.NodeService{ - Service: internalServiceID, - ID: internalServiceID, + Service: consul.ConsulServiceName, + ID: consul.ConsulServiceID, Port: agent.config.Ports.Server, } agent.state.AddService(&consulService) @@ -464,9 +461,9 @@ func (a *Agent) AddService(service *structs.NodeService, chkType *CheckType) err // The agent will make a best effort to ensure it is deregistered func (a *Agent) RemoveService(serviceID string) error { // Protect "consul" service from deletion by a user - if a.server != nil && serviceID == internalServiceID { + if a.server != nil && serviceID == consul.ConsulServiceID { return fmt.Errorf( - "Deregistering the %s service is not allowed", internalServiceID) + "Deregistering the %s service is not allowed", consul.ConsulServiceID) } // Remove service immeidately diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index 1525bcefff..64ae5c873e 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -327,7 +327,7 @@ func TestAgent_ConsulService(t *testing.T) { defer agent.Shutdown() services := agent.state.Services() - if _, ok := services[internalServiceID]; !ok { - t.Fatalf("%s service should be registered", internalServiceID) + if _, ok := services[consul.ConsulServiceID]; !ok { + t.Fatalf("%s service should be registered", consul.ConsulServiceID) } }