Merge pull request #3613 from vieux/deprecated_viz_job
move viz to a job
This commit is contained in:
commit
f213e2dd6c
4 changed files with 29 additions and 25 deletions
|
@ -4,16 +4,16 @@
|
|||
TODO "/events": getEvents, N
|
||||
ok "/info": getInfo, 1
|
||||
ok "/version": getVersion, 1
|
||||
... "/images/json": getImagesJSON, N
|
||||
TODO "/images/viz": getImagesViz, 0 yes
|
||||
TODO "/images/search": getImagesSearch, N
|
||||
#3490 "/images/{name:.*}/get": getImagesGet, 0
|
||||
TODO "/images/{name:.*}/history": getImagesHistory, N
|
||||
ok "/images/json": getImagesJSON, N
|
||||
ok "/images/viz": getImagesViz, 0 yes
|
||||
#3615 "/images/search": getImagesSearch, N
|
||||
ok "/images/{name:.*}/get": getImagesGet, 0
|
||||
ok "/images/{name:.*}/history": getImagesHistory, N
|
||||
TODO "/images/{name:.*}/json": getImagesByName, 1
|
||||
TODO "/containers/ps": getContainersJSON, N
|
||||
TODO "/containers/json": getContainersJSON, 1
|
||||
ok "/containers/{name:.*}/export": getContainersExport, 0
|
||||
TODO "/containers/{name:.*}/changes": getContainersChanges, N
|
||||
... "/containers/{name:.*}/changes": getContainersChanges, N
|
||||
TODO "/containers/{name:.*}/json": getContainersByName, 1
|
||||
TODO "/containers/{name:.*}/top": getContainersTop, N
|
||||
#3512 "/containers/{name:.*}/attach/ws": wsContainersAttach, 0 yes
|
||||
|
@ -23,22 +23,22 @@ TODO "/auth": postAuth, 0
|
|||
ok "/commit": postCommit, 0
|
||||
TODO "/build": postBuild, 0 yes
|
||||
TODO "/images/create": postImagesCreate, N yes yes (pull)
|
||||
TODO "/images/{name:.*}/insert": postImagesInsert, N yes yes
|
||||
#3559 "/images/{name:.*}/insert": postImagesInsert, N yes yes
|
||||
TODO "/images/load": postImagesLoad, 1 yes (stdin)
|
||||
TODO "/images/{name:.*}/push": postImagesPush, N yes
|
||||
ok "/images/{name:.*}/tag": postImagesTag, 0
|
||||
ok "/containers/create": postContainersCreate, 0
|
||||
ok "/containers/{name:.*}/kill": postContainersKill, 0
|
||||
#3476 "/containers/{name:.*}/restart": postContainersRestart, 0
|
||||
ok "/containers/{name:.*}/restart": postContainersRestart, 0
|
||||
ok "/containers/{name:.*}/start": postContainersStart, 0
|
||||
ok "/containers/{name:.*}/stop": postContainersStop, 0
|
||||
ok "/containers/{name:.*}/wait": postContainersWait, 0
|
||||
ok "/containers/{name:.*}/resize": postContainersResize, 0
|
||||
#3512 "/containers/{name:.*}/attach": postContainersAttach, 0 yes
|
||||
TODO "/containers/{name:.*}/copy": postContainersCopy, 0 yes
|
||||
#3560 "/containers/{name:.*}/copy": postContainersCopy, 0 yes
|
||||
|
||||
**DELETE**
|
||||
#3180 "/containers/{name:.*}": deleteContainers, 0
|
||||
ok "/containers/{name:.*}": deleteContainers, 0
|
||||
TODO "/images/{name:.*}": deleteImages, N
|
||||
|
||||
**OPTIONS**
|
||||
|
|
5
api.go
5
api.go
|
@ -238,10 +238,7 @@ func getImagesViz(srv *Server, version float64, w http.ResponseWriter, r *http.R
|
|||
w.WriteHeader(http.StatusNotFound)
|
||||
return fmt.Errorf("This is now implemented in the client.")
|
||||
}
|
||||
|
||||
if err := srv.ImagesViz(w); err != nil {
|
||||
return err
|
||||
}
|
||||
srv.Eng.ServeHTTP(w, r)
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,10 @@ import (
|
|||
// as the exit status.
|
||||
//
|
||||
func (eng *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
jobName := path.Base(r.URL.Path)
|
||||
jobArgs, exists := r.URL.Query()["a"]
|
||||
var (
|
||||
jobName = path.Base(r.URL.Path)
|
||||
jobArgs, exists = r.URL.Query()["a"]
|
||||
)
|
||||
if !exists {
|
||||
jobArgs = []string{}
|
||||
}
|
||||
|
|
23
server.go
23
server.go
|
@ -135,6 +135,10 @@ func jobInitApi(job *engine.Job) engine.Status {
|
|||
job.Error(err)
|
||||
return engine.StatusErr
|
||||
}
|
||||
if err := job.Eng.Register("viz", srv.ImagesViz); err != nil {
|
||||
job.Error(err)
|
||||
return engine.StatusErr
|
||||
}
|
||||
return engine.StatusOK
|
||||
}
|
||||
|
||||
|
@ -538,12 +542,12 @@ func (srv *Server) ImageInsert(name, url, path string, out io.Writer, sf *utils.
|
|||
return nil
|
||||
}
|
||||
|
||||
func (srv *Server) ImagesViz(out io.Writer) error {
|
||||
func (srv *Server) ImagesViz(job *engine.Job) engine.Status {
|
||||
images, _ := srv.runtime.graph.Map()
|
||||
if images == nil {
|
||||
return nil
|
||||
return engine.StatusOK
|
||||
}
|
||||
out.Write([]byte("digraph docker {\n"))
|
||||
job.Stdout.Write([]byte("digraph docker {\n"))
|
||||
|
||||
var (
|
||||
parentImage *Image
|
||||
|
@ -552,12 +556,13 @@ func (srv *Server) ImagesViz(out io.Writer) error {
|
|||
for _, image := range images {
|
||||
parentImage, err = image.GetParent()
|
||||
if err != nil {
|
||||
return fmt.Errorf("Error while getting parent image: %v", err)
|
||||
job.Errorf("Error while getting parent image: %v", err)
|
||||
return engine.StatusErr
|
||||
}
|
||||
if parentImage != nil {
|
||||
out.Write([]byte(" \"" + parentImage.ID + "\" -> \"" + image.ID + "\"\n"))
|
||||
job.Stdout.Write([]byte(" \"" + parentImage.ID + "\" -> \"" + image.ID + "\"\n"))
|
||||
} else {
|
||||
out.Write([]byte(" base -> \"" + image.ID + "\" [style=invis]\n"))
|
||||
job.Stdout.Write([]byte(" base -> \"" + image.ID + "\" [style=invis]\n"))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -570,10 +575,10 @@ func (srv *Server) ImagesViz(out io.Writer) error {
|
|||
}
|
||||
|
||||
for id, repos := range reporefs {
|
||||
out.Write([]byte(" \"" + id + "\" [label=\"" + id + "\\n" + strings.Join(repos, "\\n") + "\",shape=box,fillcolor=\"paleturquoise\",style=\"filled,rounded\"];\n"))
|
||||
job.Stdout.Write([]byte(" \"" + id + "\" [label=\"" + id + "\\n" + strings.Join(repos, "\\n") + "\",shape=box,fillcolor=\"paleturquoise\",style=\"filled,rounded\"];\n"))
|
||||
}
|
||||
out.Write([]byte(" base [style=invisible]\n}\n"))
|
||||
return nil
|
||||
job.Stdout.Write([]byte(" base [style=invisible]\n}\n"))
|
||||
return engine.StatusOK
|
||||
}
|
||||
|
||||
func (srv *Server) Images(job *engine.Job) engine.Status {
|
||||
|
|
Loading…
Add table
Reference in a new issue