This commit is contained in:
Victor Vieux 2013-05-13 12:26:18 +02:00
Родитель 1990c49a62
Коммит e82ff22fae
3 изменённых файлов: 17 добавлений и 6 удалений

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

@ -161,8 +161,8 @@ func TestGetImagesJson(t *testing.T) {
t.Errorf("Excepted 1 image, %d found", len(images2))
}
if images2[0].Id != GetTestImage(runtime).ShortId() {
t.Errorf("Retrieved image Id differs, expected %s, received %s", GetTestImage(runtime).ShortId(), images2[0].Id)
if images2[0].Id != GetTestImage(runtime).Id {
t.Errorf("Retrieved image Id differs, expected %s, received %s", GetTestImage(runtime).Id, images2[0].Id)
}
r3 := httptest.NewRecorder()

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

@ -687,6 +687,7 @@ func CmdImages(args ...string) error {
cmd := Subcmd("images", "[OPTIONS] [NAME]", "List images")
quiet := cmd.Bool("q", false, "only show numeric IDs")
all := cmd.Bool("a", false, "show all images")
noTrunc := cmd.Bool("notrunc", false, "Don't truncate output")
flViz := cmd.Bool("viz", false, "output graph in graphviz format")
if err := cmd.Parse(args); err != nil {
@ -737,9 +738,19 @@ func CmdImages(args ...string) error {
}
if !*quiet {
fmt.Fprintf(w, "%s\t%s\t%s\t%s ago\n", out.Repository, out.Tag, out.Id, HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))))
fmt.Fprintf(w, "%s\t%s\t", out.Repository, out.Tag)
if *noTrunc {
fmt.Fprintf(w, "%s\t", out.Id)
} else {
fmt.Fprintf(w, "%s\t", TruncateId(out.Id))
}
fmt.Fprintf(w, "%s ago\n", HumanDuration(time.Now().Sub(time.Unix(out.Created, 0))))
} else {
fmt.Fprintln(w, out.Id)
if *noTrunc {
fmt.Fprintln(w, out.Id)
} else {
fmt.Fprintln(w, TruncateId(out.Id))
}
}
}

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

@ -161,7 +161,7 @@ func (srv *Server) Images(all bool, filter string) ([]ApiImages, error) {
delete(allImages, id)
out.Repository = name
out.Tag = tag
out.Id = image.ShortId()
out.Id = image.Id
out.Created = image.Created.Unix()
outs = append(outs, out)
}
@ -170,7 +170,7 @@ func (srv *Server) Images(all bool, filter string) ([]ApiImages, error) {
if filter == "" {
for _, image := range allImages {
var out ApiImages
out.Id = image.ShortId()
out.Id = image.Id
out.Created = image.Created.Unix()
outs = append(outs, out)
}