diff --git a/client/checkpoint_create.go b/client/checkpoint_create.go index dea2595b1a..b3ba5459d0 100644 --- a/client/checkpoint_create.go +++ b/client/checkpoint_create.go @@ -13,11 +13,16 @@ type CheckpointCreateOptions struct { Exit bool } +// CheckpointCreateResult holds the result from [client.CheckpointCreate]. +type CheckpointCreateResult struct { + // Add future fields here +} + // CheckpointCreate creates a checkpoint from the given container. -func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) error { +func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) (CheckpointCreateResult, error) { containerID, err := trimID("container", containerID) if err != nil { - return err + return CheckpointCreateResult{}, err } requestBody := checkpoint.CreateRequest{ CheckpointID: options.CheckpointID, @@ -27,5 +32,5 @@ func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, opt resp, err := cli.post(ctx, "/containers/"+containerID+"/checkpoints", nil, requestBody, nil) defer ensureReaderClosed(resp) - return err + return CheckpointCreateResult{}, err } diff --git a/client/checkpoint_create_test.go b/client/checkpoint_create_test.go index a69eb183b3..d86d6b047f 100644 --- a/client/checkpoint_create_test.go +++ b/client/checkpoint_create_test.go @@ -1,7 +1,6 @@ package client import ( - "context" "encoding/json" "errors" "fmt" @@ -19,18 +18,18 @@ func TestCheckpointCreateError(t *testing.T) { ) assert.NilError(t, err) - err = client.CheckpointCreate(context.Background(), "nothing", CheckpointCreateOptions{ + _, err = client.CheckpointCreate(t.Context(), "nothing", CheckpointCreateOptions{ CheckpointID: "noting", Exit: true, }) assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) - err = client.CheckpointCreate(context.Background(), "", CheckpointCreateOptions{}) + _, err = client.CheckpointCreate(t.Context(), "", CheckpointCreateOptions{}) assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) assert.Check(t, is.ErrorContains(err, "value is empty")) - err = client.CheckpointCreate(context.Background(), " ", CheckpointCreateOptions{}) + _, err = client.CheckpointCreate(t.Context(), " ", CheckpointCreateOptions{}) assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) assert.Check(t, is.ErrorContains(err, "value is empty")) } @@ -65,7 +64,7 @@ func TestCheckpointCreate(t *testing.T) { ) assert.NilError(t, err) - err = client.CheckpointCreate(context.Background(), expectedContainerID, CheckpointCreateOptions{ + _, err = client.CheckpointCreate(t.Context(), expectedContainerID, CheckpointCreateOptions{ CheckpointID: expectedCheckpointID, Exit: true, }) diff --git a/client/client_interfaces.go b/client/client_interfaces.go index 69ad67ed9b..718127df50 100644 --- a/client/client_interfaces.go +++ b/client/client_interfaces.go @@ -55,7 +55,7 @@ type HijackDialer interface { // and only available if the daemon is running with experimental features // enabled. type CheckpointAPIClient interface { - CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) error + CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) (CheckpointCreateResult, error) CheckpointDelete(ctx context.Context, container string, options CheckpointDeleteOptions) error CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error) } diff --git a/integration/container/checkpoint_test.go b/integration/container/checkpoint_test.go index 80a29fda51..b9c81f395e 100644 --- a/integration/container/checkpoint_test.go +++ b/integration/container/checkpoint_test.go @@ -54,7 +54,7 @@ func TestCheckpoint(t *testing.T) { }() t.Log("Do a checkpoint and leave the container running") - err = apiClient.CheckpointCreate(ctx, cID, client.CheckpointCreateOptions{ + _, err = apiClient.CheckpointCreate(ctx, cID, client.CheckpointCreateOptions{ Exit: false, CheckpointID: "test", }) @@ -90,7 +90,7 @@ func TestCheckpoint(t *testing.T) { // Do a second checkpoint t.Log("Do a checkpoint and stop the container") - err = apiClient.CheckpointCreate(ctx, cID, client.CheckpointCreateOptions{ + _, err = apiClient.CheckpointCreate(ctx, cID, client.CheckpointCreateOptions{ Exit: true, CheckpointID: "test2", }) diff --git a/vendor/github.com/moby/moby/client/checkpoint_create.go b/vendor/github.com/moby/moby/client/checkpoint_create.go index dea2595b1a..b3ba5459d0 100644 --- a/vendor/github.com/moby/moby/client/checkpoint_create.go +++ b/vendor/github.com/moby/moby/client/checkpoint_create.go @@ -13,11 +13,16 @@ type CheckpointCreateOptions struct { Exit bool } +// CheckpointCreateResult holds the result from [client.CheckpointCreate]. +type CheckpointCreateResult struct { + // Add future fields here +} + // CheckpointCreate creates a checkpoint from the given container. -func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) error { +func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) (CheckpointCreateResult, error) { containerID, err := trimID("container", containerID) if err != nil { - return err + return CheckpointCreateResult{}, err } requestBody := checkpoint.CreateRequest{ CheckpointID: options.CheckpointID, @@ -27,5 +32,5 @@ func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, opt resp, err := cli.post(ctx, "/containers/"+containerID+"/checkpoints", nil, requestBody, nil) defer ensureReaderClosed(resp) - return err + return CheckpointCreateResult{}, err } diff --git a/vendor/github.com/moby/moby/client/client_interfaces.go b/vendor/github.com/moby/moby/client/client_interfaces.go index 69ad67ed9b..718127df50 100644 --- a/vendor/github.com/moby/moby/client/client_interfaces.go +++ b/vendor/github.com/moby/moby/client/client_interfaces.go @@ -55,7 +55,7 @@ type HijackDialer interface { // and only available if the daemon is running with experimental features // enabled. type CheckpointAPIClient interface { - CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) error + CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) (CheckpointCreateResult, error) CheckpointDelete(ctx context.Context, container string, options CheckpointDeleteOptions) error CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error) }