Skip to content

Commit 0735f3f

Browse files
author
Vladimir Varankin
committed
fix drivers GetUrl to build propper IPv6 addr
Signed-off-by: Vladimir Varankin <nek.narqo+git@gmail.com>
1 parent 45d38fd commit 0735f3f

File tree

11 files changed

+21
-12
lines changed

11 files changed

+21
-12
lines changed

drivers/amazonec2/amazonec2.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"fmt"
77
"io"
88
"io/ioutil"
9+
"net"
910
"net/url"
1011
"strconv"
1112
"strings"
@@ -430,7 +431,7 @@ func (d *Driver) GetURL() (string, error) {
430431
if ip == "" {
431432
return "", nil
432433
}
433-
return fmt.Sprintf("tcp://%s:%d", ip, dockerPort), nil
434+
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, strconv.Itoa(dockerPort))), nil
434435
}
435436

436437
func (d *Driver) GetIP() (string, error) {

drivers/digitalocean/digitalocean.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package digitalocean
33
import (
44
"fmt"
55
"io/ioutil"
6+
"net"
67
"time"
78

89
"github.com/digitalocean/godo"
@@ -228,7 +229,7 @@ func (d *Driver) GetURL() (string, error) {
228229
if err != nil {
229230
return "", err
230231
}
231-
return fmt.Sprintf("tcp://%s:2376", ip), nil
232+
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
232233
}
233234

234235
func (d *Driver) GetState() (state.State, error) {

drivers/exoscale/exoscale.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"fmt"
66
"io/ioutil"
7+
"net"
78
"strings"
89
"text/template"
910
"time"
@@ -148,7 +149,7 @@ func (d *Driver) GetURL() (string, error) {
148149
if err != nil {
149150
return "", err
150151
}
151-
return fmt.Sprintf("tcp://%s:2376", ip), nil
152+
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
152153
}
153154

154155
func (d *Driver) GetState() (state.State, error) {

drivers/generic/generic.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ func (d *Driver) GetURL() (string, error) {
118118
if err != nil {
119119
return "", err
120120
}
121-
return fmt.Sprintf("tcp://%s:2376", ip), nil
121+
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
122122
}
123123

124124
func (d *Driver) GetState() (state.State, error) {

drivers/google/google.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package google
22

33
import (
44
"fmt"
5+
"net"
56
"strings"
67

78
"github.com/docker/machine/libmachine/drivers"
@@ -223,8 +224,7 @@ func (d *Driver) GetURL() (string, error) {
223224
if err != nil {
224225
return "", err
225226
}
226-
url := fmt.Sprintf("tcp://%s:2376", ip)
227-
return url, nil
227+
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
228228
}
229229

230230
// GetIP returns the IP address of the GCE instance.

drivers/hyperv/hyperv.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"bytes"
66
"fmt"
77
"io/ioutil"
8+
"net"
89
"os"
910
"time"
1011

@@ -110,7 +111,7 @@ func (d *Driver) GetURL() (string, error) {
110111
if ip == "" {
111112
return "", nil
112113
}
113-
return fmt.Sprintf("tcp://%s:2376", ip), nil
114+
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
114115
}
115116

116117
func (d *Driver) GetState() (state.State, error) {

drivers/openstack/openstack.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package openstack
33
import (
44
"fmt"
55
"io/ioutil"
6+
"net"
67
"strings"
78
"time"
89

@@ -269,7 +270,7 @@ func (d *Driver) GetURL() (string, error) {
269270
if ip == "" {
270271
return "", nil
271272
}
272-
return fmt.Sprintf("tcp://%s:2376", ip), nil
273+
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
273274
}
274275

275276
func (d *Driver) GetIP() (string, error) {

drivers/softlayer/driver.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package softlayer
33
import (
44
"fmt"
55
"io/ioutil"
6+
"net"
67
"os"
78
"regexp"
89
"time"
@@ -265,7 +266,7 @@ func (d *Driver) GetURL() (string, error) {
265266
if ip == "" {
266267
return "", nil
267268
}
268-
return "tcp://" + ip + ":2376", nil
269+
return "tcp://" + net.JoinHostPort(ip, "2376"), nil
269270
}
270271

271272
func (d *Driver) GetIP() (string, error) {

drivers/vmwarefusion/fusion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ func (d *Driver) GetURL() (string, error) {
171171
if ip == "" {
172172
return "", nil
173173
}
174-
return fmt.Sprintf("tcp://%s:2376", ip), nil
174+
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
175175
}
176176

177177
func (d *Driver) GetIP() (string, error) {

drivers/vmwarevcloudair/vcloudair.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ package vmwarevcloudair
77
import (
88
"fmt"
99
"io/ioutil"
10+
"net"
11+
"strconv"
1012
"strings"
1113

1214
"github.com/vmware/govcloudair"
@@ -196,7 +198,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
196198
}
197199

198200
func (d *Driver) GetURL() (string, error) {
199-
return fmt.Sprintf("tcp://%s:%d", d.PublicIP, d.DockerPort), nil
201+
return fmt.Sprintf("tcp://%s", net.JoinHostPort(d.PublicIP, strconv.Itoa(d.DockerPort))), nil
200202
}
201203

202204
func (d *Driver) GetIP() (string, error) {

0 commit comments

Comments
 (0)