mirror of
https://github.com/moby/moby.git
synced 2026-01-11 10:41:43 +00:00
client: rename CheckpointDelete to CheckpointRemove, and add output struct
Align with other "delete" options, which are all named "remove". Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
@@ -1,29 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// CheckpointDeleteOptions holds parameters to delete a checkpoint from a container.
|
||||
type CheckpointDeleteOptions struct {
|
||||
CheckpointID string
|
||||
CheckpointDir string
|
||||
}
|
||||
|
||||
// CheckpointDelete deletes the checkpoint with the given name from the given container.
|
||||
func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, options CheckpointDeleteOptions) error {
|
||||
containerID, err := trimID("container", containerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
query := url.Values{}
|
||||
if options.CheckpointDir != "" {
|
||||
query.Set("dir", options.CheckpointDir)
|
||||
}
|
||||
|
||||
resp, err := cli.delete(ctx, "/containers/"+containerID+"/checkpoints/"+options.CheckpointID, query, nil)
|
||||
defer ensureReaderClosed(resp)
|
||||
return err
|
||||
}
|
||||
34
client/checkpoint_remove.go
Normal file
34
client/checkpoint_remove.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// CheckpointRemoveOptions holds parameters to delete a checkpoint from a container.
|
||||
type CheckpointRemoveOptions struct {
|
||||
CheckpointID string
|
||||
CheckpointDir string
|
||||
}
|
||||
|
||||
// CheckpointRemoveResult represents the result of [Client.CheckpointRemove].
|
||||
type CheckpointRemoveResult struct {
|
||||
// No fields currently; placeholder for future use.
|
||||
}
|
||||
|
||||
// CheckpointRemove deletes the checkpoint with the given name from the given container.
|
||||
func (cli *Client) CheckpointRemove(ctx context.Context, containerID string, options CheckpointRemoveOptions) (CheckpointRemoveResult, error) {
|
||||
containerID, err := trimID("container", containerID)
|
||||
if err != nil {
|
||||
return CheckpointRemoveResult{}, err
|
||||
}
|
||||
|
||||
query := url.Values{}
|
||||
if options.CheckpointDir != "" {
|
||||
query.Set("dir", options.CheckpointDir)
|
||||
}
|
||||
|
||||
resp, err := cli.delete(ctx, "/containers/"+containerID+"/checkpoints/"+options.CheckpointID, query, nil)
|
||||
defer ensureReaderClosed(resp)
|
||||
return CheckpointRemoveResult{}, err
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
"testing"
|
||||
|
||||
@@ -16,17 +15,17 @@ func TestCheckpointDeleteError(t *testing.T) {
|
||||
)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = client.CheckpointDelete(context.Background(), "container_id", CheckpointDeleteOptions{
|
||||
_, err = client.CheckpointRemove(t.Context(), "container_id", CheckpointRemoveOptions{
|
||||
CheckpointID: "checkpoint_id",
|
||||
})
|
||||
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
|
||||
|
||||
err = client.CheckpointDelete(context.Background(), "", CheckpointDeleteOptions{})
|
||||
_, err = client.CheckpointRemove(t.Context(), "", CheckpointRemoveOptions{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||
|
||||
err = client.CheckpointDelete(context.Background(), " ", CheckpointDeleteOptions{})
|
||||
_, err = client.CheckpointRemove(t.Context(), " ", CheckpointRemoveOptions{})
|
||||
assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
|
||||
assert.Check(t, is.ErrorContains(err, "value is empty"))
|
||||
}
|
||||
@@ -44,7 +43,7 @@ func TestCheckpointDelete(t *testing.T) {
|
||||
)
|
||||
assert.NilError(t, err)
|
||||
|
||||
err = client.CheckpointDelete(context.Background(), "container_id", CheckpointDeleteOptions{
|
||||
_, err = client.CheckpointRemove(t.Context(), "container_id", CheckpointRemoveOptions{
|
||||
CheckpointID: "checkpoint_id",
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
@@ -56,7 +56,7 @@ type HijackDialer interface {
|
||||
// enabled.
|
||||
type CheckpointAPIClient interface {
|
||||
CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) (CheckpointCreateResult, error)
|
||||
CheckpointDelete(ctx context.Context, container string, options CheckpointDeleteOptions) error
|
||||
CheckpointRemove(ctx context.Context, container string, options CheckpointRemoveOptions) (CheckpointRemoveResult, error)
|
||||
CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error)
|
||||
}
|
||||
|
||||
|
||||
@@ -132,7 +132,7 @@ func TestCheckpoint(t *testing.T) {
|
||||
r.AssertSuccess(t)
|
||||
|
||||
for _, id := range []string{"test", "test2"} {
|
||||
err = apiClient.CheckpointDelete(ctx, cID, client.CheckpointDeleteOptions{
|
||||
_, err = apiClient.CheckpointRemove(ctx, cID, client.CheckpointRemoveOptions{
|
||||
CheckpointID: id,
|
||||
})
|
||||
assert.NilError(t, err)
|
||||
|
||||
29
vendor/github.com/moby/moby/client/checkpoint_delete.go
generated
vendored
29
vendor/github.com/moby/moby/client/checkpoint_delete.go
generated
vendored
@@ -1,29 +0,0 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// CheckpointDeleteOptions holds parameters to delete a checkpoint from a container.
|
||||
type CheckpointDeleteOptions struct {
|
||||
CheckpointID string
|
||||
CheckpointDir string
|
||||
}
|
||||
|
||||
// CheckpointDelete deletes the checkpoint with the given name from the given container.
|
||||
func (cli *Client) CheckpointDelete(ctx context.Context, containerID string, options CheckpointDeleteOptions) error {
|
||||
containerID, err := trimID("container", containerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
query := url.Values{}
|
||||
if options.CheckpointDir != "" {
|
||||
query.Set("dir", options.CheckpointDir)
|
||||
}
|
||||
|
||||
resp, err := cli.delete(ctx, "/containers/"+containerID+"/checkpoints/"+options.CheckpointID, query, nil)
|
||||
defer ensureReaderClosed(resp)
|
||||
return err
|
||||
}
|
||||
34
vendor/github.com/moby/moby/client/checkpoint_remove.go
generated
vendored
Normal file
34
vendor/github.com/moby/moby/client/checkpoint_remove.go
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
package client
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/url"
|
||||
)
|
||||
|
||||
// CheckpointRemoveOptions holds parameters to delete a checkpoint from a container.
|
||||
type CheckpointRemoveOptions struct {
|
||||
CheckpointID string
|
||||
CheckpointDir string
|
||||
}
|
||||
|
||||
// CheckpointRemoveResult represents the result of [Client.CheckpointRemove].
|
||||
type CheckpointRemoveResult struct {
|
||||
// No fields currently; placeholder for future use.
|
||||
}
|
||||
|
||||
// CheckpointRemove deletes the checkpoint with the given name from the given container.
|
||||
func (cli *Client) CheckpointRemove(ctx context.Context, containerID string, options CheckpointRemoveOptions) (CheckpointRemoveResult, error) {
|
||||
containerID, err := trimID("container", containerID)
|
||||
if err != nil {
|
||||
return CheckpointRemoveResult{}, err
|
||||
}
|
||||
|
||||
query := url.Values{}
|
||||
if options.CheckpointDir != "" {
|
||||
query.Set("dir", options.CheckpointDir)
|
||||
}
|
||||
|
||||
resp, err := cli.delete(ctx, "/containers/"+containerID+"/checkpoints/"+options.CheckpointID, query, nil)
|
||||
defer ensureReaderClosed(resp)
|
||||
return CheckpointRemoveResult{}, 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
@@ -56,7 +56,7 @@ type HijackDialer interface {
|
||||
// enabled.
|
||||
type CheckpointAPIClient interface {
|
||||
CheckpointCreate(ctx context.Context, container string, options CheckpointCreateOptions) (CheckpointCreateResult, error)
|
||||
CheckpointDelete(ctx context.Context, container string, options CheckpointDeleteOptions) error
|
||||
CheckpointRemove(ctx context.Context, container string, options CheckpointRemoveOptions) (CheckpointRemoveResult, error)
|
||||
CheckpointList(ctx context.Context, container string, options CheckpointListOptions) (CheckpointListResult, error)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user