Skip to content

Commit 08f4d82

Browse files
committed
vendor: github.com/moby/moby/api, github.com/moby/moby/client master
full diff: moby/moby@4ca8aed...0769fe7 Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 6ddff81 commit 08f4d82

File tree

175 files changed

+1514
-1830
lines changed

Some content is hidden

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

175 files changed

+1514
-1830
lines changed

cli/command/builder/client_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,17 @@ package builder
33
import (
44
"context"
55

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

109
type fakeClient struct {
1110
client.Client
12-
builderPruneFunc func(ctx context.Context, opts client.BuildCachePruneOptions) (*build.CachePruneReport, error)
11+
builderPruneFunc func(ctx context.Context, opts client.BuildCachePruneOptions) (client.BuildCachePruneResult, error)
1312
}
1413

15-
func (c *fakeClient) BuildCachePrune(ctx context.Context, opts client.BuildCachePruneOptions) (*build.CachePruneReport, error) {
14+
func (c *fakeClient) BuildCachePrune(ctx context.Context, opts client.BuildCachePruneOptions) (client.BuildCachePruneResult, error) {
1615
if c.builderPruneFunc != nil {
1716
return c.builderPruneFunc(ctx, opts)
1817
}
19-
return nil, nil
18+
return client.BuildCachePruneResult{}, nil
2019
}

cli/command/builder/prune.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,7 @@ const (
7070
)
7171

7272
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) {
73-
pruneFilters := options.filter.Value()
74-
pruneFilters = command.PruneFilters(dockerCli, pruneFilters)
73+
pruneFilters := command.PruneFilters(dockerCli, options.filter.Value())
7574

7675
warning := normalWarning
7776
if options.all {
@@ -87,15 +86,15 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
8786
}
8887
}
8988

90-
report, err := dockerCli.Client().BuildCachePrune(ctx, client.BuildCachePruneOptions{
89+
resp, err := dockerCli.Client().BuildCachePrune(ctx, client.BuildCachePruneOptions{
9190
All: options.all,
9291
ReservedSpace: options.reservedSpace.Value(),
9392
Filters: pruneFilters,
9493
})
9594
if err != nil {
9695
return 0, "", err
9796
}
98-
97+
report := resp.Report
9998
if len(report.CachesDeleted) > 0 {
10099
var sb strings.Builder
101100
sb.WriteString("Deleted build cache objects:\n")

cli/command/builder/prune_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"testing"
88

99
"github.com/docker/cli/internal/test"
10-
"github.com/moby/moby/api/types/build"
1110
"github.com/moby/moby/client"
1211
)
1312

@@ -16,8 +15,8 @@ func TestBuilderPromptTermination(t *testing.T) {
1615
t.Cleanup(cancel)
1716

1817
cli := test.NewFakeCli(&fakeClient{
19-
builderPruneFunc: func(ctx context.Context, opts client.BuildCachePruneOptions) (*build.CachePruneReport, error) {
20-
return nil, errors.New("fakeClient builderPruneFunc should not be called")
18+
builderPruneFunc: func(ctx context.Context, opts client.BuildCachePruneOptions) (client.BuildCachePruneResult, error) {
19+
return client.BuildCachePruneResult{}, errors.New("fakeClient builderPruneFunc should not be called")
2120
},
2221
})
2322
cmd := newPruneCommand(cli)

cli/command/completion/functions_test.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,7 @@ import (
66
"sort"
77
"testing"
88

9-
"github.com/google/go-cmp/cmp/cmpopts"
109
"github.com/moby/moby/api/types/container"
11-
"github.com/moby/moby/api/types/filters"
1210
"github.com/moby/moby/api/types/image"
1311
"github.com/moby/moby/api/types/network"
1412
"github.com/moby/moby/api/types/volume"
@@ -33,7 +31,7 @@ type fakeClient struct {
3331
containerListFunc func(options client.ContainerListOptions) ([]container.Summary, error)
3432
imageListFunc func(options client.ImageListOptions) ([]image.Summary, error)
3533
networkListFunc func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error)
36-
volumeListFunc func(filter filters.Args) (volume.ListResponse, error)
34+
volumeListFunc func(filter client.Filters) (volume.ListResponse, error)
3735
}
3836

3937
func (c *fakeClient) ContainerList(_ context.Context, options client.ContainerListOptions) ([]container.Summary, error) {
@@ -156,7 +154,7 @@ func TestCompleteContainerNames(t *testing.T) {
156154
}
157155
comp := ContainerNames(fakeCLI{&fakeClient{
158156
containerListFunc: func(opts client.ContainerListOptions) ([]container.Summary, error) {
159-
assert.Check(t, is.DeepEqual(opts, tc.expOpts, cmpopts.IgnoreUnexported(client.ContainerListOptions{}, filters.Args{})))
157+
assert.Check(t, is.DeepEqual(opts, tc.expOpts))
160158
if tc.expDirective == cobra.ShellCompDirectiveError {
161159
return nil, errors.New("some error occurred")
162160
}
@@ -339,7 +337,7 @@ func TestCompleteVolumeNames(t *testing.T) {
339337
for _, tc := range tests {
340338
t.Run(tc.doc, func(t *testing.T) {
341339
comp := VolumeNames(fakeCLI{&fakeClient{
342-
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
340+
volumeListFunc: func(filter client.Filters) (volume.ListResponse, error) {
343341
if tc.expDirective == cobra.ShellCompDirectiveError {
344342
return volume.ListResponse{}, errors.New("some error occurred")
345343
}

cli/command/config/ls_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import (
1313
"github.com/moby/moby/api/types/swarm"
1414
"github.com/moby/moby/client"
1515
"gotest.tools/v3/assert"
16-
is "gotest.tools/v3/assert/cmp"
1716
"gotest.tools/v3/golden"
1817
)
1918

@@ -133,8 +132,8 @@ func TestConfigListWithFormat(t *testing.T) {
133132
func TestConfigListWithFilter(t *testing.T) {
134133
cli := test.NewFakeCli(&fakeClient{
135134
configListFunc: func(_ context.Context, options client.ConfigListOptions) ([]swarm.Config, error) {
136-
assert.Check(t, is.Equal("foo", options.Filters.Get("name")[0]))
137-
assert.Check(t, is.Equal("lbl1=Label-bar", options.Filters.Get("label")[0]))
135+
assert.Check(t, options.Filters["name"]["foo"])
136+
assert.Check(t, options.Filters["label"]["lbl1=Label-bar"])
138137
return []swarm.Config{
139138
*builders.Config(builders.ConfigID("ID-foo"),
140139
builders.ConfigName("foo"),

cli/command/container/client_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import (
55
"io"
66

77
"github.com/moby/moby/api/types/container"
8-
"github.com/moby/moby/api/types/filters"
98
"github.com/moby/moby/api/types/network"
109
"github.com/moby/moby/api/types/system"
1110
"github.com/moby/moby/client"
@@ -36,7 +35,7 @@ type fakeClient struct {
3635
containerRestartFunc func(ctx context.Context, containerID string, options client.ContainerStopOptions) error
3736
containerStopFunc func(ctx context.Context, containerID string, options client.ContainerStopOptions) error
3837
containerKillFunc func(ctx context.Context, containerID, signal string) error
39-
containerPruneFunc func(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error)
38+
containerPruneFunc func(ctx context.Context, pruneFilters client.Filters) (container.PruneReport, error)
4039
containerAttachFunc func(ctx context.Context, containerID string, options client.ContainerAttachOptions) (client.HijackedResponse, error)
4140
containerDiffFunc func(ctx context.Context, containerID string) ([]container.FilesystemChange, error)
4241
containerRenameFunc func(ctx context.Context, oldName, newName string) error
@@ -172,7 +171,7 @@ func (f *fakeClient) ContainerKill(ctx context.Context, containerID, signal stri
172171
return nil
173172
}
174173

175-
func (f *fakeClient) ContainersPrune(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error) {
174+
func (f *fakeClient) ContainersPrune(ctx context.Context, pruneFilters client.Filters) (container.PruneReport, error) {
176175
if f.containerPruneFunc != nil {
177176
return f.containerPruneFunc(ctx, pruneFilters)
178177
}

cli/command/container/list_test.go

Lines changed: 21 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ func TestContainerListBuildContainerListOptions(t *testing.T) {
2626
expectedAll bool
2727
expectedSize bool
2828
expectedLimit int
29-
expectedFilters map[string]string
29+
expectedFilters client.Filters
3030
}{
3131
{
3232
psOpts: &psOptions{
@@ -35,13 +35,10 @@ func TestContainerListBuildContainerListOptions(t *testing.T) {
3535
last: 5,
3636
filter: filters,
3737
},
38-
expectedAll: true,
39-
expectedSize: true,
40-
expectedLimit: 5,
41-
expectedFilters: map[string]string{
42-
"foo": "bar",
43-
"baz": "foo",
44-
},
38+
expectedAll: true,
39+
expectedSize: true,
40+
expectedLimit: 5,
41+
expectedFilters: make(client.Filters).Add("foo", "bar").Add("baz", "foo"),
4542
},
4643
{
4744
psOpts: &psOptions{
@@ -50,10 +47,9 @@ func TestContainerListBuildContainerListOptions(t *testing.T) {
5047
last: -1,
5148
nLatest: true,
5249
},
53-
expectedAll: true,
54-
expectedSize: true,
55-
expectedLimit: 1,
56-
expectedFilters: make(map[string]string),
50+
expectedAll: true,
51+
expectedSize: true,
52+
expectedLimit: 1,
5753
},
5854
{
5955
psOpts: &psOptions{
@@ -64,13 +60,10 @@ func TestContainerListBuildContainerListOptions(t *testing.T) {
6460
// With .Size, size should be true
6561
format: "{{.Size}}",
6662
},
67-
expectedAll: true,
68-
expectedSize: true,
69-
expectedLimit: 5,
70-
expectedFilters: map[string]string{
71-
"foo": "bar",
72-
"baz": "foo",
73-
},
63+
expectedAll: true,
64+
expectedSize: true,
65+
expectedLimit: 5,
66+
expectedFilters: make(client.Filters).Add("foo", "bar").Add("baz", "foo"),
7467
},
7568
{
7669
psOpts: &psOptions{
@@ -81,13 +74,10 @@ func TestContainerListBuildContainerListOptions(t *testing.T) {
8174
// With .Size, size should be true
8275
format: "{{.Size}} {{.CreatedAt}} {{upper .Networks}}",
8376
},
84-
expectedAll: true,
85-
expectedSize: true,
86-
expectedLimit: 5,
87-
expectedFilters: map[string]string{
88-
"foo": "bar",
89-
"baz": "foo",
90-
},
77+
expectedAll: true,
78+
expectedSize: true,
79+
expectedLimit: 5,
80+
expectedFilters: make(client.Filters).Add("foo", "bar").Add("baz", "foo"),
9181
},
9282
{
9383
psOpts: &psOptions{
@@ -98,13 +88,10 @@ func TestContainerListBuildContainerListOptions(t *testing.T) {
9888
// Without .Size, size should be false
9989
format: "{{.CreatedAt}} {{.Networks}}",
10090
},
101-
expectedAll: true,
102-
expectedSize: false,
103-
expectedLimit: 5,
104-
expectedFilters: map[string]string{
105-
"foo": "bar",
106-
"baz": "foo",
107-
},
91+
expectedAll: true,
92+
expectedSize: false,
93+
expectedLimit: 5,
94+
expectedFilters: make(client.Filters).Add("foo", "bar").Add("baz", "foo"),
10895
},
10996
}
11097

@@ -115,14 +102,7 @@ func TestContainerListBuildContainerListOptions(t *testing.T) {
115102
assert.Check(t, is.Equal(c.expectedAll, options.All))
116103
assert.Check(t, is.Equal(c.expectedSize, options.Size))
117104
assert.Check(t, is.Equal(c.expectedLimit, options.Limit))
118-
assert.Check(t, is.Equal(len(c.expectedFilters), options.Filters.Len()))
119-
120-
for k, v := range c.expectedFilters {
121-
f := options.Filters
122-
if !f.ExactMatch(k, v) {
123-
t.Fatalf("Expected filter with key %s to be %s but got %s", k, v, f.Get(k))
124-
}
125-
}
105+
assert.Check(t, is.DeepEqual(c.expectedFilters, options.Filters))
126106
}
127107
}
128108

0 commit comments

Comments
 (0)