Using net.JoinHostPort instead of handcrafting addrs
This commit is contained in:
parent
b180223f4b
commit
48b9684b1e
|
@ -27,7 +27,9 @@ package consul
|
|||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"net"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -703,12 +705,12 @@ func (c *Syncer) createCheckReg(check *structs.ServiceCheck, serviceReg *consul.
|
|||
}
|
||||
url := url.URL{
|
||||
Scheme: check.Protocol,
|
||||
Host: fmt.Sprintf("%s:%d", host, port),
|
||||
Host: net.JoinHostPort(host, strconv.Itoa(port)),
|
||||
Path: check.Path,
|
||||
}
|
||||
chkReg.HTTP = url.String()
|
||||
case structs.ServiceCheckTCP:
|
||||
chkReg.TCP = fmt.Sprintf("%s:%d", host, port)
|
||||
chkReg.TCP = net.JoinHostPort(host, strconv.Itoa(port))
|
||||
case structs.ServiceCheckScript:
|
||||
chkReg.TTL = (check.Interval + ttlCheckBuffer).String()
|
||||
default:
|
||||
|
|
|
@ -2781,6 +2781,12 @@ func TestTaskDiff(t *testing.T) {
|
|||
Old: "foo",
|
||||
New: "foo",
|
||||
},
|
||||
{
|
||||
Type: DiffTypeNone,
|
||||
Name: "PortLabel",
|
||||
Old: "",
|
||||
New: "",
|
||||
},
|
||||
{
|
||||
Type: DiffTypeNone,
|
||||
Name: "Protocol",
|
||||
|
|
Loading…
Reference in New Issue