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" "fmt"
"io" "io"
"io/ioutil" "io/ioutil"
"net"
"net/url" "net/url"
"strconv" "strconv"
"strings" "strings"
@ -430,7 +431,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" { if ip == "" {
return "", nil 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) { func (d *Driver) GetIP() (string, error) {

View File

@ -3,6 +3,7 @@ package digitalocean
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net"
"time" "time"
"github.com/digitalocean/godo" "github.com/digitalocean/godo"
@ -228,7 +229,7 @@ func (d *Driver) GetURL() (string, error) {
if err != nil { if err != nil {
return "", err 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) { func (d *Driver) GetState() (state.State, error) {

View File

@ -4,6 +4,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net"
"strings" "strings"
"text/template" "text/template"
"time" "time"
@ -148,7 +149,7 @@ func (d *Driver) GetURL() (string, error) {
if err != nil { if err != nil {
return "", err 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) { func (d *Driver) GetState() (state.State, error) {

View File

@ -118,7 +118,7 @@ func (d *Driver) GetURL() (string, error) {
if err != nil { if err != nil {
return "", err 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) { func (d *Driver) GetState() (state.State, error) {

View File

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

View File

@ -5,6 +5,7 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net"
"os" "os"
"time" "time"
@ -110,7 +111,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" { if ip == "" {
return "", nil 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) { func (d *Driver) GetState() (state.State, error) {

View File

@ -3,6 +3,7 @@ package openstack
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net"
"strings" "strings"
"time" "time"
@ -269,7 +270,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" { if ip == "" {
return "", nil 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) { func (d *Driver) GetIP() (string, error) {

View File

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

View File

@ -171,7 +171,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" { if ip == "" {
return "", nil 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) { func (d *Driver) GetIP() (string, error) {

View File

@ -7,6 +7,8 @@ package vmwarevcloudair
import ( import (
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net"
"strconv"
"strings" "strings"
"github.com/vmware/govcloudair" "github.com/vmware/govcloudair"
@ -196,7 +198,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
} }
func (d *Driver) GetURL() (string, 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) { func (d *Driver) GetIP() (string, error) {

View File

@ -8,6 +8,7 @@ import (
"archive/tar" "archive/tar"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"net"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -181,7 +182,7 @@ func (d *Driver) GetURL() (string, error) {
if ip == "" { if ip == "" {
return "", nil 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) { func (d *Driver) GetIP() (string, error) {