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 (
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/utils"
|
||||
"net"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"github.com/dotcloud/docker/utils"
|
||||
)
|
||||
|
||||
// ListOpts type
|
||||
|
@ -129,7 +130,7 @@ func ValidateEnv(val string) (string, error) {
|
|||
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))
|
||||
if ip != nil {
|
||||
return ip.String(), nil
|
||||
|
|
|
@ -4,25 +4,25 @@ import (
|
|||
"testing"
|
||||
)
|
||||
|
||||
func TestValidateIP4(t *testing.T) {
|
||||
if ret, err := ValidateIpAddress(`1.2.3.4`); err != nil || ret == "" {
|
||||
t.Fatalf("ValidateIpAddress(`1.2.3.4`) got %s %s", ret, err)
|
||||
func TestValidateIPAddress(t *testing.T) {
|
||||
if ret, err := ValidateIPAddress(`1.2.3.4`); err != nil || ret == "" {
|
||||
t.Fatalf("ValidateIPAddress(`1.2.3.4`) got %s %s", ret, err)
|
||||
}
|
||||
|
||||
if ret, err := ValidateIpAddress(`127.0.0.1`); err != nil || ret == "" {
|
||||
t.Fatalf("ValidateIpAddress(`127.0.0.1`) got %s %s", ret, err)
|
||||
if ret, err := ValidateIPAddress(`127.0.0.1`); err != nil || ret == "" {
|
||||
t.Fatalf("ValidateIPAddress(`127.0.0.1`) got %s %s", ret, err)
|
||||
}
|
||||
|
||||
if ret, err := ValidateIpAddress(`::1`); err != nil || ret == "" {
|
||||
t.Fatalf("ValidateIpAddress(`::1`) got %s %s", ret, err)
|
||||
if ret, err := ValidateIPAddress(`::1`); err != nil || ret == "" {
|
||||
t.Fatalf("ValidateIPAddress(`::1`) got %s %s", ret, err)
|
||||
}
|
||||
|
||||
if ret, err := ValidateIpAddress(`127`); err == nil || ret != "" {
|
||||
t.Fatalf("ValidateIpAddress(`127`) got %s %s", ret, err)
|
||||
if ret, err := ValidateIPAddress(`127`); err == nil || ret != "" {
|
||||
t.Fatalf("ValidateIPAddress(`127`) got %s %s", ret, err)
|
||||
}
|
||||
|
||||
if ret, err := ValidateIpAddress(`random invalid string`); err == nil || ret != "" {
|
||||
t.Fatalf("ValidateIpAddress(`random invalid string`) got %s %s", ret, err)
|
||||
if ret, err := ValidateIPAddress(`random invalid string`); err == nil || ret != "" {
|
||||
t.Fatalf("ValidateIPAddress(`random invalid string`) got %s %s", ret, err)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue