mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
The CheckpointList method previously returned a raw slice of checkpoint.Summary, which made it difficult to extend the API response with additional metadata or fields in the future without breaking backward compatibility. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
39 lines
982 B
Go
39 lines
982 B
Go
package client
|
|
|
|
import (
|
|
"context"
|
|
"encoding/json"
|
|
"net/url"
|
|
|
|
"github.com/moby/moby/api/types/checkpoint"
|
|
)
|
|
|
|
// CheckpointListOptions holds parameters to list checkpoints for a container.
|
|
type CheckpointListOptions struct {
|
|
CheckpointDir string
|
|
}
|
|
|
|
// CheckpointListResult holds the result from the CheckpointList method.
|
|
type CheckpointListResult struct {
|
|
Checkpoints []checkpoint.Summary
|
|
}
|
|
|
|
// CheckpointList returns the checkpoints of the given container in the docker host.
|
|
func (cli *Client) CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error) {
|
|
var out CheckpointListResult
|
|
|
|
query := url.Values{}
|
|
if options.CheckpointDir != "" {
|
|
query.Set("dir", options.CheckpointDir)
|
|
}
|
|
|
|
resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil)
|
|
defer ensureReaderClosed(resp)
|
|
if err != nil {
|
|
return out, err
|
|
}
|
|
|
|
err = json.NewDecoder(resp.Body).Decode(&out.Checkpoints)
|
|
return out, err
|
|
}
|