1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #12269 from kostickm/12251-remove-not-empty-check

Remove container name not empty check
This commit is contained in:
Phil Estes 2015-04-14 17:55:13 -04:00
commit 5395cdcae5
3 changed files with 12 additions and 8 deletions

View file

@ -21,6 +21,10 @@ func (cli *DockerCli) CmdDiff(args ...string) error {
cmd.Require(flag.Exact, 1) cmd.Require(flag.Exact, 1)
cmd.ParseFlags(args, true) cmd.ParseFlags(args, true)
if cmd.Arg(0) == "" {
return fmt.Errorf("Container name cannot be empty")
}
rdr, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/changes", nil, nil) rdr, _, err := cli.call("GET", "/containers/"+cmd.Arg(0)+"/changes", nil, nil)
if err != nil { if err != nil {
return err return err

View file

@ -30,6 +30,10 @@ func (cli *DockerCli) CmdRm(args ...string) error {
var encounteredError error var encounteredError error
for _, name := range cmd.Args() { for _, name := range cmd.Args() {
if name == "" {
return fmt.Errorf("Container name cannot be empty")
}
_, _, err := readBody(cli.call("DELETE", "/containers/"+name+"?"+val.Encode(), nil, nil)) _, _, err := readBody(cli.call("DELETE", "/containers/"+name+"?"+val.Encode(), nil, nil))
if err != nil { if err != nil {
fmt.Fprintf(cli.err, "%s\n", err) fmt.Fprintf(cli.err, "%s\n", err)

View file

@ -466,10 +466,6 @@ func getContainersChanges(eng *engine.Engine, version version.Version, w http.Re
} }
name := vars["name"] name := vars["name"]
if name == "" {
return fmt.Errorf("Container name cannot be empty")
}
d := getDaemon(eng) d := getDaemon(eng)
cont, err := d.Get(name) cont, err := d.Get(name)
if err != nil { if err != nil {
@ -883,10 +879,6 @@ func deleteContainers(eng *engine.Engine, version version.Version, w http.Respon
} }
name := vars["name"] name := vars["name"]
if name == "" {
return fmt.Errorf("Container name cannot be empty")
}
d := getDaemon(eng) d := getDaemon(eng)
config := &daemon.ContainerRmConfig{ config := &daemon.ContainerRmConfig{
ForceRemove: toBool(r.Form.Get("force")), ForceRemove: toBool(r.Form.Get("force")),
@ -895,6 +887,10 @@ func deleteContainers(eng *engine.Engine, version version.Version, w http.Respon
} }
if err := d.ContainerRm(name, config); err != nil { if err := d.ContainerRm(name, config); err != nil {
// Force a 404 for the empty string
if strings.Contains(strings.ToLower(err.Error()), "prefix can't be empty") {
return fmt.Errorf("no such id: \"\"")
}
return err return err
} }