Skip to content

Commit f74cd14

Browse files
authored
Merge pull request #6571 from thaJeztah/bump_modules
vendor: github.com/moby/moby/api, moby/moby/client master
2 parents 7b4cde6 + 4f7c07c commit f74cd14

File tree

290 files changed

+4457
-3363
lines changed

Some content is hidden

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

290 files changed

+4457
-3363
lines changed

cli-plugins/examples/helloworld/main.go

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

@@ -25,7 +26,7 @@ func main() {
2526
Short: "Print the API version of the server",
2627
RunE: func(_ *cobra.Command, _ []string) error {
2728
apiClient := dockerCLI.Client()
28-
ping, err := apiClient.Ping(context.Background())
29+
ping, err := apiClient.Ping(context.Background(), client.PingOptions{})
2930
if err != nil {
3031
return err
3132
}

cli/command/cli.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import (
2525
"github.com/docker/cli/cli/version"
2626
dopts "github.com/docker/cli/opts"
2727
"github.com/moby/moby/api/types/build"
28-
"github.com/moby/moby/api/types/swarm"
2928
"github.com/moby/moby/client"
3029
"github.com/spf13/cobra"
3130
)
@@ -378,7 +377,7 @@ func (cli *DockerCli) initializeFromClient() {
378377
ctx, cancel := context.WithTimeout(cli.baseCtx, cli.getInitTimeout())
379378
defer cancel()
380379

381-
ping, err := cli.client.Ping(ctx)
380+
ping, err := cli.client.Ping(ctx, client.PingOptions{})
382381
if err != nil {
383382
// Default to true if we fail to connect to daemon
384383
cli.serverInfo = ServerInfo{HasExperimental: true}
@@ -564,7 +563,7 @@ type ServerInfo struct {
564563
// in the ping response, or if an error occurred, in which case the client
565564
// should use other ways to get the current swarm status, such as the /swarm
566565
// endpoint.
567-
SwarmStatus *swarm.Status
566+
SwarmStatus *client.SwarmStatus
568567
}
569568

570569
// NewDockerCli returns a DockerCli instance with all operators applied on it.

cli/command/cli_test.go

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
"github.com/docker/cli/cli/config/configfile"
2121
"github.com/docker/cli/cli/context/store"
2222
"github.com/docker/cli/cli/flags"
23-
"github.com/moby/moby/api/types"
2423
"github.com/moby/moby/client"
2524
"gotest.tools/v3/assert"
2625
)
@@ -80,7 +79,7 @@ func TestNewAPIClientFromFlagsWithCustomHeaders(t *testing.T) {
8079
"My-Header": "Custom-Value",
8180
"User-Agent": UserAgent(),
8281
}
83-
_, err = apiClient.Ping(context.Background())
82+
_, err = apiClient.Ping(context.TODO(), client.PingOptions{})
8483
assert.NilError(t, err)
8584
assert.DeepEqual(t, received, expectedHeaders)
8685
}
@@ -115,7 +114,7 @@ func TestNewAPIClientFromFlagsWithCustomHeadersFromEnv(t *testing.T) {
115114
"Four": []string{"four-value-override"},
116115
"User-Agent": []string{UserAgent()},
117116
}
118-
_, err = apiClient.Ping(context.Background())
117+
_, err = apiClient.Ping(context.TODO(), client.PingOptions{})
119118
assert.NilError(t, err)
120119
assert.DeepEqual(t, received, expectedHeaders)
121120
}
@@ -135,20 +134,20 @@ func TestNewAPIClientFromFlagsWithAPIVersionFromEnv(t *testing.T) {
135134

136135
type fakeClient struct {
137136
client.Client
138-
pingFunc func() (types.Ping, error)
137+
pingFunc func() (client.PingResult, error)
139138
version string
140139
negotiated bool
141140
}
142141

143-
func (c *fakeClient) Ping(_ context.Context) (types.Ping, error) {
142+
func (c *fakeClient) Ping(_ context.Context, _ client.PingOptions) (client.PingResult, error) {
144143
return c.pingFunc()
145144
}
146145

147146
func (c *fakeClient) ClientVersion() string {
148147
return c.version
149148
}
150149

151-
func (c *fakeClient) NegotiateAPIVersionPing(types.Ping) {
150+
func (c *fakeClient) NegotiateAPIVersionPing(client.PingResult) {
152151
c.negotiated = true
153152
}
154153

@@ -157,29 +156,29 @@ func TestInitializeFromClient(t *testing.T) {
157156

158157
testcases := []struct {
159158
doc string
160-
pingFunc func() (types.Ping, error)
159+
pingFunc func() (client.PingResult, error)
161160
expectedServer ServerInfo
162161
negotiated bool
163162
}{
164163
{
165164
doc: "successful ping",
166-
pingFunc: func() (types.Ping, error) {
167-
return types.Ping{Experimental: true, OSType: "linux", APIVersion: "v1.44"}, nil
165+
pingFunc: func() (client.PingResult, error) {
166+
return client.PingResult{Experimental: true, OSType: "linux", APIVersion: "v1.44"}, nil
168167
},
169168
expectedServer: ServerInfo{HasExperimental: true, OSType: "linux"},
170169
negotiated: true,
171170
},
172171
{
173172
doc: "failed ping, no API version",
174-
pingFunc: func() (types.Ping, error) {
175-
return types.Ping{}, errors.New("failed")
173+
pingFunc: func() (client.PingResult, error) {
174+
return client.PingResult{}, errors.New("failed")
176175
},
177176
expectedServer: ServerInfo{HasExperimental: true},
178177
},
179178
{
180179
doc: "failed ping, with API version",
181-
pingFunc: func() (types.Ping, error) {
182-
return types.Ping{APIVersion: "v1.44"}, errors.New("failed")
180+
pingFunc: func() (client.PingResult, error) {
181+
return client.PingResult{APIVersion: "v1.44"}, errors.New("failed")
183182
},
184183
expectedServer: ServerInfo{HasExperimental: true},
185184
negotiated: true,
@@ -211,7 +210,7 @@ func TestInitializeFromClientHangs(t *testing.T) {
211210
assert.NilError(t, err)
212211

213212
receiveReqCh := make(chan bool)
214-
timeoutCtx, cancel := context.WithTimeout(context.Background(), time.Second)
213+
timeoutCtx, cancel := context.WithTimeout(context.TODO(), time.Second)
215214
defer cancel()
216215

217216
// Simulate a server that hangs on connections.
@@ -385,7 +384,7 @@ func TestNewDockerCliWithCustomUserAgent(t *testing.T) {
385384
cli.options = opts
386385
cli.configFile = &configfile.ConfigFile{}
387386

388-
_, err = cli.Client().Ping(context.Background())
387+
_, err = cli.Client().Ping(context.TODO(), client.PingOptions{})
389388
assert.NilError(t, err)
390389
assert.DeepEqual(t, received, "fake-agent/0.0.1")
391390
}

cli/command/completion/functions.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ func ImageNames(dockerCLI APIClientProvider, limit int) cobra.CompletionFunc {
2727
if limit > 0 && len(args) >= limit {
2828
return nil, cobra.ShellCompDirectiveNoFileComp
2929
}
30-
list, err := dockerCLI.Client().ImageList(cmd.Context(), client.ImageListOptions{})
30+
res, err := dockerCLI.Client().ImageList(cmd.Context(), client.ImageListOptions{})
3131
if err != nil {
3232
return nil, cobra.ShellCompDirectiveError
3333
}
3434
var names []string
35-
for _, img := range list {
35+
for _, img := range res.Items {
3636
names = append(names, img.RepoTags...)
3737
}
3838
return names, cobra.ShellCompDirectiveNoFileComp
@@ -47,13 +47,13 @@ func ImageNamesWithBase(dockerCLI APIClientProvider, limit int) cobra.Completion
4747
if limit > 0 && len(args) >= limit {
4848
return nil, cobra.ShellCompDirectiveNoFileComp
4949
}
50-
list, err := dockerCLI.Client().ImageList(cmd.Context(), client.ImageListOptions{})
50+
res, err := dockerCLI.Client().ImageList(cmd.Context(), client.ImageListOptions{})
5151
if err != nil {
5252
return nil, cobra.ShellCompDirectiveError
5353
}
5454
var names []string
5555
baseNameCounts := make(map[string]int)
56-
for _, img := range list {
56+
for _, img := range res.Items {
5757
names = append(names, img.RepoTags...)
5858
for _, tag := range img.RepoTags {
5959
ref, err := reference.ParseNormalizedNamed(tag)
@@ -110,12 +110,12 @@ func ContainerNames(dockerCLI APIClientProvider, all bool, filters ...func(conta
110110
// VolumeNames offers completion for volumes
111111
func VolumeNames(dockerCLI APIClientProvider) cobra.CompletionFunc {
112112
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
113-
list, err := dockerCLI.Client().VolumeList(cmd.Context(), client.VolumeListOptions{})
113+
res, err := dockerCLI.Client().VolumeList(cmd.Context(), client.VolumeListOptions{})
114114
if err != nil {
115115
return nil, cobra.ShellCompDirectiveError
116116
}
117117
var names []string
118-
for _, vol := range list.Volumes {
118+
for _, vol := range res.Items.Volumes {
119119
names = append(names, vol.Name)
120120
}
121121
return names, cobra.ShellCompDirectiveNoFileComp
@@ -125,12 +125,12 @@ func VolumeNames(dockerCLI APIClientProvider) cobra.CompletionFunc {
125125
// NetworkNames offers completion for networks
126126
func NetworkNames(dockerCLI APIClientProvider) cobra.CompletionFunc {
127127
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
128-
list, err := dockerCLI.Client().NetworkList(cmd.Context(), client.NetworkListOptions{})
128+
res, err := dockerCLI.Client().NetworkList(cmd.Context(), client.NetworkListOptions{})
129129
if err != nil {
130130
return nil, cobra.ShellCompDirectiveError
131131
}
132132
var names []string
133-
for _, nw := range list {
133+
for _, nw := range res.Items {
134134
names = append(names, nw.Name)
135135
}
136136
return names, cobra.ShellCompDirectiveNoFileComp

cli/command/completion/functions_test.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -28,38 +28,38 @@ func (c fakeCLI) Client() client.APIClient {
2828

2929
type fakeClient struct {
3030
client.Client
31-
containerListFunc func(options client.ContainerListOptions) ([]container.Summary, error)
32-
imageListFunc func(options client.ImageListOptions) ([]image.Summary, error)
33-
networkListFunc func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error)
34-
volumeListFunc func(filter client.Filters) (volume.ListResponse, error)
31+
containerListFunc func(context.Context, client.ContainerListOptions) ([]container.Summary, error)
32+
imageListFunc func(context.Context, client.ImageListOptions) (client.ImageListResult, error)
33+
networkListFunc func(context.Context, client.NetworkListOptions) (client.NetworkListResult, error)
34+
volumeListFunc func(context.Context, client.VolumeListOptions) (client.VolumeListResult, error)
3535
}
3636

37-
func (c *fakeClient) ContainerList(_ context.Context, options client.ContainerListOptions) ([]container.Summary, error) {
37+
func (c *fakeClient) ContainerList(ctx context.Context, options client.ContainerListOptions) ([]container.Summary, error) {
3838
if c.containerListFunc != nil {
39-
return c.containerListFunc(options)
39+
return c.containerListFunc(ctx, options)
4040
}
4141
return []container.Summary{}, nil
4242
}
4343

44-
func (c *fakeClient) ImageList(_ context.Context, options client.ImageListOptions) ([]image.Summary, error) {
44+
func (c *fakeClient) ImageList(ctx context.Context, options client.ImageListOptions) (client.ImageListResult, error) {
4545
if c.imageListFunc != nil {
46-
return c.imageListFunc(options)
46+
return c.imageListFunc(ctx, options)
4747
}
48-
return []image.Summary{}, nil
48+
return client.ImageListResult{}, nil
4949
}
5050

51-
func (c *fakeClient) NetworkList(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
51+
func (c *fakeClient) NetworkList(ctx context.Context, options client.NetworkListOptions) (client.NetworkListResult, error) {
5252
if c.networkListFunc != nil {
5353
return c.networkListFunc(ctx, options)
5454
}
55-
return []network.Summary{}, nil
55+
return client.NetworkListResult{}, nil
5656
}
5757

58-
func (c *fakeClient) VolumeList(_ context.Context, options client.VolumeListOptions) (volume.ListResponse, error) {
58+
func (c *fakeClient) VolumeList(ctx context.Context, options client.VolumeListOptions) (client.VolumeListResult, error) {
5959
if c.volumeListFunc != nil {
60-
return c.volumeListFunc(options.Filters)
60+
return c.volumeListFunc(ctx, options)
6161
}
62-
return volume.ListResponse{}, nil
62+
return client.VolumeListResult{}, nil
6363
}
6464

6565
func TestCompleteContainerNames(t *testing.T) {
@@ -153,7 +153,7 @@ func TestCompleteContainerNames(t *testing.T) {
153153
t.Setenv("DOCKER_COMPLETION_SHOW_CONTAINER_IDS", "yes")
154154
}
155155
comp := ContainerNames(fakeCLI{&fakeClient{
156-
containerListFunc: func(opts client.ContainerListOptions) ([]container.Summary, error) {
156+
containerListFunc: func(_ context.Context, opts client.ContainerListOptions) ([]container.Summary, error) {
157157
assert.Check(t, is.DeepEqual(opts, tc.expOpts))
158158
if tc.expDirective == cobra.ShellCompDirectiveError {
159159
return nil, errors.New("some error occurred")
@@ -226,11 +226,11 @@ func TestCompleteImageNames(t *testing.T) {
226226
for _, tc := range tests {
227227
t.Run(tc.doc, func(t *testing.T) {
228228
comp := ImageNames(fakeCLI{&fakeClient{
229-
imageListFunc: func(options client.ImageListOptions) ([]image.Summary, error) {
229+
imageListFunc: func(context.Context, client.ImageListOptions) (client.ImageListResult, error) {
230230
if tc.expDirective == cobra.ShellCompDirectiveError {
231-
return nil, errors.New("some error occurred")
231+
return client.ImageListResult{}, errors.New("some error occurred")
232232
}
233-
return tc.images, nil
233+
return client.ImageListResult{Items: tc.images}, nil
234234
},
235235
}}, -1)
236236

@@ -286,11 +286,11 @@ func TestCompleteNetworkNames(t *testing.T) {
286286
for _, tc := range tests {
287287
t.Run(tc.doc, func(t *testing.T) {
288288
comp := NetworkNames(fakeCLI{&fakeClient{
289-
networkListFunc: func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
289+
networkListFunc: func(context.Context, client.NetworkListOptions) (client.NetworkListResult, error) {
290290
if tc.expDirective == cobra.ShellCompDirectiveError {
291-
return nil, errors.New("some error occurred")
291+
return client.NetworkListResult{}, errors.New("some error occurred")
292292
}
293-
return tc.networks, nil
293+
return client.NetworkListResult{Items: tc.networks}, nil
294294
},
295295
}})
296296

@@ -337,11 +337,11 @@ func TestCompleteVolumeNames(t *testing.T) {
337337
for _, tc := range tests {
338338
t.Run(tc.doc, func(t *testing.T) {
339339
comp := VolumeNames(fakeCLI{&fakeClient{
340-
volumeListFunc: func(filter client.Filters) (volume.ListResponse, error) {
340+
volumeListFunc: func(context.Context, client.VolumeListOptions) (client.VolumeListResult, error) {
341341
if tc.expDirective == cobra.ShellCompDirectiveError {
342-
return volume.ListResponse{}, errors.New("some error occurred")
342+
return client.VolumeListResult{}, errors.New("some error occurred")
343343
}
344-
return volume.ListResponse{Volumes: tc.volumes}, nil
344+
return client.VolumeListResult{Items: volume.ListResponse{Volumes: tc.volumes}}, nil
345345
},
346346
}})
347347

cli/command/config/client_test.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,41 @@ package config
33
import (
44
"context"
55

6-
"github.com/moby/moby/api/types/swarm"
76
"github.com/moby/moby/client"
87
)
98

109
type fakeClient struct {
1110
client.Client
12-
configCreateFunc func(context.Context, swarm.ConfigSpec) (swarm.ConfigCreateResponse, error)
13-
configInspectFunc func(context.Context, string) (swarm.Config, []byte, error)
14-
configListFunc func(context.Context, client.ConfigListOptions) ([]swarm.Config, error)
15-
configRemoveFunc func(string) error
11+
configCreateFunc func(context.Context, client.ConfigCreateOptions) (client.ConfigCreateResult, error)
12+
configInspectFunc func(context.Context, string, client.ConfigInspectOptions) (client.ConfigInspectResult, error)
13+
configListFunc func(context.Context, client.ConfigListOptions) (client.ConfigListResult, error)
14+
configRemoveFunc func(context.Context, string, client.ConfigRemoveOptions) (client.ConfigRemoveResult, error)
1615
}
1716

18-
func (c *fakeClient) ConfigCreate(ctx context.Context, spec swarm.ConfigSpec) (swarm.ConfigCreateResponse, error) {
17+
func (c *fakeClient) ConfigCreate(ctx context.Context, options client.ConfigCreateOptions) (client.ConfigCreateResult, error) {
1918
if c.configCreateFunc != nil {
20-
return c.configCreateFunc(ctx, spec)
19+
return c.configCreateFunc(ctx, options)
2120
}
22-
return swarm.ConfigCreateResponse{}, nil
21+
return client.ConfigCreateResult{}, nil
2322
}
2423

25-
func (c *fakeClient) ConfigInspectWithRaw(ctx context.Context, id string) (swarm.Config, []byte, error) {
24+
func (c *fakeClient) ConfigInspect(ctx context.Context, id string, options client.ConfigInspectOptions) (client.ConfigInspectResult, error) {
2625
if c.configInspectFunc != nil {
27-
return c.configInspectFunc(ctx, id)
26+
return c.configInspectFunc(ctx, id, options)
2827
}
29-
return swarm.Config{}, nil, nil
28+
return client.ConfigInspectResult{}, nil
3029
}
3130

32-
func (c *fakeClient) ConfigList(ctx context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
31+
func (c *fakeClient) ConfigList(ctx context.Context, options client.ConfigListOptions) (client.ConfigListResult, error) {
3332
if c.configListFunc != nil {
3433
return c.configListFunc(ctx, options)
3534
}
36-
return []swarm.Config{}, nil
35+
return client.ConfigListResult{}, nil
3736
}
3837

39-
func (c *fakeClient) ConfigRemove(_ context.Context, name string) error {
38+
func (c *fakeClient) ConfigRemove(ctx context.Context, name string, options client.ConfigRemoveOptions) (client.ConfigRemoveResult, error) {
4039
if c.configRemoveFunc != nil {
41-
return c.configRemoveFunc(name)
40+
return c.configRemoveFunc(ctx, name, options)
4241
}
43-
return nil
42+
return client.ConfigRemoveResult{}, nil
4443
}

cli/command/config/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,12 @@ func newConfigCommand(dockerCLI command.Cli) *cobra.Command {
3838
// completeNames offers completion for swarm configs
3939
func completeNames(dockerCLI completion.APIClientProvider) cobra.CompletionFunc {
4040
return func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
41-
list, err := dockerCLI.Client().ConfigList(cmd.Context(), client.ConfigListOptions{})
41+
res, err := dockerCLI.Client().ConfigList(cmd.Context(), client.ConfigListOptions{})
4242
if err != nil {
4343
return nil, cobra.ShellCompDirectiveError
4444
}
4545
var names []string
46-
for _, config := range list {
46+
for _, config := range res.Items {
4747
names = append(names, config.ID)
4848
}
4949
return names, cobra.ShellCompDirectiveNoFileComp

0 commit comments

Comments
 (0)