checkpoint_list.go 841 B

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