github.com/Heebron/moby@v0.0.0-20221111184709-6eab4f55faf7/client/image_history.go (about) 1 package client // import "github.com/docker/docker/client" 2 3 import ( 4 "context" 5 "encoding/json" 6 "net/url" 7 8 "github.com/docker/docker/api/types/image" 9 ) 10 11 // ImageHistory returns the changes in an image in history format. 12 func (cli *Client) ImageHistory(ctx context.Context, imageID string) ([]image.HistoryResponseItem, error) { 13 var history []image.HistoryResponseItem 14 serverResp, err := cli.get(ctx, "/images/"+imageID+"/history", url.Values{}, nil) 15 defer ensureReaderClosed(serverResp) 16 if err != nil { 17 return history, err 18 } 19 20 err = json.NewDecoder(serverResp.body).Decode(&history) 21 return history, err 22 }