DRYed the code

This commit is contained in:
Diptanu Choudhury
2015-11-18 01:20:53 -08:00
parent 392a807305
commit df074a54e3

View File

@@ -68,15 +68,10 @@ func (c *ConsulClient) DeRegister(task *structs.Task) error {
}
func (c *ConsulClient) findPortAndHostForLabel(portLabel string, task *structs.Task) (string, int) {
var host string
var port int
for _, network := range task.Resources.Networks {
if p, ok := network.MapLabelToValues()[portLabel]; ok {
host = network.IP
port = p
break
return network.IP, p
}
}
return host, port
return "", 0
}