Skip to content

Commit 3bee32d

Browse files
committed
vendor: github.com/moby/moby/api, moby/client master
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent ee244f2 commit 3bee32d

23 files changed

+125
-130
lines changed

cli/command/checkpoint/client_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,23 +8,23 @@ import (
88

99
type fakeClient struct {
1010
client.Client
11-
checkpointCreateFunc func(container string, options client.CheckpointCreateOptions) error
12-
checkpointDeleteFunc func(container string, options client.CheckpointDeleteOptions) error
11+
checkpointCreateFunc func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error)
12+
checkpointDeleteFunc func(container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error)
1313
checkpointListFunc func(container string, options client.CheckpointListOptions) (client.CheckpointListResult, error)
1414
}
1515

16-
func (cli *fakeClient) CheckpointCreate(_ context.Context, container string, options client.CheckpointCreateOptions) error {
16+
func (cli *fakeClient) CheckpointCreate(_ context.Context, container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error) {
1717
if cli.checkpointCreateFunc != nil {
1818
return cli.checkpointCreateFunc(container, options)
1919
}
20-
return nil
20+
return client.CheckpointCreateResult{}, nil
2121
}
2222

23-
func (cli *fakeClient) CheckpointDelete(_ context.Context, container string, options client.CheckpointDeleteOptions) error {
23+
func (cli *fakeClient) CheckpointRemove(_ context.Context, container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error) {
2424
if cli.checkpointDeleteFunc != nil {
2525
return cli.checkpointDeleteFunc(container, options)
2626
}
27-
return nil
27+
return client.CheckpointRemoveResult{}, nil
2828
}
2929

3030
func (cli *fakeClient) CheckpointList(_ context.Context, container string, options client.CheckpointListOptions) (client.CheckpointListResult, error) {

cli/command/checkpoint/create.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func newCreateCommand(dockerCLI command.Cli) *cobra.Command {
4141
}
4242

4343
func runCreate(ctx context.Context, dockerCLI command.Cli, opts createOptions) error {
44-
err := dockerCLI.Client().CheckpointCreate(ctx, opts.container, client.CheckpointCreateOptions{
44+
_, err := dockerCLI.Client().CheckpointCreate(ctx, opts.container, client.CheckpointCreateOptions{
4545
CheckpointID: opts.checkpoint,
4646
CheckpointDir: opts.checkpointDir,
4747
Exit: !opts.leaveRunning,

cli/command/checkpoint/create_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
func TestCheckpointCreateErrors(t *testing.T) {
1717
testCases := []struct {
1818
args []string
19-
checkpointCreateFunc func(container string, options client.CheckpointCreateOptions) error
19+
checkpointCreateFunc func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error)
2020
expectedError string
2121
}{
2222
{
@@ -29,8 +29,8 @@ func TestCheckpointCreateErrors(t *testing.T) {
2929
},
3030
{
3131
args: []string{"foo", "bar"},
32-
checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) error {
33-
return errors.New("error creating checkpoint for container foo")
32+
checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error) {
33+
return client.CheckpointCreateResult{}, errors.New("error creating checkpoint for container foo")
3434
},
3535
expectedError: "error creating checkpoint for container foo",
3636
},
@@ -61,10 +61,10 @@ func TestCheckpointCreateWithOptions(t *testing.T) {
6161
var actualContainerName string
6262
var actualOptions client.CheckpointCreateOptions
6363
cli := test.NewFakeCli(&fakeClient{
64-
checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) error {
64+
checkpointCreateFunc: func(container string, options client.CheckpointCreateOptions) (client.CheckpointCreateResult, error) {
6565
actualContainerName = container
6666
actualOptions = options
67-
return nil
67+
return client.CheckpointCreateResult{}, nil
6868
},
6969
})
7070
cmd := newCreateCommand(cli)

cli/command/checkpoint/list.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@ func runList(ctx context.Context, dockerCLI command.Cli, container string, opts
4848
Output: dockerCLI.Out(),
4949
Format: newFormat(formatter.TableFormatKey),
5050
}
51-
return formatWrite(cpCtx, checkpoints.Checkpoints)
51+
return formatWrite(cpCtx, checkpoints.Items)
5252
}

cli/command/checkpoint/list_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ func TestCheckpointListWithOptions(t *testing.T) {
5555
containerID = container
5656
checkpointDir = options.CheckpointDir
5757
return client.CheckpointListResult{
58-
Checkpoints: []checkpoint.Summary{
58+
Items: []checkpoint.Summary{
5959
{Name: "checkpoint-foo"},
6060
},
6161
}, nil
6262
},
6363
})
6464
cmd := newListCommand(cli)
6565
cmd.SetArgs([]string{"container-foo"})
66-
cmd.Flags().Set("checkpoint-dir", "/dir/foo")
66+
assert.Check(t, cmd.Flags().Set("checkpoint-dir", "/dir/foo"))
6767
assert.NilError(t, cmd.Execute())
6868
assert.Check(t, is.Equal("container-foo", containerID))
6969
assert.Check(t, is.Equal("/dir/foo", checkpointDir))

cli/command/checkpoint/remove.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package checkpoint
22

33
import (
4-
"context"
5-
64
"github.com/docker/cli/cli"
75
"github.com/docker/cli/cli/command"
86
"github.com/moby/moby/client"
@@ -22,7 +20,12 @@ func newRemoveCommand(dockerCLI command.Cli) *cobra.Command {
2220
Short: "Remove a checkpoint",
2321
Args: cli.ExactArgs(2),
2422
RunE: func(cmd *cobra.Command, args []string) error {
25-
return runRemove(cmd.Context(), dockerCLI, args[0], args[1], opts)
23+
containerID, checkpointID := args[0], args[1]
24+
_, err := dockerCLI.Client().CheckpointRemove(cmd.Context(), containerID, client.CheckpointRemoveOptions{
25+
CheckpointID: checkpointID,
26+
CheckpointDir: opts.checkpointDir,
27+
})
28+
return err
2629
},
2730
DisableFlagsInUseLine: true,
2831
}
@@ -32,10 +35,3 @@ func newRemoveCommand(dockerCLI command.Cli) *cobra.Command {
3235

3336
return cmd
3437
}
35-
36-
func runRemove(ctx context.Context, dockerCli command.Cli, container string, checkpointID string, opts removeOptions) error {
37-
return dockerCli.Client().CheckpointDelete(ctx, container, client.CheckpointDeleteOptions{
38-
CheckpointID: checkpointID,
39-
CheckpointDir: opts.checkpointDir,
40-
})
41-
}

cli/command/checkpoint/remove_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414
func TestCheckpointRemoveErrors(t *testing.T) {
1515
testCases := []struct {
1616
args []string
17-
checkpointDeleteFunc func(container string, options client.CheckpointDeleteOptions) error
17+
checkpointDeleteFunc func(container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error)
1818
expectedError string
1919
}{
2020
{
@@ -27,8 +27,8 @@ func TestCheckpointRemoveErrors(t *testing.T) {
2727
},
2828
{
2929
args: []string{"foo", "bar"},
30-
checkpointDeleteFunc: func(container string, options client.CheckpointDeleteOptions) error {
31-
return errors.New("error deleting checkpoint")
30+
checkpointDeleteFunc: func(container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error) {
31+
return client.CheckpointRemoveResult{}, errors.New("error deleting checkpoint")
3232
},
3333
expectedError: "error deleting checkpoint",
3434
},
@@ -49,16 +49,16 @@ func TestCheckpointRemoveErrors(t *testing.T) {
4949
func TestCheckpointRemoveWithOptions(t *testing.T) {
5050
var containerID, checkpointID, checkpointDir string
5151
cli := test.NewFakeCli(&fakeClient{
52-
checkpointDeleteFunc: func(container string, options client.CheckpointDeleteOptions) error {
52+
checkpointDeleteFunc: func(container string, options client.CheckpointRemoveOptions) (client.CheckpointRemoveResult, error) {
5353
containerID = container
5454
checkpointID = options.CheckpointID
5555
checkpointDir = options.CheckpointDir
56-
return nil
56+
return client.CheckpointRemoveResult{}, nil
5757
},
5858
})
5959
cmd := newRemoveCommand(cli)
6060
cmd.SetArgs([]string{"container-foo", "checkpoint-bar"})
61-
cmd.Flags().Set("checkpoint-dir", "/dir/foo")
61+
assert.Check(t, cmd.Flags().Set("checkpoint-dir", "/dir/foo"))
6262
assert.NilError(t, cmd.Execute())
6363
assert.Check(t, is.Equal("container-foo", containerID))
6464
assert.Check(t, is.Equal("checkpoint-bar", checkpointID))

cli/command/plugin/formatter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func formatWrite(fmtCtx formatter.Context, plugins client.PluginListResult) erro
5555
for _, p := range plugins.Items {
5656
if err := format(&pluginContext{
5757
trunc: fmtCtx.Trunc,
58-
p: *p,
58+
p: p,
5959
}); err != nil {
6060
return err
6161
}

cli/command/plugin/formatter_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ foobar_bar
148148
}
149149

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

172172
func TestPluginContextWriteJSON(t *testing.T) {
173173
plugins := client.PluginListResult{
174-
Items: []*plugin.Plugin{
174+
Items: []plugin.Plugin{
175175
{ID: "pluginID1", Name: "foobar_baz"},
176176
{ID: "pluginID2", Name: "foobar_bar"},
177177
},
@@ -197,7 +197,7 @@ func TestPluginContextWriteJSON(t *testing.T) {
197197

198198
func TestPluginContextWriteJSONField(t *testing.T) {
199199
plugins := client.PluginListResult{
200-
Items: []*plugin.Plugin{
200+
Items: []plugin.Plugin{
201201
{ID: "pluginID1", Name: "foobar_baz"},
202202
{ID: "pluginID2", Name: "foobar_bar"},
203203
},

cli/command/plugin/list_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestList(t *testing.T) {
119119
golden: "plugin-list-with-no-trunc-option.golden",
120120
listFunc: func(opts client.PluginListOptions) (client.PluginListResult, error) {
121121
return client.PluginListResult{
122-
Items: []*plugin.Plugin{{
122+
Items: []plugin.Plugin{{
123123
ID: "xyg4z2hiSLO5yTnBJfg4OYia9gKA6Qjd",
124124
Name: "name-foo",
125125
Enabled: true,
@@ -148,7 +148,7 @@ func TestList(t *testing.T) {
148148
golden: "plugin-list-sort.golden",
149149
listFunc: func(client.PluginListOptions) (client.PluginListResult, error) {
150150
return client.PluginListResult{
151-
Items: []*plugin.Plugin{
151+
Items: []plugin.Plugin{
152152
{
153153
ID: "id-1",
154154
Name: "plugin-1-foo",

0 commit comments

Comments
 (0)