add image history when listing images

This commit is contained in:
Jesse Duffield 2019-05-19 02:22:07 +10:00
parent 15bd991560
commit 2f1c246fd7
3 changed files with 15 additions and 3 deletions

View file

@ -4,7 +4,6 @@ import (
"context"
"strings"
"github.com/davecgh/go-spew/spew"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/client"
@ -77,7 +76,12 @@ func (c *DockerCommand) GetImages() ([]*Image, error) {
ownImages := make([]*Image, len(images))
for i, image := range images {
c.Log.Warn(spew.Sdump(image))
// func (cli *Client) ImageHistory(ctx context.Context, imageID string) ([]image.HistoryResponseItem, error)
history, err := c.Client.ImageHistory(context.Background(), image.ID)
if err != nil {
return nil, err
}
name := "none"
tags := image.RepoTags
@ -95,6 +99,7 @@ func (c *DockerCommand) GetImages() ([]*Image, error) {
Client: c.Client,
OSCommand: c.OSCommand,
Log: c.Log,
History: history,
}
}

View file

@ -16,6 +16,7 @@ type Image struct {
Tag string
ID string
Image types.ImageSummary
History []types.ImageHistory
Client *client.Client
OSCommand *OSCommand
Log *logrus.Entry

View file

@ -104,7 +104,13 @@ func (gui *Gui) renderImageConfig(mainView *gocui.View, Image *commands.Image, w
if err != nil {
return err
}
gui.renderString(gui.g, "main", string(data))
historyData, err := json.MarshalIndent(&Image.History, "", " ")
if err != nil {
return err
}
gui.renderString(gui.g, "main", string(data)+"\n"+string(historyData))
return nil
}