Skip to content

Commit 606f1c6

Browse files
authored
Merge pull request #6584 from thaJeztah/bump_modules
vendor: github.com/moby/moby/api, moby/moby/client master
2 parents 10281ff + 83319f0 commit 606f1c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+406
-249
lines changed

cli/command/container/client_test.go

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type fakeClient struct {
1515
execInspectFunc func(execID string) (client.ExecInspectResult, error)
1616
execCreateFunc func(containerID string, options client.ExecCreateOptions) (client.ExecCreateResult, error)
1717
createContainerFunc func(options client.ContainerCreateOptions) (client.ContainerCreateResult, error)
18-
containerStartFunc func(containerID string, options client.ContainerStartOptions) error
18+
containerStartFunc func(containerID string, options client.ContainerStartOptions) (client.ContainerStartResult, error)
1919
imageCreateFunc func(ctx context.Context, parentReference string, options client.ImageCreateOptions) (client.ImageCreateResult, error)
2020
infoFunc func() (system.Info, error)
2121
containerStatPathFunc func(containerID, path string) (container.PathStat, error)
@@ -25,16 +25,16 @@ type fakeClient struct {
2525
containerListFunc func(client.ContainerListOptions) ([]container.Summary, error)
2626
containerExportFunc func(string) (io.ReadCloser, error)
2727
containerExecResizeFunc func(id string, options client.ExecResizeOptions) (client.ExecResizeResult, error)
28-
containerRemoveFunc func(ctx context.Context, containerID string, options client.ContainerRemoveOptions) error
29-
containerRestartFunc func(ctx context.Context, containerID string, options client.ContainerStopOptions) error
30-
containerStopFunc func(ctx context.Context, containerID string, options client.ContainerStopOptions) error
31-
containerKillFunc func(ctx context.Context, containerID, signal string) error
28+
containerRemoveFunc func(ctx context.Context, containerID string, options client.ContainerRemoveOptions) (client.ContainerRemoveResult, error)
29+
containerRestartFunc func(ctx context.Context, containerID string, options client.ContainerRestartOptions) (client.ContainerRestartResult, error)
30+
containerStopFunc func(ctx context.Context, containerID string, options client.ContainerStopOptions) (client.ContainerStopResult, error)
31+
containerKillFunc func(ctx context.Context, containerID string, options client.ContainerKillOptions) (client.ContainerKillResult, error)
3232
containerPruneFunc func(ctx context.Context, options client.ContainerPruneOptions) (client.ContainerPruneResult, error)
3333
containerAttachFunc func(ctx context.Context, containerID string, options client.ContainerAttachOptions) (client.ContainerAttachResult, error)
3434
containerDiffFunc func(ctx context.Context, containerID string) (client.ContainerDiffResult, error)
3535
containerRenameFunc func(ctx context.Context, oldName, newName string) error
3636
containerCommitFunc func(ctx context.Context, container string, options client.ContainerCommitOptions) (client.ContainerCommitResult, error)
37-
containerPauseFunc func(ctx context.Context, container string) error
37+
containerPauseFunc func(ctx context.Context, container string, options client.ContainerPauseOptions) (client.ContainerPauseResult, error)
3838
Version string
3939
}
4040

@@ -77,11 +77,11 @@ func (f *fakeClient) ContainerCreate(_ context.Context, options client.Container
7777
return client.ContainerCreateResult{}, nil
7878
}
7979

80-
func (f *fakeClient) ContainerRemove(ctx context.Context, containerID string, options client.ContainerRemoveOptions) error {
80+
func (f *fakeClient) ContainerRemove(ctx context.Context, containerID string, options client.ContainerRemoveOptions) (client.ContainerRemoveResult, error) {
8181
if f.containerRemoveFunc != nil {
8282
return f.containerRemoveFunc(ctx, containerID, options)
8383
}
84-
return nil
84+
return client.ContainerRemoveResult{}, nil
8585
}
8686

8787
func (f *fakeClient) ImageCreate(ctx context.Context, parentReference string, options client.ImageCreateOptions) (client.ImageCreateResult, error) {
@@ -130,11 +130,11 @@ func (f *fakeClient) ContainerWait(_ context.Context, containerID string, _ cont
130130
return nil, nil
131131
}
132132

133-
func (f *fakeClient) ContainerStart(_ context.Context, containerID string, options client.ContainerStartOptions) error {
133+
func (f *fakeClient) ContainerStart(_ context.Context, containerID string, options client.ContainerStartOptions) (client.ContainerStartResult, error) {
134134
if f.containerStartFunc != nil {
135135
return f.containerStartFunc(containerID, options)
136136
}
137-
return nil
137+
return client.ContainerStartResult{}, nil
138138
}
139139

140140
func (f *fakeClient) ContainerExport(_ context.Context, containerID string) (io.ReadCloser, error) {
@@ -151,11 +151,11 @@ func (f *fakeClient) ExecResize(_ context.Context, id string, options client.Exe
151151
return client.ExecResizeResult{}, nil
152152
}
153153

154-
func (f *fakeClient) ContainerKill(ctx context.Context, containerID, signal string) error {
154+
func (f *fakeClient) ContainerKill(ctx context.Context, containerID string, options client.ContainerKillOptions) (client.ContainerKillResult, error) {
155155
if f.containerKillFunc != nil {
156-
return f.containerKillFunc(ctx, containerID, signal)
156+
return f.containerKillFunc(ctx, containerID, options)
157157
}
158-
return nil
158+
return client.ContainerKillResult{}, nil
159159
}
160160

161161
func (f *fakeClient) ContainersPrune(ctx context.Context, options client.ContainerPruneOptions) (client.ContainerPruneResult, error) {
@@ -165,18 +165,18 @@ func (f *fakeClient) ContainersPrune(ctx context.Context, options client.Contain
165165
return client.ContainerPruneResult{}, nil
166166
}
167167

168-
func (f *fakeClient) ContainerRestart(ctx context.Context, containerID string, options client.ContainerStopOptions) error {
168+
func (f *fakeClient) ContainerRestart(ctx context.Context, containerID string, options client.ContainerRestartOptions) (client.ContainerRestartResult, error) {
169169
if f.containerRestartFunc != nil {
170170
return f.containerRestartFunc(ctx, containerID, options)
171171
}
172-
return nil
172+
return client.ContainerRestartResult{}, nil
173173
}
174174

175-
func (f *fakeClient) ContainerStop(ctx context.Context, containerID string, options client.ContainerStopOptions) error {
175+
func (f *fakeClient) ContainerStop(ctx context.Context, containerID string, options client.ContainerStopOptions) (client.ContainerStopResult, error) {
176176
if f.containerStopFunc != nil {
177177
return f.containerStopFunc(ctx, containerID, options)
178178
}
179-
return nil
179+
return client.ContainerStopResult{}, nil
180180
}
181181

182182
func (f *fakeClient) ContainerAttach(ctx context.Context, containerID string, options client.ContainerAttachOptions) (client.ContainerAttachResult, error) {
@@ -209,10 +209,10 @@ func (f *fakeClient) ContainerCommit(ctx context.Context, containerID string, op
209209
return client.ContainerCommitResult{}, nil
210210
}
211211

212-
func (f *fakeClient) ContainerPause(ctx context.Context, containerID string) error {
212+
func (f *fakeClient) ContainerPause(ctx context.Context, containerID string, options client.ContainerPauseOptions) (client.ContainerPauseResult, error) {
213213
if f.containerPauseFunc != nil {
214-
return f.containerPauseFunc(ctx, containerID)
214+
return f.containerPauseFunc(ctx, containerID, options)
215215
}
216216

217-
return nil
217+
return client.ContainerPauseResult{}, nil
218218
}

cli/command/container/kill.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"github.com/docker/cli/cli"
99
"github.com/docker/cli/cli/command"
1010
"github.com/docker/cli/cli/command/completion"
11+
"github.com/moby/moby/client"
1112
"github.com/spf13/cobra"
1213
)
1314

@@ -47,7 +48,10 @@ func newKillCommand(dockerCLI command.Cli) *cobra.Command {
4748
func runKill(ctx context.Context, dockerCLI command.Cli, opts *killOptions) error {
4849
apiClient := dockerCLI.Client()
4950
errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, container string) error {
50-
return apiClient.ContainerKill(ctx, container, opts.signal)
51+
_, err := apiClient.ContainerKill(ctx, container, client.ContainerKillOptions{
52+
Signal: opts.signal,
53+
})
54+
return err
5155
})
5256

5357
var errs []error

cli/command/container/kill_test.go

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,16 @@ import (
88
"testing"
99

1010
"github.com/docker/cli/internal/test"
11+
"github.com/moby/moby/client"
1112
"gotest.tools/v3/assert"
1213
is "gotest.tools/v3/assert/cmp"
1314
)
1415

1516
func TestRunKill(t *testing.T) {
1617
cli := test.NewFakeCli(&fakeClient{
17-
containerKillFunc: func(
18-
ctx context.Context,
19-
container string,
20-
signal string,
21-
) error {
22-
assert.Assert(t, is.Equal(signal, "STOP"))
23-
return nil
18+
containerKillFunc: func(ctx context.Context, container string, options client.ContainerKillOptions) (client.ContainerKillResult, error) {
19+
assert.Assert(t, is.Equal(options.Signal, "STOP"))
20+
return client.ContainerKillResult{}, nil
2421
},
2522
})
2623

@@ -47,12 +44,8 @@ func TestRunKill(t *testing.T) {
4744

4845
func TestRunKillClientError(t *testing.T) {
4946
cli := test.NewFakeCli(&fakeClient{
50-
containerKillFunc: func(
51-
ctx context.Context,
52-
container string,
53-
signal string,
54-
) error {
55-
return fmt.Errorf("client error for container %s", container)
47+
containerKillFunc: func(ctx context.Context, container string, options client.ContainerKillOptions) (client.ContainerKillResult, error) {
48+
return client.ContainerKillResult{}, fmt.Errorf("client error for container %s", container)
5649
},
5750
})
5851

cli/command/container/pause.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/docker/cli/cli/command"
1010
"github.com/docker/cli/cli/command/completion"
1111
"github.com/moby/moby/api/types/container"
12+
"github.com/moby/moby/client"
1213
"github.com/spf13/cobra"
1314
)
1415

@@ -40,7 +41,10 @@ func newPauseCommand(dockerCLI command.Cli) *cobra.Command {
4041

4142
func runPause(ctx context.Context, dockerCLI command.Cli, opts *pauseOptions) error {
4243
apiClient := dockerCLI.Client()
43-
errChan := parallelOperation(ctx, opts.containers, apiClient.ContainerPause)
44+
errChan := parallelOperation(ctx, opts.containers, func(ctx context.Context, container string) error {
45+
_, err := apiClient.ContainerPause(ctx, container, client.ContainerPauseOptions{})
46+
return err
47+
})
4448

4549
var errs []error
4650
for _, ctr := range opts.containers {

cli/command/container/pause_test.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,13 @@ import (
88
"testing"
99

1010
"github.com/docker/cli/internal/test"
11+
"github.com/moby/moby/client"
1112
"gotest.tools/v3/assert"
1213
is "gotest.tools/v3/assert/cmp"
1314
)
1415

1516
func TestRunPause(t *testing.T) {
16-
cli := test.NewFakeCli(
17-
&fakeClient{
18-
containerPauseFunc: func(ctx context.Context, container string) error {
19-
return nil
20-
},
21-
},
22-
)
17+
cli := test.NewFakeCli(&fakeClient{})
2318

2419
cmd := newPauseCommand(cli)
2520
cmd.SetOut(io.Discard)
@@ -41,8 +36,8 @@ func TestRunPause(t *testing.T) {
4136
func TestRunPauseClientError(t *testing.T) {
4237
cli := test.NewFakeCli(
4338
&fakeClient{
44-
containerPauseFunc: func(ctx context.Context, container string) error {
45-
return fmt.Errorf("client error for container %s", container)
39+
containerPauseFunc: func(ctx context.Context, container string, options client.ContainerPauseOptions) (client.ContainerPauseResult, error) {
40+
return client.ContainerPauseResult{}, fmt.Errorf("client error for container %s", container)
4641
},
4742
},
4843
)

cli/command/container/restart.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func runRestart(ctx context.Context, dockerCLI command.Cli, opts *restartOptions
6666
var errs []error
6767
// TODO(thaJeztah): consider using parallelOperation for restart, similar to "stop" and "remove"
6868
for _, name := range opts.containers {
69-
err := apiClient.ContainerRestart(ctx, name, client.ContainerStopOptions{
69+
_, err := apiClient.ContainerRestart(ctx, name, client.ContainerRestartOptions{
7070
Signal: opts.signal,
7171
Timeout: timeout,
7272
})

cli/command/container/restart_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ func TestRestart(t *testing.T) {
1919
name string
2020
args []string
2121
restarted []string
22-
expectedOpts client.ContainerStopOptions
22+
expectedOpts client.ContainerRestartOptions
2323
expectedErr string
2424
}{
2525
{
@@ -36,19 +36,19 @@ func TestRestart(t *testing.T) {
3636
{
3737
name: "with -t",
3838
args: []string{"-t", "2", "container-1"},
39-
expectedOpts: client.ContainerStopOptions{Timeout: func(to int) *int { return &to }(2)},
39+
expectedOpts: client.ContainerRestartOptions{Timeout: func(to int) *int { return &to }(2)},
4040
restarted: []string{"container-1"},
4141
},
4242
{
4343
name: "with --timeout",
4444
args: []string{"--timeout", "2", "container-1"},
45-
expectedOpts: client.ContainerStopOptions{Timeout: func(to int) *int { return &to }(2)},
45+
expectedOpts: client.ContainerRestartOptions{Timeout: func(to int) *int { return &to }(2)},
4646
restarted: []string{"container-1"},
4747
},
4848
{
4949
name: "with --time",
5050
args: []string{"--time", "2", "container-1"},
51-
expectedOpts: client.ContainerStopOptions{Timeout: func(to int) *int { return &to }(2)},
51+
expectedOpts: client.ContainerRestartOptions{Timeout: func(to int) *int { return &to }(2)},
5252
restarted: []string{"container-1"},
5353
},
5454
{
@@ -62,17 +62,17 @@ func TestRestart(t *testing.T) {
6262
mutex := new(sync.Mutex)
6363

6464
cli := test.NewFakeCli(&fakeClient{
65-
containerRestartFunc: func(ctx context.Context, containerID string, options client.ContainerStopOptions) error {
65+
containerRestartFunc: func(ctx context.Context, containerID string, options client.ContainerRestartOptions) (client.ContainerRestartResult, error) {
6666
assert.Check(t, is.DeepEqual(options, tc.expectedOpts))
6767
if containerID == "nosuchcontainer" {
68-
return notFound(errors.New("Error: no such container: " + containerID))
68+
return client.ContainerRestartResult{}, notFound(errors.New("Error: no such container: " + containerID))
6969
}
7070

7171
// TODO(thaJeztah): consider using parallelOperation for restart, similar to "stop" and "remove"
7272
mutex.Lock()
7373
restarted = append(restarted, containerID)
7474
mutex.Unlock()
75-
return nil
75+
return client.ContainerRestartResult{}, nil
7676
},
7777
Version: "1.36",
7878
})

cli/command/container/rm.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ func runRm(ctx context.Context, dockerCLI command.Cli, opts *rmOptions) error {
6767
if ctrID == "" {
6868
return errors.New("container name cannot be empty")
6969
}
70-
return apiClient.ContainerRemove(ctx, ctrID, client.ContainerRemoveOptions{
70+
_, err := apiClient.ContainerRemove(ctx, ctrID, client.ContainerRemoveOptions{
7171
RemoveVolumes: opts.rmVolumes,
7272
RemoveLinks: opts.rmLink,
7373
Force: opts.force,
7474
})
75+
return err
7576
})
7677

7778
var errs []error

cli/command/container/rm_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,17 @@ func TestRemoveForce(t *testing.T) {
2727
mutex := new(sync.Mutex)
2828

2929
cli := test.NewFakeCli(&fakeClient{
30-
containerRemoveFunc: func(ctx context.Context, container string, options client.ContainerRemoveOptions) error {
30+
containerRemoveFunc: func(ctx context.Context, container string, options client.ContainerRemoveOptions) (client.ContainerRemoveResult, error) {
3131
// containerRemoveFunc is called in parallel for each container
3232
// by the remove command so append must be synchronized.
3333
mutex.Lock()
3434
removed = append(removed, container)
3535
mutex.Unlock()
3636

3737
if container == "nosuchcontainer" {
38-
return notFound(errors.New("Error: no such container: " + container))
38+
return client.ContainerRemoveResult{}, notFound(errors.New("Error: no such container: " + container))
3939
}
40-
return nil
40+
return client.ContainerRemoveResult{}, nil
4141
},
4242
Version: "1.36",
4343
})

cli/command/container/run.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ func runContainer(ctx context.Context, dockerCli command.Cli, runOpts *runOption
193193
statusChan := waitExitOrRemoved(statusCtx, apiClient, containerID, copts.autoRemove)
194194

195195
// start the container
196-
if err := apiClient.ContainerStart(ctx, containerID, client.ContainerStartOptions{}); err != nil {
196+
if _, err := apiClient.ContainerStart(ctx, containerID, client.ContainerStartOptions{}); err != nil {
197197
// If we have hijackedIOStreamer, we should notify
198198
// hijackedIOStreamer we are going to exit and wait
199199
// to avoid the terminal are not restored.

0 commit comments

Comments
 (0)