mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
update for consistency
Docker-DCO-1.1-Signed-off-by: Victor Vieux <vieux@docker.com> (github: vieux)
This commit is contained in:
parent
0abdea9094
commit
b68111713d
4 changed files with 16 additions and 15 deletions
|
@ -51,7 +51,7 @@ func main() {
|
|||
flRoot = flag.String([]string{"g", "-graph"}, "/var/lib/docker", "Path to use as the root of the Docker runtime")
|
||||
flSocketGroup = flag.String([]string{"G", "-group"}, "docker", "Group to assign the unix socket specified by -H when running in daemon mode\nuse '' (the empty string) to disable setting of a group")
|
||||
flEnableCors = flag.Bool([]string{"#api-enable-cors", "-api-enable-cors"}, false, "Enable CORS headers in the remote API")
|
||||
flDns = opts.NewListOpts(opts.ValidateIpAddress)
|
||||
flDns = opts.NewListOpts(opts.ValidateIPAddress)
|
||||
flDnsSearch = opts.NewListOpts(opts.ValidateDnsSearch)
|
||||
flEnableIptables = flag.Bool([]string{"#iptables", "-iptables"}, true, "Enable Docker's addition of iptables rules")
|
||||
flEnableIpForward = flag.Bool([]string{"#ip-forward", "-ip-forward"}, true, "Enable net.ipv4.ip_forward")
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
|||
|
||||
flPublish opts.ListOpts
|
||||
flExpose opts.ListOpts
|
||||
flDns = opts.NewListOpts(opts.ValidateIpAddress)
|
||||
flDns = opts.NewListOpts(opts.ValidateIPAddress)
|
||||
flDnsSearch = opts.NewListOpts(opts.ValidateDnsSearch)
|
||||
flVolumesFrom opts.ListOpts
|
||||
flLxcOpts opts.ListOpts
|
||||
|
|
Loading…
Reference in a new issue