agent: re-use ConsulServiceID from consul package
This commit is contained in:
parent
5e66e2ae1e
commit
ece81c11ac
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue