2018-02-05 21:05:59 +00:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2016-09-06 18:46:37 +00:00
|
|
|
|
|
|
|
import (
|
2018-04-19 22:30:59 +00:00
|
|
|
"context"
|
2016-09-06 18:46:37 +00:00
|
|
|
"encoding/json"
|
2016-09-19 16:01:16 +00:00
|
|
|
"net/url"
|
2016-09-06 18:46:37 +00:00
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
)
|
|
|
|
|
2017-02-03 16:41:35 +00:00
|
|
|
// CheckpointList returns the checkpoints of the given container in the docker host
|
2016-09-19 16:01:16 +00:00
|
|
|
func (cli *Client) CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) {
|
2016-09-06 18:46:37 +00:00
|
|
|
var checkpoints []types.Checkpoint
|
|
|
|
|
2016-09-19 16:01:16 +00:00
|
|
|
query := url.Values{}
|
|
|
|
if options.CheckpointDir != "" {
|
|
|
|
query.Set("dir", options.CheckpointDir)
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil)
|
2019-02-11 12:26:12 +00:00
|
|
|
defer ensureReaderClosed(resp)
|
2016-09-06 18:46:37 +00:00
|
|
|
if err != nil {
|
2017-09-08 16:04:34 +00:00
|
|
|
return checkpoints, wrapResponseError(err, resp, "container", container)
|
2016-09-06 18:46:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
err = json.NewDecoder(resp.body).Decode(&checkpoints)
|
|
|
|
return checkpoints, err
|
|
|
|
}
|