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

     1  package client
     2  
     3  import (
     4  	"encoding/json"
     5  	"net/url"
     6  
     7  	"github.com/docker/docker/api/types"
     8  	"golang.org/x/net/context"
     9  )
    10  
    11  // CheckpointList returns the checkpoints of the given container in the docker host
    12  func (cli *Client) CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) {
    13  	var checkpoints []types.Checkpoint
    14  
    15  	query := url.Values{}
    16  	if options.CheckpointDir != "" {
    17  		query.Set("dir", options.CheckpointDir)
    18  	}
    19  
    20  	resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil)
    21  	if err != nil {
    22  		return checkpoints, wrapResponseError(err, resp, "container", container)
    23  	}
    24  
    25  	err = json.NewDecoder(resp.body).Decode(&checkpoints)
    26  	ensureReaderClosed(resp)
    27  	return checkpoints, err
    28  }