mirror of https://github.com/docker/cli.git
update for consistency
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
This commit is contained in:
parent
e56ff6bda9
commit
84c187fe0c
|
@ -2,12 +2,13 @@ package opts
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/utils"
|
|
||||||
"net"
|
"net"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"regexp"
|
"regexp"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/dotcloud/docker/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ListOpts type
|
// ListOpts type
|
||||||
|
@ -129,7 +130,7 @@ func ValidateEnv(val string) (string, error) {
|
||||||
return fmt.Sprintf("%s=%s", val, os.Getenv(val)), nil
|
return fmt.Sprintf("%s=%s", val, os.Getenv(val)), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateIpAddress(val string) (string, error) {
|
func ValidateIPAddress(val string) (string, error) {
|
||||||
var ip = net.ParseIP(strings.TrimSpace(val))
|
var ip = net.ParseIP(strings.TrimSpace(val))
|
||||||
if ip != nil {
|
if ip != nil {
|
||||||
return ip.String(), nil
|
return ip.String(), nil
|
||||||
|
|
|
@ -4,25 +4,25 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestValidateIP4(t *testing.T) {
|
func TestValidateIPAddress(t *testing.T) {
|
||||||
if ret, err := ValidateIpAddress(`1.2.3.4`); err != nil || ret == "" {
|
if ret, err := ValidateIPAddress(`1.2.3.4`); err != nil || ret == "" {
|
||||||
t.Fatalf("ValidateIpAddress(`1.2.3.4`) got %s %s", ret, err)
|
t.Fatalf("ValidateIPAddress(`1.2.3.4`) got %s %s", ret, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ret, err := ValidateIpAddress(`127.0.0.1`); err != nil || ret == "" {
|
if ret, err := ValidateIPAddress(`127.0.0.1`); err != nil || ret == "" {
|
||||||
t.Fatalf("ValidateIpAddress(`127.0.0.1`) got %s %s", ret, err)
|
t.Fatalf("ValidateIPAddress(`127.0.0.1`) got %s %s", ret, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ret, err := ValidateIpAddress(`::1`); err != nil || ret == "" {
|
if ret, err := ValidateIPAddress(`::1`); err != nil || ret == "" {
|
||||||
t.Fatalf("ValidateIpAddress(`::1`) got %s %s", ret, err)
|
t.Fatalf("ValidateIPAddress(`::1`) got %s %s", ret, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ret, err := ValidateIpAddress(`127`); err == nil || ret != "" {
|
if ret, err := ValidateIPAddress(`127`); err == nil || ret != "" {
|
||||||
t.Fatalf("ValidateIpAddress(`127`) got %s %s", ret, err)
|
t.Fatalf("ValidateIPAddress(`127`) got %s %s", ret, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if ret, err := ValidateIpAddress(`random invalid string`); err == nil || ret != "" {
|
if ret, err := ValidateIPAddress(`random invalid string`); err == nil || ret != "" {
|
||||||
t.Fatalf("ValidateIpAddress(`random invalid string`) got %s %s", ret, err)
|
t.Fatalf("ValidateIPAddress(`random invalid string`) got %s %s", ret, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue