Merge pull request #6365 from vieux/allow_net_none_h
Allow --net=none and -h
This commit is contained in:
commit
15243cdbde
2 changed files with 28 additions and 2 deletions
|
@ -18,7 +18,7 @@ var (
|
||||||
ErrInvalidWorkingDirectory = fmt.Errorf("The working directory is invalid. It needs to be an absolute path.")
|
ErrInvalidWorkingDirectory = fmt.Errorf("The working directory is invalid. It needs to be an absolute path.")
|
||||||
ErrConflictAttachDetach = fmt.Errorf("Conflicting options: -a and -d")
|
ErrConflictAttachDetach = fmt.Errorf("Conflicting options: -a and -d")
|
||||||
ErrConflictDetachAutoRemove = fmt.Errorf("Conflicting options: --rm and -d")
|
ErrConflictDetachAutoRemove = fmt.Errorf("Conflicting options: --rm and -d")
|
||||||
ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and --net")
|
ErrConflictNetworkHostname = fmt.Errorf("Conflicting options: -h and the network mode (--net)")
|
||||||
)
|
)
|
||||||
|
|
||||||
//FIXME Only used in tests
|
//FIXME Only used in tests
|
||||||
|
@ -104,7 +104,7 @@ func parseRun(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Conf
|
||||||
return nil, nil, cmd, ErrConflictDetachAutoRemove
|
return nil, nil, cmd, ErrConflictDetachAutoRemove
|
||||||
}
|
}
|
||||||
|
|
||||||
if *flNetMode != "bridge" && *flHostname != "" {
|
if *flNetMode != "bridge" && *flNetMode != "none" && *flHostname != "" {
|
||||||
return nil, nil, cmd, ErrConflictNetworkHostname
|
return nil, nil, cmd, ErrConflictNetworkHostname
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,3 +22,29 @@ func TestParseLxcConfOpt(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestNetHostname(t *testing.T) {
|
||||||
|
if _, _, _, err := Parse([]string{"-h=name", "img", "cmd"}, nil); err != nil {
|
||||||
|
t.Fatal("Unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, _, _, err := Parse([]string{"--net=host", "img", "cmd"}, nil); err != nil {
|
||||||
|
t.Fatal("Unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, _, _, err := Parse([]string{"-h=name", "--net=bridge", "img", "cmd"}, nil); err != nil {
|
||||||
|
t.Fatal("Unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, _, _, err := Parse([]string{"-h=name", "--net=none", "img", "cmd"}, nil); err != nil {
|
||||||
|
t.Fatal("Unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, _, _, err := Parse([]string{"-h=name", "--net=host", "img", "cmd"}, nil); err != ErrConflictNetworkHostname {
|
||||||
|
t.Fatal("Expected error ErrConflictNetworkHostname, got: %s", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if _, _, _, err := Parse([]string{"-h=name", "--net=container:other", "img", "cmd"}, nil); err != ErrConflictNetworkHostname {
|
||||||
|
t.Fatal("Expected error ErrConflictNetworkHostname, got: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue