mirror of https://github.com/docker/cli.git
Allow providing a custom storage directory for docker checkpoints
Signed-off-by: boucher <rboucher@gmail.com>
This commit is contained in:
parent
4c7160ed7b
commit
a38761aba4
|
@ -1,12 +1,20 @@
|
|||
package client
|
||||
|
||||
import (
|
||||
"net/url"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// CheckpointDelete deletes the checkpoint with the given name from the given container
|
||||
func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, checkpointID string) error {
|
||||
resp, err := cli.delete(ctx, "/containers/"+containerID+"/checkpoints/"+checkpointID, nil, nil)
|
||||
func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, options types.CheckpointDeleteOptions) error {
|
||||
query := url.Values{}
|
||||
if options.CheckpointDir != "" {
|
||||
query.Set("dir", options.CheckpointDir)
|
||||
}
|
||||
|
||||
resp, err := cli.delete(ctx, "/containers/"+containerID+"/checkpoints/"+options.CheckpointID, query, nil)
|
||||
ensureReaderClosed(resp)
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
|
@ -16,7 +17,10 @@ func TestCheckpointDeleteError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
|
||||
err := client.CheckpointDelete(context.Background(), "container_id", "checkpoint_id")
|
||||
err := client.CheckpointDelete(context.Background(), "container_id", types.CheckpointDeleteOptions{
|
||||
CheckpointID: "checkpoint_id",
|
||||
})
|
||||
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
|
@ -40,7 +44,10 @@ func TestCheckpointDelete(t *testing.T) {
|
|||
}),
|
||||
}
|
||||
|
||||
err := client.CheckpointDelete(context.Background(), "container_id", "checkpoint_id")
|
||||
err := client.CheckpointDelete(context.Background(), "container_id", types.CheckpointDeleteOptions{
|
||||
CheckpointID: "checkpoint_id",
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -2,16 +2,22 @@ package client
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
|
||||
"github.com/docker/docker/api/types"
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
// CheckpointList returns the volumes configured in the docker host.
|
||||
func (cli *Client) CheckpointList(ctx context.Context, container string) ([]types.Checkpoint, error) {
|
||||
func (cli *Client) CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error) {
|
||||
var checkpoints []types.Checkpoint
|
||||
|
||||
resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", nil, nil)
|
||||
query := url.Values{}
|
||||
if options.CheckpointDir != "" {
|
||||
query.Set("dir", options.CheckpointDir)
|
||||
}
|
||||
|
||||
resp, err := cli.get(ctx, "/containers/"+container+"/checkpoints", query, nil)
|
||||
if err != nil {
|
||||
return checkpoints, err
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ func TestCheckpointListError(t *testing.T) {
|
|||
client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
|
||||
}
|
||||
|
||||
_, err := client.CheckpointList(context.Background(), "container_id")
|
||||
_, err := client.CheckpointList(context.Background(), "container_id", types.CheckpointListOptions{})
|
||||
if err == nil || err.Error() != "Error response from daemon: Server error" {
|
||||
t.Fatalf("expected a Server Error, got %v", err)
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ func TestCheckpointList(t *testing.T) {
|
|||
}),
|
||||
}
|
||||
|
||||
checkpoints, err := client.CheckpointList(context.Background(), "container_id")
|
||||
checkpoints, err := client.CheckpointList(context.Background(), "container_id", types.CheckpointListOptions{})
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -14,6 +14,9 @@ func (cli *Client) ContainerStart(ctx context.Context, containerID string, optio
|
|||
if len(options.CheckpointID) != 0 {
|
||||
query.Set("checkpoint", options.CheckpointID)
|
||||
}
|
||||
if len(options.CheckpointDir) != 0 {
|
||||
query.Set("checkpoint-dir", options.CheckpointDir)
|
||||
}
|
||||
|
||||
resp, err := cli.post(ctx, "/containers/"+containerID+"/start", query, nil, nil)
|
||||
ensureReaderClosed(resp)
|
||||
|
|
|
@ -13,8 +13,8 @@ type apiClientExperimental interface {
|
|||
// CheckpointAPIClient defines API client methods for the checkpoints
|
||||
type CheckpointAPIClient interface {
|
||||
CheckpointCreate(ctx context.Context, container string, options types.CheckpointCreateOptions) error
|
||||
CheckpointDelete(ctx context.Context, container string, checkpointID string) error
|
||||
CheckpointList(ctx context.Context, container string) ([]types.Checkpoint, error)
|
||||
CheckpointDelete(ctx context.Context, container string, options types.CheckpointDeleteOptions) error
|
||||
CheckpointList(ctx context.Context, container string, options types.CheckpointListOptions) ([]types.Checkpoint, error)
|
||||
}
|
||||
|
||||
// PluginAPIClient defines API client methods for the plugins
|
||||
|
|
Loading…
Reference in New Issue