github.com/feiyang21687/docker@v1.5.0/graph/viz.go (about) 1 package graph 2 3 import ( 4 "strings" 5 6 "github.com/docker/docker/engine" 7 "github.com/docker/docker/image" 8 ) 9 10 func (s *TagStore) CmdViz(job *engine.Job) engine.Status { 11 images, _ := s.graph.Map() 12 if images == nil { 13 return engine.StatusOK 14 } 15 job.Stdout.Write([]byte("digraph docker {\n")) 16 17 var ( 18 parentImage *image.Image 19 err error 20 ) 21 for _, image := range images { 22 parentImage, err = image.GetParent() 23 if err != nil { 24 return job.Errorf("Error while getting parent image: %v", err) 25 } 26 if parentImage != nil { 27 job.Stdout.Write([]byte(" \"" + parentImage.ID + "\" -> \"" + image.ID + "\"\n")) 28 } else { 29 job.Stdout.Write([]byte(" base -> \"" + image.ID + "\" [style=invis]\n")) 30 } 31 } 32 33 for id, repos := range s.GetRepoRefs() { 34 job.Stdout.Write([]byte(" \"" + id + "\" [label=\"" + id + "\\n" + strings.Join(repos, "\\n") + "\",shape=box,fillcolor=\"paleturquoise\",style=\"filled,rounded\"];\n")) 35 } 36 job.Stdout.Write([]byte(" base [style=invisible]\n}\n")) 37 return engine.StatusOK 38 }