using switch to determine the state of checks

This commit is contained in:
Diptanu Choudhury
2016-03-25 14:26:56 -07:00
parent f8db6a433f
commit bfc2a0d716

View File

@@ -412,13 +412,14 @@ func (c *ConsulService) runCheck(check Check) {
if res.Err != nil {
output = res.Err.Error()
}
if res.ExitCode == 0 {
switch res.ExitCode {
case 0:
state = consul.HealthPassing
}
if res.ExitCode == 1 {
case 1:
state = consul.HealthWarning
default:
state = consul.HealthCritical
}
if err := c.client.Agent().UpdateTTL(check.ID(), output, state); err != nil {
c.logger.Printf("[DEBUG] error updating ttl check for check %q: %v", check.ID(), err)
}