зеркало из https://github.com/microsoft/docker.git
Merge pull request #12269 from kostickm/12251-remove-not-empty-check
Remove container name not empty check
This commit is contained in:
Коммит
5395cdcae5
|
@ -21,6 +21,10 @@ func (cli *DockerCli) CmdDiff(args ...string) error {
|
|||
cmd.Require(flag.Exact, 1)
|
||||
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)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -30,6 +30,10 @@ func (cli *DockerCli) CmdRm(args ...string) error {
|
|||
|
||||
var encounteredError error
|
||||
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))
|
||||
if err != nil {
|
||||
fmt.Fprintf(cli.err, "%s\n", err)
|
||||
|
|
|
@ -466,10 +466,6 @@ func getContainersChanges(eng *engine.Engine, version version.Version, w http.Re
|
|||
}
|
||||
|
||||
name := vars["name"]
|
||||
if name == "" {
|
||||
return fmt.Errorf("Container name cannot be empty")
|
||||
}
|
||||
|
||||
d := getDaemon(eng)
|
||||
cont, err := d.Get(name)
|
||||
if err != nil {
|
||||
|
@ -883,10 +879,6 @@ func deleteContainers(eng *engine.Engine, version version.Version, w http.Respon
|
|||
}
|
||||
|
||||
name := vars["name"]
|
||||
if name == "" {
|
||||
return fmt.Errorf("Container name cannot be empty")
|
||||
}
|
||||
|
||||
d := getDaemon(eng)
|
||||
config := &daemon.ContainerRmConfig{
|
||||
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 {
|
||||
// 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
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче