Signed-off-by: Solomon Hykes <solomon@docker.com>
This commit is contained in:
Solomon Hykes 2014-08-05 05:11:02 +00:00 коммит произвёл Tibor Vass
Родитель 51dd68d659
Коммит 77781440f1
4 изменённых файлов: 39 добавлений и 31 удалений

Просмотреть файл

@ -18,6 +18,7 @@ func (s *TagStore) Install(eng *engine.Engine) error {
eng.Register("image_export", s.CmdImageExport)
eng.Register("history", s.CmdHistory)
eng.Register("images", s.CmdImages)
eng.Register("viz", s.CmdViz)
return nil
}

38
graph/viz.go Normal file
Просмотреть файл

@ -0,0 +1,38 @@
package graph
import (
"strings"
"github.com/docker/docker/engine"
"github.com/docker/docker/image"
)
func (s *TagStore) CmdViz(job *engine.Job) engine.Status {
images, _ := s.graph.Map()
if images == nil {
return engine.StatusOK
}
job.Stdout.Write([]byte("digraph docker {\n"))
var (
parentImage *image.Image
err error
)
for _, image := range images {
parentImage, err = image.GetParent()
if err != nil {
return job.Errorf("Error while getting parent image: %v", err)
}
if parentImage != nil {
job.Stdout.Write([]byte(" \"" + parentImage.ID + "\" -> \"" + image.ID + "\"\n"))
} else {
job.Stdout.Write([]byte(" base -> \"" + image.ID + "\" [style=invis]\n"))
}
}
for id, repos := range s.GetRepoRefs() {
job.Stdout.Write([]byte(" \"" + id + "\" [label=\"" + id + "\\n" + strings.Join(repos, "\\n") + "\",shape=box,fillcolor=\"paleturquoise\",style=\"filled,rounded\"];\n"))
}
job.Stdout.Write([]byte(" base [style=invisible]\n}\n"))
return engine.StatusOK
}

Просмотреть файл

@ -212,36 +212,6 @@ func (srv *Server) recursiveLoad(eng *engine.Engine, address, tmpImageDir string
return nil
}
func (srv *Server) ImagesViz(job *engine.Job) engine.Status {
images, _ := srv.daemon.Graph().Map()
if images == nil {
return engine.StatusOK
}
job.Stdout.Write([]byte("digraph docker {\n"))
var (
parentImage *image.Image
err error
)
for _, image := range images {
parentImage, err = image.GetParent()
if err != nil {
return job.Errorf("Error while getting parent image: %v", err)
}
if parentImage != nil {
job.Stdout.Write([]byte(" \"" + parentImage.ID + "\" -> \"" + image.ID + "\"\n"))
} else {
job.Stdout.Write([]byte(" base -> \"" + image.ID + "\" [style=invis]\n"))
}
}
for id, repos := range srv.daemon.Repositories().GetRepoRefs() {
job.Stdout.Write([]byte(" \"" + id + "\" [label=\"" + id + "\\n" + strings.Join(repos, "\\n") + "\",shape=box,fillcolor=\"paleturquoise\",style=\"filled,rounded\"];\n"))
}
job.Stdout.Write([]byte(" base [style=invisible]\n}\n"))
return engine.StatusOK
}
func (srv *Server) ImageTag(job *engine.Job) engine.Status {
if len(job.Args) != 2 && len(job.Args) != 3 {
return job.Errorf("Usage: %s IMAGE REPOSITORY [TAG]\n", job.Name)

Просмотреть файл

@ -88,7 +88,6 @@ func InitServer(job *engine.Job) engine.Status {
for name, handler := range map[string]engine.Handler{
"tag": srv.ImageTag, // FIXME merge with "image_tag"
"info": srv.DockerInfo,
"viz": srv.ImagesViz,
"log": srv.Log,
"load": srv.ImageLoad,
"build": srv.Build,