From bfc2a0d716b50b4d7057e7bdbc6f9fe05bd73d4e Mon Sep 17 00:00:00 2001 From: Diptanu Choudhury Date: Fri, 25 Mar 2016 14:26:56 -0700 Subject: [PATCH] using switch to determine the state of checks --- client/consul/sync.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/client/consul/sync.go b/client/consul/sync.go index 5b9e96ea2..4d20ba15c 100644 --- a/client/consul/sync.go +++ b/client/consul/sync.go @@ -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) }