Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
| ... | ... |
@@ -13,11 +13,16 @@ type CheckpointCreateOptions struct {
|
| 13 | 13 |
Exit bool |
| 14 | 14 |
} |
| 15 | 15 |
|
| 16 |
+// CheckpointCreateResult holds the result from [client.CheckpointCreate]. |
|
| 17 |
+type CheckpointCreateResult struct {
|
|
| 18 |
+ // Add future fields here |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 16 | 21 |
// CheckpointCreate creates a checkpoint from the given container. |
| 17 |
-func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) error {
|
|
| 22 |
+func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) (CheckpointCreateResult, error) {
|
|
| 18 | 23 |
containerID, err := trimID("container", containerID)
|
| 19 | 24 |
if err != nil {
|
| 20 |
- return err |
|
| 25 |
+ return CheckpointCreateResult{}, err
|
|
| 21 | 26 |
} |
| 22 | 27 |
requestBody := checkpoint.CreateRequest{
|
| 23 | 28 |
CheckpointID: options.CheckpointID, |
| ... | ... |
@@ -27,5 +32,5 @@ func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, opt |
| 27 | 27 |
|
| 28 | 28 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/checkpoints", nil, requestBody, nil) |
| 29 | 29 |
defer ensureReaderClosed(resp) |
| 30 |
- return err |
|
| 30 |
+ return CheckpointCreateResult{}, err
|
|
| 31 | 31 |
} |
| ... | ... |
@@ -1,7 +1,6 @@ |
| 1 | 1 |
package client |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
- "context" |
|
| 5 | 4 |
"encoding/json" |
| 6 | 5 |
"errors" |
| 7 | 6 |
"fmt" |
| ... | ... |
@@ -19,18 +18,18 @@ func TestCheckpointCreateError(t *testing.T) {
|
| 19 | 19 |
) |
| 20 | 20 |
assert.NilError(t, err) |
| 21 | 21 |
|
| 22 |
- err = client.CheckpointCreate(context.Background(), "nothing", CheckpointCreateOptions{
|
|
| 22 |
+ _, err = client.CheckpointCreate(t.Context(), "nothing", CheckpointCreateOptions{
|
|
| 23 | 23 |
CheckpointID: "noting", |
| 24 | 24 |
Exit: true, |
| 25 | 25 |
}) |
| 26 | 26 |
|
| 27 | 27 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal)) |
| 28 | 28 |
|
| 29 |
- err = client.CheckpointCreate(context.Background(), "", CheckpointCreateOptions{})
|
|
| 29 |
+ _, err = client.CheckpointCreate(t.Context(), "", CheckpointCreateOptions{})
|
|
| 30 | 30 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 31 | 31 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 32 | 32 |
|
| 33 |
- err = client.CheckpointCreate(context.Background(), " ", CheckpointCreateOptions{})
|
|
| 33 |
+ _, err = client.CheckpointCreate(t.Context(), " ", CheckpointCreateOptions{})
|
|
| 34 | 34 |
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument)) |
| 35 | 35 |
assert.Check(t, is.ErrorContains(err, "value is empty")) |
| 36 | 36 |
} |
| ... | ... |
@@ -65,7 +64,7 @@ func TestCheckpointCreate(t *testing.T) {
|
| 65 | 65 |
) |
| 66 | 66 |
assert.NilError(t, err) |
| 67 | 67 |
|
| 68 |
- err = client.CheckpointCreate(context.Background(), expectedContainerID, CheckpointCreateOptions{
|
|
| 68 |
+ _, err = client.CheckpointCreate(t.Context(), expectedContainerID, CheckpointCreateOptions{
|
|
| 69 | 69 |
CheckpointID: expectedCheckpointID, |
| 70 | 70 |
Exit: true, |
| 71 | 71 |
}) |
| ... | ... |
@@ -55,7 +55,7 @@ type HijackDialer interface {
|
| 55 | 55 |
// and only available if the daemon is running with experimental features |
| 56 | 56 |
// enabled. |
| 57 | 57 |
type CheckpointAPIClient interface {
|
| 58 |
- CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) error |
|
| 58 |
+ CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) (CheckpointCreateResult, error) |
|
| 59 | 59 |
CheckpointDelete(ctx context.Context, container string, options CheckpointDeleteOptions) error |
| 60 | 60 |
CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error) |
| 61 | 61 |
} |
| ... | ... |
@@ -54,7 +54,7 @@ func TestCheckpoint(t *testing.T) {
|
| 54 | 54 |
}() |
| 55 | 55 |
|
| 56 | 56 |
t.Log("Do a checkpoint and leave the container running")
|
| 57 |
- err = apiClient.CheckpointCreate(ctx, cID, client.CheckpointCreateOptions{
|
|
| 57 |
+ _, err = apiClient.CheckpointCreate(ctx, cID, client.CheckpointCreateOptions{
|
|
| 58 | 58 |
Exit: false, |
| 59 | 59 |
CheckpointID: "test", |
| 60 | 60 |
}) |
| ... | ... |
@@ -90,7 +90,7 @@ func TestCheckpoint(t *testing.T) {
|
| 90 | 90 |
|
| 91 | 91 |
// Do a second checkpoint |
| 92 | 92 |
t.Log("Do a checkpoint and stop the container")
|
| 93 |
- err = apiClient.CheckpointCreate(ctx, cID, client.CheckpointCreateOptions{
|
|
| 93 |
+ _, err = apiClient.CheckpointCreate(ctx, cID, client.CheckpointCreateOptions{
|
|
| 94 | 94 |
Exit: true, |
| 95 | 95 |
CheckpointID: "test2", |
| 96 | 96 |
}) |
| ... | ... |
@@ -13,11 +13,16 @@ type CheckpointCreateOptions struct {
|
| 13 | 13 |
Exit bool |
| 14 | 14 |
} |
| 15 | 15 |
|
| 16 |
+// CheckpointCreateResult holds the result from [client.CheckpointCreate]. |
|
| 17 |
+type CheckpointCreateResult struct {
|
|
| 18 |
+ // Add future fields here |
|
| 19 |
+} |
|
| 20 |
+ |
|
| 16 | 21 |
// CheckpointCreate creates a checkpoint from the given container. |
| 17 |
-func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) error {
|
|
| 22 |
+func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, options CheckpointCreateOptions) (CheckpointCreateResult, error) {
|
|
| 18 | 23 |
containerID, err := trimID("container", containerID)
|
| 19 | 24 |
if err != nil {
|
| 20 |
- return err |
|
| 25 |
+ return CheckpointCreateResult{}, err
|
|
| 21 | 26 |
} |
| 22 | 27 |
requestBody := checkpoint.CreateRequest{
|
| 23 | 28 |
CheckpointID: options.CheckpointID, |
| ... | ... |
@@ -27,5 +32,5 @@ func (cli *Client) CheckpointCreate(ctx context.Context, containerID string, opt |
| 27 | 27 |
|
| 28 | 28 |
resp, err := cli.post(ctx, "/containers/"+containerID+"/checkpoints", nil, requestBody, nil) |
| 29 | 29 |
defer ensureReaderClosed(resp) |
| 30 |
- return err |
|
| 30 |
+ return CheckpointCreateResult{}, err
|
|
| 31 | 31 |
} |
| ... | ... |
@@ -55,7 +55,7 @@ type HijackDialer interface {
|
| 55 | 55 |
// and only available if the daemon is running with experimental features |
| 56 | 56 |
// enabled. |
| 57 | 57 |
type CheckpointAPIClient interface {
|
| 58 |
- CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) error |
|
| 58 |
+ CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) (CheckpointCreateResult, error) |
|
| 59 | 59 |
CheckpointDelete(ctx context.Context, container string, options CheckpointDeleteOptions) error |
| 60 | 60 |
CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error) |
| 61 | 61 |
} |