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")
|
||||
}
|
||||
|
||||
newName := r.URL.Query().Get("name")
|
||||
job := eng.Job("container_rename", vars["name"], newName)
|
||||
job.Setenv("t", r.Form.Get("t"))
|
||||
if err := job.Run(); err != nil {
|
||||
d := getDaemon(eng)
|
||||
name := vars["name"]
|
||||
newName := r.Form.Get("name")
|
||||
if err := d.ContainerRename(name, newName); err != nil {
|
||||
return err
|
||||
}
|
||||
w.WriteHeader(http.StatusNoContent)
|
||||
|
|
|
@ -119,7 +119,6 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
|
|||
for name, method := range map[string]engine.Handler{
|
||||
"commit": daemon.ContainerCommit,
|
||||
"container_copy": daemon.ContainerCopy,
|
||||
"container_rename": daemon.ContainerRename,
|
||||
"container_inspect": daemon.ContainerInspect,
|
||||
"container_stats": daemon.ContainerStats,
|
||||
"create": daemon.ContainerCreate,
|
||||
|
|
|
@ -2,16 +2,12 @@ package daemon
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/docker/docker/engine"
|
||||
)
|
||||
|
||||
func (daemon *Daemon) ContainerRename(job *engine.Job) error {
|
||||
if len(job.Args) != 2 {
|
||||
return fmt.Errorf("usage: %s OLD_NAME NEW_NAME", job.Name)
|
||||
func (daemon *Daemon) ContainerRename(oldName, newName string) error {
|
||||
if oldName == "" || newName == "" {
|
||||
return fmt.Errorf("usage: docker rename OLD_NAME NEW_NAME")
|
||||
}
|
||||
oldName := job.Args[0]
|
||||
newName := job.Args[1]
|
||||
|
||||
container, err := daemon.Get(oldName)
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue