This commit is contained in:
Nate Jones 2015-11-07 18:32:49 -08:00
parent b86486fdbc
commit f8106ccec6

View file

@ -30,7 +30,6 @@ type ImagesCommand struct {
var imagesCommand ImagesCommand var imagesCommand ImagesCommand
func (x *ImagesCommand) Execute(args []string) error { func (x *ImagesCommand) Execute(args []string) error {
var images *[]Image var images *[]Image
@ -130,7 +129,7 @@ func (x *ImagesCommand) Execute(args []string) error {
// build helper map (image -> children) // build helper map (image -> children)
var imagesByParent = make(map[string][]Image) var imagesByParent = make(map[string][]Image)
imagesByParent = collectChildren(images); imagesByParent = collectChildren(images)
// image ids truncate // image ids truncate
// initialize image informations // initialize image informations
@ -162,7 +161,6 @@ func (x *ImagesCommand) Execute(args []string) error {
return nil return nil
} }
func collectChildren(images *[]Image) map[string][]Image { func collectChildren(images *[]Image) map[string][]Image {
var imagesByParent = make(map[string][]Image) var imagesByParent = make(map[string][]Image)
for _, image := range *images { for _, image := range *images {
@ -176,7 +174,6 @@ func collectChildren(images *[]Image) map[string][]Image {
return imagesByParent return imagesByParent
} }
func collectRoots(images *[]Image) []Image { func collectRoots(images *[]Image) []Image {
var roots []Image var roots []Image
for _, image := range *images { for _, image := range *images {
@ -188,7 +185,6 @@ func collectRoots(images *[]Image) []Image {
return roots return roots
} }
func filterImages(images *[]Image, byParent *map[string][]Image) (filteredImages []Image, filteredChildren map[string][]Image) { func filterImages(images *[]Image, byParent *map[string][]Image) (filteredImages []Image, filteredChildren map[string][]Image) {
for i := 0; i < len(*images); i++ { for i := 0; i < len(*images); i++ {
// image is visible // image is visible
@ -245,7 +241,6 @@ func jsonToText(buffer *bytes.Buffer, noTrunc bool, images []Image, byParent map
} }
} }
func PrintTreeNode(buffer *bytes.Buffer, noTrunc bool, image Image, prefix string) { func PrintTreeNode(buffer *bytes.Buffer, noTrunc bool, image Image, prefix string) {
var imageID string var imageID string
if noTrunc { if noTrunc {
@ -280,12 +275,10 @@ func humanSize(raw int64) string {
return fmt.Sprintf("%.01f %s", rawFloat, sizes[ind]) return fmt.Sprintf("%.01f %s", rawFloat, sizes[ind])
} }
func truncate(id string) string { func truncate(id string) string {
return id[0:12] return id[0:12]
} }
func parseImagesJSON(rawJSON []byte) (*[]Image, error) { func parseImagesJSON(rawJSON []byte) (*[]Image, error) {
var images []Image var images []Image
@ -298,7 +291,6 @@ func parseImagesJSON(rawJSON []byte) (*[]Image, error) {
return &images, nil return &images, nil
} }
func imagesToDot(buffer *bytes.Buffer, images []Image, byParent map[string][]Image) { func imagesToDot(buffer *bytes.Buffer, images []Image, byParent map[string][]Image) {
for _, image := range images { for _, image := range images {
if image.ParentId == "" { if image.ParentId == "" {
@ -315,7 +307,6 @@ func imagesToDot(buffer *bytes.Buffer, images []Image, byParent map[string][]Ima
} }
} }
func jsonToShort(images *[]Image) string { func jsonToShort(images *[]Image) string {
var buffer bytes.Buffer var buffer bytes.Buffer
@ -347,7 +338,6 @@ func jsonToShort(images *[]Image) string {
return buffer.String() return buffer.String()
} }
func init() { func init() {
parser.AddCommand("images", parser.AddCommand("images",
"Visualize docker images.", "Visualize docker images.",