github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/client/image_history.go (about)

     1  package client
     2  
     3  import (
     4  	"encoding/json"
     5  	"net/url"
     6  
     7  	"github.com/docker/docker/api/types/image"
     8  	"golang.org/x/net/context"
     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  	if err != nil {
    16  		return history, err
    17  	}
    18  
    19  	err = json.NewDecoder(serverResp.body).Decode(&history)
    20  	ensureReaderClosed(serverResp)
    21  	return history, err
    22  }