image_history.go 563 B

1234567891011121314151617181920212223
  1. package client
  2. import (
  3. "encoding/json"
  4. "net/url"
  5. "github.com/docker/engine-api/types"
  6. "golang.org/x/net/context"
  7. )
  8. // ImageHistory returns the changes in an image in history format.
  9. func (cli *Client) ImageHistory(ctx context.Context, imageID string) ([]types.ImageHistory, error) {
  10. var history []types.ImageHistory
  11. serverResp, err := cli.get(ctx, "/images/"+imageID+"/history", url.Values{}, nil)
  12. if err != nil {
  13. return history, err
  14. }
  15. err = json.NewDecoder(serverResp.body).Decode(&history)
  16. ensureReaderClosed(serverResp)
  17. return history, err
  18. }