using switch to determine the state of checks

This commit is contained in:
Diptanu Choudhury 2016-03-25 14:26:56 -07:00
parent b886636f6f
commit 449fdf6fb2

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)
}