Skip to content

Commit

Permalink
agent: use const for default maintenance reason strings
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanuber committed Jan 21, 2015
1 parent 52ff08b commit 124e7bf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
10 changes: 8 additions & 2 deletions command/agent/agent.go
Original file line number Diff line number Diff line change
Expand Up @@ -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."
)

/*
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions command/agent/agent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down Expand Up @@ -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)
}
}

0 comments on commit 124e7bf

Please sign in to comment.