Bläddra i källkod

add image size to -tree

Nate Jones 11 år sedan
förälder
incheckning
b7d1d35c27
2 ändrade filer med 5 tillägg och 4 borttagningar
  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)
 		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>" {
 	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 {
 	} 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)
 		cmdOutput := string(cmdOutputBytes)
 
 
 		regexpStrings := []string{
 		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]+",
 			"(?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{}
 		compiledRegexps := []*regexp.Regexp{}