mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
client: CheckpointCreate: add output struct
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -13,11 +13,16 @@ type CheckpointCreateOptions struct {
|
|||||||
Exit bool
|
Exit bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckpointCreateResult holds the result from [client.CheckpointCreate].
|
||||||
|
type CheckpointCreateResult struct {
|
||||||
|
// Add future fields here
|
||||||
|
}
|
||||||
|
|
||||||
// CheckpointCreate creates a checkpoint from the given container.
|
// 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)
|
containerID, err := trimID("container", containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return CheckpointCreateResult{}, err
|
||||||
}
|
}
|
||||||
requestBody := checkpoint.CreateRequest{
|
requestBody := checkpoint.CreateRequest{
|
||||||
CheckpointID: options.CheckpointID,
|
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)
|
resp, err := cli.post(ctx, "/containers/"+containerID+"/checkpoints", nil, requestBody, nil)
|
||||||
defer ensureReaderClosed(resp)
|
defer ensureReaderClosed(resp)
|
||||||
return err
|
return CheckpointCreateResult{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package client
|
package client
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
@@ -19,18 +18,18 @@ func TestCheckpointCreateError(t *testing.T) {
|
|||||||
)
|
)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
err = client.CheckpointCreate(context.Background(), "nothing", CheckpointCreateOptions{
|
_, err = client.CheckpointCreate(t.Context(), "nothing", CheckpointCreateOptions{
|
||||||
CheckpointID: "noting",
|
CheckpointID: "noting",
|
||||||
Exit: true,
|
Exit: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
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.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
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.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||||
}
|
}
|
||||||
@@ -65,7 +64,7 @@ func TestCheckpointCreate(t *testing.T) {
|
|||||||
)
|
)
|
||||||
assert.NilError(t, err)
|
assert.NilError(t, err)
|
||||||
|
|
||||||
err = client.CheckpointCreate(context.Background(), expectedContainerID, CheckpointCreateOptions{
|
_, err = client.CheckpointCreate(t.Context(), expectedContainerID, CheckpointCreateOptions{
|
||||||
CheckpointID: expectedCheckpointID,
|
CheckpointID: expectedCheckpointID,
|
||||||
Exit: true,
|
Exit: true,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ type HijackDialer interface {
|
|||||||
// and only available if the daemon is running with experimental features
|
// and only available if the daemon is running with experimental features
|
||||||
// enabled.
|
// enabled.
|
||||||
type CheckpointAPIClient interface {
|
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
|
CheckpointDelete(ctx context.Context, container string, options CheckpointDeleteOptions) error
|
||||||
CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error)
|
CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ func TestCheckpoint(t *testing.T) {
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
t.Log("Do a checkpoint and leave the container running")
|
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,
|
Exit: false,
|
||||||
CheckpointID: "test",
|
CheckpointID: "test",
|
||||||
})
|
})
|
||||||
@@ -90,7 +90,7 @@ func TestCheckpoint(t *testing.T) {
|
|||||||
|
|
||||||
// Do a second checkpoint
|
// Do a second checkpoint
|
||||||
t.Log("Do a checkpoint and stop the container")
|
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,
|
Exit: true,
|
||||||
CheckpointID: "test2",
|
CheckpointID: "test2",
|
||||||
})
|
})
|
||||||
|
|||||||
11
vendor/github.com/moby/moby/client/checkpoint_create.go
generated
vendored
11
vendor/github.com/moby/moby/client/checkpoint_create.go
generated
vendored
@@ -13,11 +13,16 @@ type CheckpointCreateOptions struct {
|
|||||||
Exit bool
|
Exit bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CheckpointCreateResult holds the result from [client.CheckpointCreate].
|
||||||
|
type CheckpointCreateResult struct {
|
||||||
|
// Add future fields here
|
||||||
|
}
|
||||||
|
|
||||||
// CheckpointCreate creates a checkpoint from the given container.
|
// 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)
|
containerID, err := trimID("container", containerID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return CheckpointCreateResult{}, err
|
||||||
}
|
}
|
||||||
requestBody := checkpoint.CreateRequest{
|
requestBody := checkpoint.CreateRequest{
|
||||||
CheckpointID: options.CheckpointID,
|
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)
|
resp, err := cli.post(ctx, "/containers/"+containerID+"/checkpoints", nil, requestBody, nil)
|
||||||
defer ensureReaderClosed(resp)
|
defer ensureReaderClosed(resp)
|
||||||
return err
|
return CheckpointCreateResult{}, err
|
||||||
}
|
}
|
||||||
|
|||||||
2
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
2
vendor/github.com/moby/moby/client/client_interfaces.go
generated
vendored
@@ -55,7 +55,7 @@ type HijackDialer interface {
|
|||||||
// and only available if the daemon is running with experimental features
|
// and only available if the daemon is running with experimental features
|
||||||
// enabled.
|
// enabled.
|
||||||
type CheckpointAPIClient interface {
|
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
|
CheckpointDelete(ctx context.Context, container string, options CheckpointDeleteOptions) error
|
||||||
CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error)
|
CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user