Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions cli/command/checkpoint/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,23 @@ import (

type fakeClient struct {
client.Client
checkpointCreateFunc func(container string, options client.CheckpointCreateOptions) error
checkpointDeleteFunc func(container string, options client.CheckpointDeleteOptions) error
checkpointCreateFunc func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error)
checkpointDeleteFunc func(container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error)
checkpointListFunc func(container string, options client.CheckpointListOptions) (client.CheckpointListResult, error)
}

func (cli *fakeClient) CheckpointCreate(_ context.Context, container string, options client.CheckpointCreateOptions) error {
func (cli *fakeClient) CheckpointCreate(_ context.Context, container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error) {
if cli.checkpointCreateFunc != nil {
return cli.checkpointCreateFunc(container, options)
}
return nil
return client.CheckpointCreateResult{}, nil
}

func (cli *fakeClient) CheckpointDelete(_ context.Context, container string, options client.CheckpointDeleteOptions) error {
func (cli *fakeClient) CheckpointRemove(_ context.Context, container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error) {
if cli.checkpointDeleteFunc != nil {
return cli.checkpointDeleteFunc(container, options)
}
return nil
return client.CheckpointRemoveResult{}, nil
}

func (cli *fakeClient) CheckpointList(_ context.Context, container string, options client.CheckpointListOptions) (client.CheckpointListResult, error) {
Expand Down
2 changes: 1 addition & 1 deletion cli/command/checkpoint/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
}

func runCreate(ctx context.Context, dockerCLI command.Cli, opts createOptions) error {
err := dockerCLI.Client().CheckpointCreate(ctx, opts.container, client.CheckpointCreateOptions{
_, err := dockerCLI.Client().CheckpointCreate(ctx, opts.container, client.CheckpointCreateOptions{
CheckpointID: opts.checkpoint,
CheckpointDir: opts.checkpointDir,
Exit: !opts.leaveRunning,
Expand Down
10 changes: 5 additions & 5 deletions cli/command/checkpoint/create_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import (
func TestCheckpointCreateErrors(t *testing.T) {
testCases := []struct {
args []string
checkpointCreateFunc func(container string, options client.CheckpointCreateOptions) error
checkpointCreateFunc func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error)
expectedError string
}{
{
Expand All @@ -29,8 +29,8 @@ func TestCheckpointCreateErrors(t *testing.T) {
},
{
args: []string{"foo", "bar"},
checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) error {
return errors.New("error creating checkpoint for container foo")
checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error) {
return client.CheckpointCreateResult{}, errors.New("error creating checkpoint for container foo")
},
expectedError: "error creating checkpoint for container foo",
},
Expand Down Expand Up @@ -61,10 +61,10 @@ func TestCheckpointCreateWithOptions(t *testing.T) {
var actualContainerName string
var actualOptions client.CheckpointCreateOptions
cli := test.NewFakeCli(&fakeClient{
checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) error {
checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error) {
actualContainerName = container
actualOptions = options
return nil
return client.CheckpointCreateResult{}, nil
},
})
cmd := newCreateCommand(cli)
Expand Down
2 changes: 1 addition & 1 deletion cli/command/checkpoint/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,5 @@ func runList(ctx context.Context, dockerCLI command.Cli, container string, opts
Output: dockerCLI.Out(),
Format: newFormat(formatter.TableFormatKey),
}
return formatWrite(cpCtx, checkpoints.Checkpoints)
return formatWrite(cpCtx, checkpoints.Items)
}
4 changes: 2 additions & 2 deletions cli/command/checkpoint/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ func TestCheckpointListWithOptions(t *testing.T) {
containerID = container
checkpointDir = options.CheckpointDir
return client.CheckpointListResult{
Checkpoints: []checkpoint.Summary{
Items: []checkpoint.Summary{
{Name: "checkpoint-foo"},
},
}, nil
},
})
cmd := newListCommand(cli)
cmd.SetArgs([]string{"container-foo"})
cmd.Flags().Set("checkpoint-dir", "/dir/foo")
assert.Check(t, cmd.Flags().Set("checkpoint-dir", "/dir/foo"))
assert.NilError(t, cmd.Execute())
assert.Check(t, is.Equal("container-foo", containerID))
assert.Check(t, is.Equal("/dir/foo", checkpointDir))
Expand Down
16 changes: 6 additions & 10 deletions cli/command/checkpoint/remove.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package checkpoint

import (
"context"

"github.com/docker/cli/cli"
"github.com/docker/cli/cli/command"
"github.com/moby/moby/client"
Expand All @@ -22,7 +20,12 @@ func newRemoveCommand(dockerCLI command.Cli) *cobra.Command {
Short: "Remove a checkpoint",
Args: cli.ExactArgs(2),
RunE: func(cmd *cobra.Command, args []string) error {
return runRemove(cmd.Context(), dockerCLI, args[0], args[1], opts)
containerID, checkpointID := args[0], args[1]
_, err := dockerCLI.Client().CheckpointRemove(cmd.Context(), containerID, client.CheckpointRemoveOptions{
CheckpointID: checkpointID,
CheckpointDir: opts.checkpointDir,
})
return err
},
DisableFlagsInUseLine: true,
}
Expand All @@ -32,10 +35,3 @@ func newRemoveCommand(dockerCLI command.Cli) *cobra.Command {

return cmd
}

func runRemove(ctx context.Context, dockerCli command.Cli, container string, checkpointID string, opts removeOptions) error {
return dockerCli.Client().CheckpointDelete(ctx, container, client.CheckpointDeleteOptions{
CheckpointID: checkpointID,
CheckpointDir: opts.checkpointDir,
})
}
12 changes: 6 additions & 6 deletions cli/command/checkpoint/remove_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
func TestCheckpointRemoveErrors(t *testing.T) {
testCases := []struct {
args []string
checkpointDeleteFunc func(container string, options client.CheckpointDeleteOptions) error
checkpointDeleteFunc func(container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error)
expectedError string
}{
{
Expand All @@ -27,8 +27,8 @@ func TestCheckpointRemoveErrors(t *testing.T) {
},
{
args: []string{"foo", "bar"},
checkpointDeleteFunc: func(container string, options client.CheckpointDeleteOptions) error {
return errors.New("error deleting checkpoint")
checkpointDeleteFunc: func(container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error) {
return client.CheckpointRemoveResult{}, errors.New("error deleting checkpoint")
},
expectedError: "error deleting checkpoint",
},
Expand All @@ -49,16 +49,16 @@ func TestCheckpointRemoveErrors(t *testing.T) {
func TestCheckpointRemoveWithOptions(t *testing.T) {
var containerID, checkpointID, checkpointDir string
cli := test.NewFakeCli(&fakeClient{
checkpointDeleteFunc: func(container string, options client.CheckpointDeleteOptions) error {
checkpointDeleteFunc: func(container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error) {
containerID = container
checkpointID = options.CheckpointID
checkpointDir = options.CheckpointDir
return nil
return client.CheckpointRemoveResult{}, nil
},
})
cmd := newRemoveCommand(cli)
cmd.SetArgs([]string{"container-foo", "checkpoint-bar"})
cmd.Flags().Set("checkpoint-dir", "/dir/foo")
assert.Check(t, cmd.Flags().Set("checkpoint-dir", "/dir/foo"))
assert.NilError(t, cmd.Execute())
assert.Check(t, is.Equal("container-foo", containerID))
assert.Check(t, is.Equal("checkpoint-bar", checkpointID))
Expand Down
2 changes: 1 addition & 1 deletion cli/command/formatter/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ func (c *ContainerContext) Ports() string {
// State returns the container's current state (e.g. "running" or "paused").
// Refer to [container.ContainerState] for possible states.
func (c *ContainerContext) State() string {
return c.c.State
return string(c.c.State)
}

// Status returns the container's status in a human readable form (for example,
Expand Down
2 changes: 1 addition & 1 deletion cli/command/formatter/container_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func TestContainerPsContext(t *testing.T) {
{
container: container.Summary{State: container.StateRunning},
trunc: true,
expValue: container.StateRunning,
expValue: string(container.StateRunning),
call: ctx.State,
},
{
Expand Down
2 changes: 1 addition & 1 deletion cli/command/plugin/formatter.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func formatWrite(fmtCtx formatter.Context, plugins client.PluginListResult) erro
for _, p := range plugins.Items {
if err := format(&pluginContext{
trunc: fmtCtx.Trunc,
p: *p,
p: p,
}); err != nil {
return err
}
Expand Down
6 changes: 3 additions & 3 deletions cli/command/plugin/formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ foobar_bar
}

plugins := client.PluginListResult{
Items: []*plugin.Plugin{
Items: []plugin.Plugin{
{ID: "pluginID1", Name: "foobar_baz", Config: plugin.Config{Description: "description 1"}, Enabled: true},
{ID: "pluginID2", Name: "foobar_bar", Config: plugin.Config{Description: "description 2"}, Enabled: false},
},
Expand All @@ -171,7 +171,7 @@ foobar_bar

func TestPluginContextWriteJSON(t *testing.T) {
plugins := client.PluginListResult{
Items: []*plugin.Plugin{
Items: []plugin.Plugin{
{ID: "pluginID1", Name: "foobar_baz"},
{ID: "pluginID2", Name: "foobar_bar"},
},
Expand All @@ -197,7 +197,7 @@ func TestPluginContextWriteJSON(t *testing.T) {

func TestPluginContextWriteJSONField(t *testing.T) {
plugins := client.PluginListResult{
Items: []*plugin.Plugin{
Items: []plugin.Plugin{
{ID: "pluginID1", Name: "foobar_baz"},
{ID: "pluginID2", Name: "foobar_bar"},
},
Expand Down
4 changes: 2 additions & 2 deletions cli/command/plugin/list_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestList(t *testing.T) {
golden: "plugin-list-with-no-trunc-option.golden",
listFunc: func(opts client.PluginListOptions) (client.PluginListResult, error) {
return client.PluginListResult{
Items: []*plugin.Plugin{{
Items: []plugin.Plugin{{
ID: "xyg4z2hiSLO5yTnBJfg4OYia9gKA6Qjd",
Name: "name-foo",
Enabled: true,
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestList(t *testing.T) {
golden: "plugin-list-sort.golden",
listFunc: func(client.PluginListOptions) (client.PluginListResult, error) {
return client.PluginListResult{
Items: []*plugin.Plugin{
Items: []plugin.Plugin{
{
ID: "id-1",
Name: "plugin-1-foo",
Expand Down
4 changes: 2 additions & 2 deletions vendor.mod
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ require (
github.com/google/uuid v1.6.0
github.com/mattn/go-runewidth v0.0.19
github.com/moby/go-archive v0.1.0
github.com/moby/moby/api v1.52.0-rc.1
github.com/moby/moby/client v0.1.0-rc.1
github.com/moby/moby/api v1.52.0-rc.1.0.20251110152122-7cff366d4383 // master
github.com/moby/moby/client v0.1.0-rc.1.0.20251110152122-7cff366d4383 // master
github.com/moby/patternmatcher v0.6.0
github.com/moby/swarmkit/v2 v2.1.1
github.com/moby/sys/atomicwriter v0.1.0
Expand Down
8 changes: 4 additions & 4 deletions vendor.sum
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,10 @@ github.com/moby/docker-image-spec v1.3.1 h1:jMKff3w6PgbfSa69GfNg+zN/XLhfXJGnEx3N
github.com/moby/docker-image-spec v1.3.1/go.mod h1:eKmb5VW8vQEh/BAr2yvVNvuiJuY6UIocYsFu/DxxRpo=
github.com/moby/go-archive v0.1.0 h1:Kk/5rdW/g+H8NHdJW2gsXyZ7UnzvJNOy6VKJqueWdcQ=
github.com/moby/go-archive v0.1.0/go.mod h1:G9B+YoujNohJmrIYFBpSd54GTUB4lt9S+xVQvsJyFuo=
github.com/moby/moby/api v1.52.0-rc.1 h1:yiNz/QzD4Jr1gyKl2iMo7OCZwwY+Xb3BltKv1xipwXo=
github.com/moby/moby/api v1.52.0-rc.1/go.mod h1:v0K/motq8oWmx+rtApG1rBTIpQ8KUONUjpf+U73gags=
github.com/moby/moby/client v0.1.0-rc.1 h1:NfuQec3HvQkPf4EvVkoFGPsBvlAc8CCyQN1m1kGSEX8=
github.com/moby/moby/client v0.1.0-rc.1/go.mod h1:qYzoKHz8qu4Ie1j41CWYhfNRHo8uhs5ay7cfx309Aqc=
github.com/moby/moby/api v1.52.0-rc.1.0.20251110152122-7cff366d4383 h1:EtwsCC5qh3+Q08G4m2X+mvkl4iXaVwbLjib4UgZmtY0=
github.com/moby/moby/api v1.52.0-rc.1.0.20251110152122-7cff366d4383/go.mod h1:v0K/motq8oWmx+rtApG1rBTIpQ8KUONUjpf+U73gags=
github.com/moby/moby/client v0.1.0-rc.1.0.20251110152122-7cff366d4383 h1:OBG6NXd/rSJDsfjwe2y7W2swcqiW8/wGrdKB46QgN+A=
github.com/moby/moby/client v0.1.0-rc.1.0.20251110152122-7cff366d4383/go.mod h1:DYvby7ZKcDKbvuhs4/gBptKp+fqMLz0RhVIPUMy+H/Q=
github.com/moby/patternmatcher v0.6.0 h1:GmP9lR19aU5GqSSFko+5pRqHi+Ohk1O69aFiKkVGiPk=
github.com/moby/patternmatcher v0.6.0/go.mod h1:hDPoyOpDY7OrrMDLaYoY3hf52gNCR/YOUYxkhApJIxc=
github.com/moby/swarmkit/v2 v2.1.1 h1:yvTJ8MMCc3f0qTA44J6R59EZ5yZawdYopkpuLk4+ICU=
Expand Down
9 changes: 5 additions & 4 deletions vendor/github.com/moby/moby/api/types/container/health.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 9 additions & 5 deletions vendor/github.com/moby/moby/api/types/container/state.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 0 additions & 19 deletions vendor/github.com/moby/moby/api/types/system/disk_usage.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 0 additions & 16 deletions vendor/github.com/moby/moby/client/checkpoint.go

This file was deleted.

Loading
Loading