DRYed the code
This commit is contained in:
parent
d6da6372cd
commit
a447b1ea3c
|
@ -68,15 +68,10 @@ func (c *ConsulClient) DeRegister(task *structs.Task) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ConsulClient) findPortAndHostForLabel(portLabel string, task *structs.Task) (string, int) {
|
func (c *ConsulClient) findPortAndHostForLabel(portLabel string, task *structs.Task) (string, int) {
|
||||||
var host string
|
|
||||||
var port int
|
|
||||||
for _, network := range task.Resources.Networks {
|
for _, network := range task.Resources.Networks {
|
||||||
if p, ok := network.MapLabelToValues()[portLabel]; ok {
|
if p, ok := network.MapLabelToValues()[portLabel]; ok {
|
||||||
host = network.IP
|
return network.IP, p
|
||||||
port = p
|
|
||||||
break
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return "", 0
|
||||||
return host, port
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue