2016-09-06 14:46:37 -04:00
|
|
|
package client
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
2017-02-01 17:40:43 -05:00
|
|
|
"net/http"
|
2016-09-19 12:01:16 -04:00
|
|
|
"net/url"
|
2016-09-06 14:46:37 -04:00
|
|
|
|
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
)
|
|
|
|
|
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)
|
2016-09-06 14:46:37 -04:00
|
|
|
if err != nil {
|
2017-02-01 17:40:43 -05:00
|
|
|
if resp.statusCode == http.StatusNotFound {
|
|
|
|
return checkpoints, containerNotFoundError{container}
|
|
|
|
}
|
2016-09-06 14:46:37 -04:00
|
|
|
return checkpoints, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = json.NewDecoder(resp.body).Decode(&checkpoints)
|
|
|
|
ensureReaderClosed(resp)
|
|
|
|
return checkpoints, err
|
|
|
|
}
|