mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Move the option-types to the client and in some cases create a copy for the backend. These types are used to construct query- args, and not marshaled to JSON, and can be replaced with functional options in the client. The CreateOptions type was used both as options-struct for the client, and as struct to marshal/unmarshal the request. For this type, a copy is created in the Client and a new `checkpoint.CreateRequest` is added in the API. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
34 lines
857 B
Go
34 lines
857 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
|
|
}
|
|
|
|
// CheckpointList returns the checkpoints of the given container in the docker host.
|
|
func (cli *Client) CheckpointList(ctx context.Context, container string, options CheckpointListOptions) ([]checkpoint.Summary, error) {
|
|
var checkpoints []checkpoint.Summary
|
|
|
|
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 checkpoints, err
|
|
}
|
|
|
|
err = json.NewDecoder(resp.Body).Decode(&checkpoints)
|
|
return checkpoints, err
|
|
}
|