Merge pull request #2281 from narqo/fix-dirvers-geturl

More accurate way to calculate drivers' urls with IPv6 support
This commit is contained in:
David Gageot 2015-11-18 09:23:11 +01:00
commit 41dd8c5878
11 changed files with 21 additions and 12 deletions

View File

@ -6,6 +6,7 @@ import (
"fmt"
"io"
"io/ioutil"
"net"
"net/url"
"strconv"
"strings"
@ -430,7 +431,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" {
return "", nil
}
return fmt.Sprintf("tcp://%s:%d", ip, dockerPort), nil
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, strconv.Itoa(dockerPort))), nil
}
func (d *Driver) GetIP() (string, error) {

View File

@ -3,6 +3,7 @@ package digitalocean
import (
"fmt"
"io/ioutil"
"net"
"time"
"github.com/digitalocean/godo"
@ -228,7 +229,7 @@ func (d *Driver) GetURL() (string, error) {
if err != nil {
return "", err
}
return fmt.Sprintf("tcp://%s:2376", ip), nil
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
}
func (d *Driver) GetState() (state.State, error) {

View File

@ -4,6 +4,7 @@ import (
"bytes"
"fmt"
"io/ioutil"
"net"
"strings"
"text/template"
"time"
@ -148,7 +149,7 @@ func (d *Driver) GetURL() (string, error) {
if err != nil {
return "", err
}
return fmt.Sprintf("tcp://%s:2376", ip), nil
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
}
func (d *Driver) GetState() (state.State, error) {

View File

@ -118,7 +118,7 @@ func (d *Driver) GetURL() (string, error) {
if err != nil {
return "", err
}
return fmt.Sprintf("tcp://%s:2376", ip), nil
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
}
func (d *Driver) GetState() (state.State, error) {

View File

@ -2,6 +2,7 @@ package google
import (
"fmt"
"net"
"strings"
"github.com/docker/machine/libmachine/drivers"
@ -223,8 +224,7 @@ func (d *Driver) GetURL() (string, error) {
if err != nil {
return "", err
}
url := fmt.Sprintf("tcp://%s:2376", ip)
return url, nil
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
}
// GetIP returns the IP address of the GCE instance.

View File

@ -5,6 +5,7 @@ import (
"bytes"
"fmt"
"io/ioutil"
"net"
"os"
"time"
@ -110,7 +111,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" {
return "", nil
}
return fmt.Sprintf("tcp://%s:2376", ip), nil
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
}
func (d *Driver) GetState() (state.State, error) {

View File

@ -3,6 +3,7 @@ package openstack
import (
"fmt"
"io/ioutil"
"net"
"strings"
"time"
@ -269,7 +270,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" {
return "", nil
}
return fmt.Sprintf("tcp://%s:2376", ip), nil
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
}
func (d *Driver) GetIP() (string, error) {

View File

@ -3,6 +3,7 @@ package softlayer
import (
"fmt"
"io/ioutil"
"net"
"os"
"regexp"
"time"
@ -265,7 +266,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" {
return "", nil
}
return "tcp://" + ip + ":2376", nil
return "tcp://" + net.JoinHostPort(ip, "2376"), nil
}
func (d *Driver) GetIP() (string, error) {

View File

@ -171,7 +171,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" {
return "", nil
}
return fmt.Sprintf("tcp://%s:2376", ip), nil
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
}
func (d *Driver) GetIP() (string, error) {

View File

@ -7,6 +7,8 @@ package vmwarevcloudair
import (
"fmt"
"io/ioutil"
"net"
"strconv"
"strings"
"github.com/vmware/govcloudair"
@ -196,7 +198,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
}
func (d *Driver) GetURL() (string, error) {
return fmt.Sprintf("tcp://%s:%d", d.PublicIP, d.DockerPort), nil
return fmt.Sprintf("tcp://%s", net.JoinHostPort(d.PublicIP, strconv.Itoa(d.DockerPort))), nil
}
func (d *Driver) GetIP() (string, error) {

View File

@ -8,6 +8,7 @@ import (
"archive/tar"
"fmt"
"io/ioutil"
"net"
"os"
"path/filepath"
"strings"
@ -181,7 +182,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" {
return "", nil
}
return fmt.Sprintf("tcp://%s:2376", ip), nil
return fmt.Sprintf("tcp://%s", net.JoinHostPort(ip, "2376")), nil
}
func (d *Driver) GetIP() (string, error) {