mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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",
|
||||
})
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
// 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
|
||||
}
|
||||
|
||||
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
|
||||
// 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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user