Skip to content

Commit 8f4ff89

Browse files
committed
vendor latest
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent a71cb31 commit 8f4ff89

Some content is hidden

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

80 files changed

+379
-914
lines changed

cli/command/completion/functions_test.go

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

99
"github.com/google/go-cmp/cmp/cmpopts"
1010
"github.com/moby/moby/api/types/container"
11-
"github.com/moby/moby/api/types/filters"
1211
"github.com/moby/moby/api/types/image"
1312
"github.com/moby/moby/api/types/network"
1413
"github.com/moby/moby/api/types/volume"
@@ -33,7 +32,7 @@ type fakeClient struct {
3332
containerListFunc func(options client.ContainerListOptions) ([]container.Summary, error)
3433
imageListFunc func(options client.ImageListOptions) ([]image.Summary, error)
3534
networkListFunc func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error)
36-
volumeListFunc func(filter filters.Args) (volume.ListResponse, error)
35+
volumeListFunc func(filter client.Filters) (volume.ListResponse, error)
3736
}
3837

3938
func (c *fakeClient) ContainerList(_ context.Context, options client.ContainerListOptions) ([]container.Summary, error) {
@@ -156,7 +155,7 @@ func TestCompleteContainerNames(t *testing.T) {
156155
}
157156
comp := ContainerNames(fakeCLI{&fakeClient{
158157
containerListFunc: func(opts client.ContainerListOptions) ([]container.Summary, error) {
159-
assert.Check(t, is.DeepEqual(opts, tc.expOpts, cmpopts.IgnoreUnexported(client.ContainerListOptions{}, filters.Args{})))
158+
assert.Check(t, is.DeepEqual(opts, tc.expOpts, cmpopts.IgnoreUnexported(client.ContainerListOptions{}, client.Filters{})))
160159
if tc.expDirective == cobra.ShellCompDirectiveError {
161160
return nil, errors.New("some error occurred")
162161
}
@@ -339,7 +338,7 @@ func TestCompleteVolumeNames(t *testing.T) {
339338
for _, tc := range tests {
340339
t.Run(tc.doc, func(t *testing.T) {
341340
comp := VolumeNames(fakeCLI{&fakeClient{
342-
volumeListFunc: func(filter filters.Args) (volume.ListResponse, error) {
341+
volumeListFunc: func(filter client.Filters) (volume.ListResponse, error) {
343342
if tc.expDirective == cobra.ShellCompDirectiveError {
344343
return volume.ListResponse{}, errors.New("some error occurred")
345344
}

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/prune_test.go

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

99
"github.com/docker/cli/internal/test"
1010
"github.com/moby/moby/api/types/container"
11-
"github.com/moby/moby/api/types/filters"
11+
"github.com/moby/moby/client"
1212
)
1313

1414
func TestContainerPrunePromptTermination(t *testing.T) {
1515
ctx, cancel := context.WithCancel(context.Background())
1616
t.Cleanup(cancel)
1717

1818
cli := test.NewFakeCli(&fakeClient{
19-
containerPruneFunc: func(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error) {
19+
containerPruneFunc: func(ctx context.Context, pruneFilters client.Filters) (container.PruneReport, error) {
2020
return container.PruneReport{}, errors.New("fakeClient containerPruneFunc should not be called")
2121
},
2222
})

cli/command/container/stats.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"errors"
77
"fmt"
88
"io"
9+
"maps"
910
"strings"
1011
"sync"
1112
"time"
@@ -16,7 +17,6 @@ import (
1617
"github.com/docker/cli/cli/command/formatter"
1718
flagsHelper "github.com/docker/cli/cli/flags"
1819
"github.com/moby/moby/api/types/events"
19-
"github.com/moby/moby/api/types/filters"
2020
"github.com/moby/moby/client"
2121
"github.com/sirupsen/logrus"
2222
"github.com/spf13/cobra"
@@ -60,7 +60,7 @@ type StatsOptions struct {
6060
// filter options may be added in future (within the constraints described
6161
// above), but may require daemon-side validation as the list of accepted
6262
// filters can differ between daemon- and API versions.
63-
Filters *filters.Args
63+
Filters client.Filters
6464
}
6565

6666
// newStatsCommand creates a new [cobra.Command] for "docker container stats".
@@ -123,13 +123,13 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
123123
started := make(chan struct{})
124124

125125
if options.Filters == nil {
126-
f := filters.NewArgs()
127-
options.Filters = &f
126+
options.Filters = make(client.Filters)
128127
}
129128

130-
if err := options.Filters.Validate(acceptedStatsFilters); err != nil {
131-
return err
132-
}
129+
// FIXME(thaJeztah): any way we can (and should?) validate allowed filters?
130+
// if err := options.Filters.Validate(acceptedStatsFilters); err != nil {
131+
// return err
132+
// }
133133

134134
eh := newEventHandler()
135135
if options.All {
@@ -163,7 +163,7 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
163163
// the original set of filters. Custom filters are used both
164164
// to list containers and to filter events, but the "type" filter
165165
// is not valid for filtering containers.
166-
f := options.Filters.Clone()
166+
f := maps.Clone(options.Filters) // FIXME(thaJeztah): is this correct?
167167
f.Add("type", string(events.ContainerEventType))
168168
eventChan, errChan := apiClient.Events(ctx, client.EventsListOptions{
169169
Filters: f,
@@ -199,7 +199,7 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
199199
// to refresh the list of containers.
200200
cs, err := apiClient.ContainerList(ctx, client.ContainerListOptions{
201201
All: options.All,
202-
Filters: *options.Filters,
202+
Filters: options.Filters,
203203
})
204204
if err != nil {
205205
return err
@@ -219,7 +219,7 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
219219
// only a single code-path is needed, and custom filters can be combined
220220
// with a list of container names/IDs.
221221

222-
if options.Filters != nil && options.Filters.Len() > 0 {
222+
if len(options.Filters) > 0 {
223223
return errors.New("filtering is not supported when specifying a list of containers")
224224
}
225225

cli/command/image/client_test.go

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

9-
"github.com/moby/moby/api/types/filters"
109
"github.com/moby/moby/api/types/image"
1110
"github.com/moby/moby/api/types/system"
1211
"github.com/moby/moby/client"
@@ -20,7 +19,7 @@ type fakeClient struct {
2019
imagePushFunc func(ref string, options client.ImagePushOptions) (io.ReadCloser, error)
2120
infoFunc func() (system.Info, error)
2221
imagePullFunc func(ref string, options client.ImagePullOptions) (io.ReadCloser, error)
23-
imagesPruneFunc func(pruneFilter filters.Args) (image.PruneReport, error)
22+
imagesPruneFunc func(pruneFilter client.Filters) (image.PruneReport, error)
2423
imageLoadFunc func(input io.Reader, options ...client.ImageLoadOption) (client.LoadResponse, error)
2524
imageListFunc func(options client.ImageListOptions) ([]image.Summary, error)
2625
imageInspectFunc func(img string) (image.InspectResponse, error)
@@ -73,7 +72,7 @@ func (cli *fakeClient) ImagePull(_ context.Context, ref string, options client.I
7372
return io.NopCloser(strings.NewReader("")), nil
7473
}
7574

76-
func (cli *fakeClient) ImagesPrune(_ context.Context, pruneFilter filters.Args) (image.PruneReport, error) {
75+
func (cli *fakeClient) ImagesPrune(_ context.Context, pruneFilter client.Filters) (image.PruneReport, error) {
7776
if cli.imagesPruneFunc != nil {
7877
return cli.imagesPruneFunc(pruneFilter)
7978
}

cli/command/image/prune.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"context"
55
"errors"
66
"fmt"
7+
"maps"
78
"strconv"
89
"strings"
910

@@ -69,7 +70,7 @@ Are you sure you want to continue?`
6970
)
7071

7172
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) {
72-
pruneFilters := options.filter.Value().Clone()
73+
pruneFilters := maps.Clone(options.filter.Value())
7374
pruneFilters.Add("dangling", strconv.FormatBool(!options.all))
7475
pruneFilters = command.PruneFilters(dockerCli, pruneFilters)
7576

cli/command/image/prune_test.go

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,9 @@ import (
1010

1111
"github.com/docker/cli/cli/streams"
1212
"github.com/docker/cli/internal/test"
13-
"github.com/moby/moby/api/types/filters"
1413
"github.com/moby/moby/api/types/image"
14+
"github.com/moby/moby/client"
1515
"gotest.tools/v3/assert"
16-
is "gotest.tools/v3/assert/cmp"
1716
"gotest.tools/v3/golden"
1817
)
1918

@@ -22,7 +21,7 @@ func TestNewPruneCommandErrors(t *testing.T) {
2221
name string
2322
args []string
2423
expectedError string
25-
imagesPruneFunc func(pruneFilter filters.Args) (image.PruneReport, error)
24+
imagesPruneFunc func(pruneFilter client.Filters) (image.PruneReport, error)
2625
}{
2726
{
2827
name: "wrong-args",
@@ -33,7 +32,7 @@ func TestNewPruneCommandErrors(t *testing.T) {
3332
name: "prune-error",
3433
args: []string{"--force"},
3534
expectedError: "something went wrong",
36-
imagesPruneFunc: func(pruneFilter filters.Args) (image.PruneReport, error) {
35+
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
3736
return image.PruneReport{}, errors.New("something went wrong")
3837
},
3938
},
@@ -55,21 +54,21 @@ func TestNewPruneCommandSuccess(t *testing.T) {
5554
testCases := []struct {
5655
name string
5756
args []string
58-
imagesPruneFunc func(pruneFilter filters.Args) (image.PruneReport, error)
57+
imagesPruneFunc func(pruneFilter client.Filters) (image.PruneReport, error)
5958
}{
6059
{
6160
name: "all",
6261
args: []string{"--all"},
63-
imagesPruneFunc: func(pruneFilter filters.Args) (image.PruneReport, error) {
64-
assert.Check(t, is.Equal("false", pruneFilter.Get("dangling")[0]))
62+
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
63+
assert.Check(t, pruneFilter["dangling"]["false"])
6564
return image.PruneReport{}, nil
6665
},
6766
},
6867
{
6968
name: "force-deleted",
7069
args: []string{"--force"},
71-
imagesPruneFunc: func(pruneFilter filters.Args) (image.PruneReport, error) {
72-
assert.Check(t, is.Equal("true", pruneFilter.Get("dangling")[0]))
70+
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
71+
assert.Check(t, pruneFilter["dangling"]["true"])
7372
return image.PruneReport{
7473
ImagesDeleted: []image.DeleteResponse{{Deleted: "image1"}},
7574
SpaceReclaimed: 1,
@@ -79,16 +78,16 @@ func TestNewPruneCommandSuccess(t *testing.T) {
7978
{
8079
name: "label-filter",
8180
args: []string{"--force", "--filter", "label=foobar"},
82-
imagesPruneFunc: func(pruneFilter filters.Args) (image.PruneReport, error) {
83-
assert.Check(t, is.Equal("foobar", pruneFilter.Get("label")[0]))
81+
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
82+
assert.Check(t, pruneFilter["label"]["foobar"])
8483
return image.PruneReport{}, nil
8584
},
8685
},
8786
{
8887
name: "force-untagged",
8988
args: []string{"--force"},
90-
imagesPruneFunc: func(pruneFilter filters.Args) (image.PruneReport, error) {
91-
assert.Check(t, is.Equal("true", pruneFilter.Get("dangling")[0]))
89+
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
90+
assert.Check(t, pruneFilter["dangling"]["true"])
9291
return image.PruneReport{
9392
ImagesDeleted: []image.DeleteResponse{{Untagged: "image1"}},
9493
SpaceReclaimed: 2,
@@ -117,7 +116,7 @@ func TestPrunePromptTermination(t *testing.T) {
117116
t.Cleanup(cancel)
118117

119118
cli := test.NewFakeCli(&fakeClient{
120-
imagesPruneFunc: func(pruneFilter filters.Args) (image.PruneReport, error) {
119+
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
121120
return image.PruneReport{}, errors.New("fakeClient imagesPruneFunc should not be called")
122121
},
123122
})

cli/command/image/tree.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/docker/cli/cli/streams"
1818
"github.com/docker/cli/internal/tui"
1919
"github.com/docker/go-units"
20-
"github.com/moby/moby/api/types/filters"
2120
imagetypes "github.com/moby/moby/api/types/image"
2221
"github.com/moby/moby/client"
2322
"github.com/morikuni/aec"
@@ -26,7 +25,7 @@ import (
2625

2726
type treeOptions struct {
2827
all bool
29-
filters filters.Args
28+
filters client.Filters
3029
}
3130

3231
type treeView struct {

cli/command/network/client_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package network
33
import (
44
"context"
55

6-
"github.com/moby/moby/api/types/filters"
76
"github.com/moby/moby/api/types/network"
87
"github.com/moby/moby/client"
98
)
@@ -15,7 +14,7 @@ type fakeClient struct {
1514
networkDisconnectFunc func(ctx context.Context, networkID, container string, force bool) error
1615
networkRemoveFunc func(ctx context.Context, networkID string) error
1716
networkListFunc func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error)
18-
networkPruneFunc func(ctx context.Context, pruneFilters filters.Args) (network.PruneReport, error)
17+
networkPruneFunc func(ctx context.Context, pruneFilters client.Filters) (network.PruneReport, error)
1918
networkInspectFunc func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, []byte, error)
2019
}
2120

@@ -61,7 +60,7 @@ func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string
6160
return network.Inspect{}, nil, nil
6261
}
6362

64-
func (c *fakeClient) NetworksPrune(ctx context.Context, pruneFilter filters.Args) (network.PruneReport, error) {
63+
func (c *fakeClient) NetworksPrune(ctx context.Context, pruneFilter client.Filters) (network.PruneReport, error) {
6564
if c.networkPruneFunc != nil {
6665
return c.networkPruneFunc(ctx, pruneFilter)
6766
}

cli/command/network/list_test.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"github.com/docker/cli/internal/test"
1010
"github.com/docker/cli/internal/test/builders"
1111
"github.com/google/go-cmp/cmp"
12-
"github.com/moby/moby/api/types/filters"
1312
"github.com/moby/moby/api/types/network"
1413
"github.com/moby/moby/client"
1514
"gotest.tools/v3/assert"
@@ -57,9 +56,9 @@ func TestNetworkList(t *testing.T) {
5756
golden: "network-list.golden",
5857
networkListFunc: func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error) {
5958
expectedOpts := client.NetworkListOptions{
60-
Filters: filters.NewArgs(filters.Arg("image.name", "ubuntu")),
59+
// Filters: filters.NewArgs(filters.Arg("image.name", "ubuntu")),
6160
}
62-
assert.Check(t, is.DeepEqual(expectedOpts, options, cmp.AllowUnexported(filters.Args{})))
61+
assert.Check(t, is.DeepEqual(expectedOpts, options, cmp.AllowUnexported(client.Filters{})))
6362

6463
return []network.Summary{*builders.NetworkResource(builders.NetworkResourceID("123454321"),
6564
builders.NetworkResourceName("network_1"),

0 commit comments

Comments
 (0)