2018-02-05 16:05:59 -05:00
|
|
|
package client // import "github.com/docker/docker/client"
|
2016-09-06 14:46:37 -04:00
|
|
|
|
|
|
|
import (
|
2018-04-19 18:30:59 -04:00
|
|
|
"context"
|
2016-09-06 14:46:37 -04:00
|
|
|
"encoding/json"
|
2016-09-19 12:01:16 -04:00
|
|
|
"net/url"
|
2016-09-06 14:46:37 -04:00
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
)
|
|
|
|
|
2017-02-03 11:41:35 -05:00
|
|
|
// CheckpointList returns the checkpoints of the given container in the docker host
|
2016-09-19 12:01:16 -04:00
|
|
|
func (cli *Client) CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) {
|
2016-09-06 14:46:37 -04:00
|
|
|
var checkpoints []types.Checkpoint
|
|
|
|
|
2016-09-19 12:01:16 -04: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 07:26:12 -05:00
|
|
|
defer ensureReaderClosed(resp)
|
2016-09-06 14:46:37 -04:00
|
|
|
if err != nil {
|
2022-03-20 11:55:42 -04:00
|
|
|
return checkpoints, err
|
2016-09-06 14:46:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
err = json.NewDecoder(resp.body).Decode(&checkpoints)
|
|
|
|
return checkpoints, err
|
|
|
|
}
|