Browse Source

add image size to -tree

Nate Jones 11 years ago
parent
commit
b7d1d35c27
2 changed files with 5 additions and 4 deletions
  1. 3 2
      commands.go
  2. 2 2
      commands_test.go

+ 3 - 2
commands.go

@@ -1231,10 +1231,11 @@ func PrintTreeNode(cli *DockerCli, noTrunc *bool, image APIImages, prefix string
 		imageID = utils.TruncateID(image.ID)
 	}
 
+	fmt.Fprintf(cli.out, "%s%s Size: %s (virtual %s)", prefix, imageID, utils.HumanSize(image.Size), utils.HumanSize(image.VirtualSize))
 	if image.RepoTags[0] != "<none>:<none>" {
-		fmt.Fprintf(cli.out, "%s%s Tags: %s\n", prefix, imageID, strings.Join(image.RepoTags, ","))
+		fmt.Fprintf(cli.out, " Tags: %s\n", strings.Join(image.RepoTags, ","))
 	} else {
-		fmt.Fprintf(cli.out, "%s%s\n", prefix, imageID)
+		fmt.Fprint(cli.out, "\n")
 	}
 }
 

+ 2 - 2
commands_test.go

@@ -778,11 +778,11 @@ func TestImagesTree(t *testing.T) {
 		cmdOutput := string(cmdOutputBytes)
 
 		regexpStrings := []string{
-			fmt.Sprintf("└─%s Tags: %s:latest", unitTestImageIDShort, unitTestImageName),
+			fmt.Sprintf("└─%s Size: (\\d+.\\d+ MB) \\(virtual \\d+.\\d+ MB\\) Tags: %s:latest", unitTestImageIDShort, unitTestImageName),
 			"(?m)^  └─[0-9a-f]+",
 			"(?m)^    └─[0-9a-f]+",
 			"(?m)^      └─[0-9a-f]+",
-			fmt.Sprintf("        └─%s Tags: test:latest", utils.TruncateID(image.ID)),
+			fmt.Sprintf("        └─%s Size: \\d+.\\d+ kB \\(virtual \\d+.\\d+ MB\\) Tags: test:latest", utils.TruncateID(image.ID)),
 		}
 
 		compiledRegexps := []*regexp.Regexp{}