mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Remove Job from rename
A part of ISSUE#12151-Remove engine.Job mechanism Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
parent
91abff41dd
commit
49c4de4aeb
3 changed files with 7 additions and 12 deletions
|
@ -859,10 +859,10 @@ func postContainerRename(eng *engine.Engine, version version.Version, w http.Res
|
||||||
return fmt.Errorf("Missing parameter")
|
return fmt.Errorf("Missing parameter")
|
||||||
}
|
}
|
||||||
|
|
||||||
newName := r.URL.Query().Get("name")
|
d := getDaemon(eng)
|
||||||
job := eng.Job("container_rename", vars["name"], newName)
|
name := vars["name"]
|
||||||
job.Setenv("t", r.Form.Get("t"))
|
newName := r.Form.Get("name")
|
||||||
if err := job.Run(); err != nil {
|
if err := d.ContainerRename(name, newName); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
w.WriteHeader(http.StatusNoContent)
|
w.WriteHeader(http.StatusNoContent)
|
||||||
|
|
|
@ -119,7 +119,6 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
|
||||||
for name, method := range map[string]engine.Handler{
|
for name, method := range map[string]engine.Handler{
|
||||||
"commit": daemon.ContainerCommit,
|
"commit": daemon.ContainerCommit,
|
||||||
"container_copy": daemon.ContainerCopy,
|
"container_copy": daemon.ContainerCopy,
|
||||||
"container_rename": daemon.ContainerRename,
|
|
||||||
"container_inspect": daemon.ContainerInspect,
|
"container_inspect": daemon.ContainerInspect,
|
||||||
"container_stats": daemon.ContainerStats,
|
"container_stats": daemon.ContainerStats,
|
||||||
"create": daemon.ContainerCreate,
|
"create": daemon.ContainerCreate,
|
||||||
|
|
|
@ -2,16 +2,12 @@ package daemon
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/docker/docker/engine"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (daemon *Daemon) ContainerRename(job *engine.Job) error {
|
func (daemon *Daemon) ContainerRename(oldName, newName string) error {
|
||||||
if len(job.Args) != 2 {
|
if oldName == "" || newName == "" {
|
||||||
return fmt.Errorf("usage: %s OLD_NAME NEW_NAME", job.Name)
|
return fmt.Errorf("usage: docker rename OLD_NAME NEW_NAME")
|
||||||
}
|
}
|
||||||
oldName := job.Args[0]
|
|
||||||
newName := job.Args[1]
|
|
||||||
|
|
||||||
container, err := daemon.Get(oldName)
|
container, err := daemon.Get(oldName)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue