mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Move "changes" to daemon/changes.go
This is part of an effort to break apart the deprecated server/ package Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes) Fix issues with renaming changes to container_changes Docker-DCO-1.1-Signed-off-by: Tibor Vass <teabee89@gmail.com> (github: tiborvass)
This commit is contained in:
parent
06229a4b76
commit
49e61f62ce
5 changed files with 36 additions and 29 deletions
|
@ -302,7 +302,7 @@ func getContainersChanges(eng *engine.Engine, version version.Version, w http.Re
|
|||
if vars == nil {
|
||||
return fmt.Errorf("Missing parameter")
|
||||
}
|
||||
var job = eng.Job("changes", vars["name"])
|
||||
var job = eng.Job("container_changes", vars["name"])
|
||||
streamJSON(job, w, false)
|
||||
|
||||
return job.Run()
|
||||
|
|
32
daemon/changes.go
Normal file
32
daemon/changes.go
Normal file
|
@ -0,0 +1,32 @@
|
|||
package daemon
|
||||
|
||||
import (
|
||||
"github.com/docker/docker/engine"
|
||||
)
|
||||
|
||||
func (daemon *Daemon) ContainerChanges(job *engine.Job) engine.Status {
|
||||
if n := len(job.Args); n != 1 {
|
||||
return job.Errorf("Usage: %s CONTAINER", job.Name)
|
||||
}
|
||||
name := job.Args[0]
|
||||
if container := daemon.Get(name); container != nil {
|
||||
outs := engine.NewTable("", 0)
|
||||
changes, err := container.Changes()
|
||||
if err != nil {
|
||||
return job.Error(err)
|
||||
}
|
||||
for _, change := range changes {
|
||||
out := &engine.Env{}
|
||||
if err := out.Import(change); err != nil {
|
||||
return job.Error(err)
|
||||
}
|
||||
outs.Add(out)
|
||||
}
|
||||
if _, err := outs.WriteListTo(job.Stdout); err != nil {
|
||||
return job.Error(err)
|
||||
}
|
||||
} else {
|
||||
return job.Errorf("No such container: %s", name)
|
||||
}
|
||||
return engine.StatusOK
|
||||
}
|
|
@ -155,6 +155,9 @@ func (daemon *Daemon) Install(eng *engine.Engine) error {
|
|||
if err := eng.Register("container_copy", daemon.ContainerCopy); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := eng.Register("container_changes", daemon.ContainerChanges); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -86,33 +86,6 @@ func (srv *Server) ContainerTop(job *engine.Job) engine.Status {
|
|||
return job.Errorf("No such container: %s", name)
|
||||
}
|
||||
|
||||
func (srv *Server) ContainerChanges(job *engine.Job) engine.Status {
|
||||
if n := len(job.Args); n != 1 {
|
||||
return job.Errorf("Usage: %s CONTAINER", job.Name)
|
||||
}
|
||||
name := job.Args[0]
|
||||
if container := srv.daemon.Get(name); container != nil {
|
||||
outs := engine.NewTable("", 0)
|
||||
changes, err := container.Changes()
|
||||
if err != nil {
|
||||
return job.Error(err)
|
||||
}
|
||||
for _, change := range changes {
|
||||
out := &engine.Env{}
|
||||
if err := out.Import(change); err != nil {
|
||||
return job.Error(err)
|
||||
}
|
||||
outs.Add(out)
|
||||
}
|
||||
if _, err := outs.WriteListTo(job.Stdout); err != nil {
|
||||
return job.Error(err)
|
||||
}
|
||||
} else {
|
||||
return job.Errorf("No such container: %s", name)
|
||||
}
|
||||
return engine.StatusOK
|
||||
}
|
||||
|
||||
func (srv *Server) Containers(job *engine.Job) engine.Status {
|
||||
var (
|
||||
foundBefore bool
|
||||
|
|
|
@ -93,7 +93,6 @@ func InitServer(job *engine.Job) engine.Status {
|
|||
"history": srv.ImageHistory,
|
||||
"viz": srv.ImagesViz,
|
||||
"log": srv.Log,
|
||||
"changes": srv.ContainerChanges,
|
||||
"top": srv.ContainerTop,
|
||||
"load": srv.ImageLoad,
|
||||
"build": srv.Build,
|
||||
|
|
Loading…
Reference in a new issue