From 124e7bfa7e7c337598c8f34aaa0e129bdd793f49 Mon Sep 17 00:00:00 2001 From: Ryan Uber Date: Wed, 21 Jan 2015 14:45:09 -0800 Subject: [PATCH] agent: use const for default maintenance reason strings --- command/agent/agent.go | 10 ++++++++-- command/agent/agent_test.go | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/command/agent/agent.go b/command/agent/agent.go index 1a22f859ad..7ec832e709 100644 --- a/command/agent/agent.go +++ b/command/agent/agent.go @@ -34,6 +34,12 @@ const ( // The ID of the faux health checks for maintenance mode serviceMaintCheckPrefix = "_service_maintenance" nodeMaintCheckID = "_node_maintenance" + + // Default reasons for node/service maintenance mode + defaultNodeMaintReason = "Maintenance mode is enabled for this node, " + + "but no reason was provided. This is a default message." + defaultServiceMaintReason = "Maintenance mode is enabled for this " + + "service, but no reason was provided. This is a default message." ) /* @@ -1041,7 +1047,7 @@ func (a *Agent) EnableServiceMaintenance(serviceID, reason string) error { // Use default notes if no reason provided if reason == "" { - reason = "Maintenance mode is enabled for this service" + reason = defaultServiceMaintReason } // Create and register the critical health check @@ -1089,7 +1095,7 @@ func (a *Agent) EnableNodeMaintenance(reason string) { // Use a default notes value if reason == "" { - reason = "Maintenance mode is enabled for this node" + reason = defaultNodeMaintReason } // Create and register the node maintenance check diff --git a/command/agent/agent_test.go b/command/agent/agent_test.go index a09d789666..0a702263ff 100644 --- a/command/agent/agent_test.go +++ b/command/agent/agent_test.go @@ -952,7 +952,7 @@ func TestAgent_ServiceMaintenanceMode(t *testing.T) { if !ok { t.Fatalf("should have registered critical check") } - if check.Notes == "" { + if check.Notes != defaultServiceMaintReason { t.Fatalf("bad: %#v", check) } } @@ -993,7 +993,7 @@ func TestAgent_NodeMaintenanceMode(t *testing.T) { if !ok { t.Fatalf("should have registered critical node check") } - if check.Notes == "" { + if check.Notes != defaultNodeMaintReason { t.Fatalf("bad: %#v", check) } }