Repository: allegro/marathon-consul (go)

Issue:
Handle Mesos healthchecks
Mesos 1.1 introduces HTTP/S and TCP healthchecks. Marathon will support this healthchecks from 1.4. We need to support them too. 

Pull request description:
Fixes #151 | Handle Mesos healthchecks

Patch:
diff --git a/consul/consul.go b/consul/consul.go
index b5688ae..6924267 100644
--- a/consul/consul.go
+++ b/consul/consul.go
@@ -323,9 +323,13 @@ func (c *Consul) marathonToConsulChecks(task *apps.Task, healthChecks []apps.Hea
 		}
 
 		switch check.Protocol {
-		case "HTTP", "HTTPS":
+		case "HTTP", "HTTPS", "MESOS_HTTP", "MESOS_HTTPS":
 			if parsedURL, err := url.ParseRequestURI(check.Path); err == nil {
-				parsedURL.Scheme = strings.ToLower(check.Protocol)
+				if check.Protocol == "HTTP" || check.Protocol == "MESOS_HTTP" {
+					parsedURL.Scheme = "http"
+				} else {
+					parsedURL.Scheme = "https"
+				}
 				parsedURL.Host = fmt.Sprintf("%s:%d", serviceAddress, port)
 				consulCheck.HTTP = parsedURL.String()
 				checks = append(checks, &consulCheck)
@@ -335,7 +339,7 @@ func (c *Consul) marathonToConsulChecks(task *apps.Task, healthChecks []apps.Hea
 					WithField("Address", serviceAddress).
 					Warn(fmt.Sprintf("Could not parse provided path: %s", check.Path))
 			}
-		case "TCP":
+		case "TCP", "MESOS_TCP":
 			consulCheck.TCP = fmt.Sprintf("%s:%d", serviceAddress, port)
 			checks = append(checks, &consulCheck)
 		case "COMMAND":


Test patch:
diff --git a/consul/consul_test.go b/consul/consul_test.go
index 0c17f55..5feb247 100644
--- a/consul/consul_test.go
+++ b/consul/consul_test.go
@@ -829,7 +829,7 @@ func TestMarathonTaskToConsulServiceMapping_IgnoredHealthcheckTypes(t *testing.T
 		HealthChecks: []apps.HealthCheck{
 			{
 				Path:                   "/api/health?with=query",
-				Protocol:               "HTTP",
+				Protocol:               "MESOS_HTTP",
 				PortIndex:              0,
 				IntervalSeconds:        60,
 				TimeoutSeconds:         20,