Skip to content

Commit 869c837

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

Some content is hidden

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

81 files changed

+392
-918
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: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
2+
//go:build go1.23
3+
14
package container
25

36
import (
@@ -6,17 +9,18 @@ import (
69
"errors"
710
"fmt"
811
"io"
12+
"maps"
913
"strings"
1014
"sync"
1115
"time"
1216

17+
"github.com/containerd/errdefs"
1318
"github.com/docker/cli/cli"
1419
"github.com/docker/cli/cli/command"
1520
"github.com/docker/cli/cli/command/completion"
1621
"github.com/docker/cli/cli/command/formatter"
1722
flagsHelper "github.com/docker/cli/cli/flags"
1823
"github.com/moby/moby/api/types/events"
19-
"github.com/moby/moby/api/types/filters"
2024
"github.com/moby/moby/client"
2125
"github.com/sirupsen/logrus"
2226
"github.com/spf13/cobra"
@@ -60,7 +64,7 @@ type StatsOptions struct {
6064
// filter options may be added in future (within the constraints described
6165
// above), but may require daemon-side validation as the list of accepted
6266
// filters can differ between daemon- and API versions.
63-
Filters *filters.Args
67+
Filters client.Filters
6468
}
6569

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

125129
if options.Filters == nil {
126-
f := filters.NewArgs()
127-
options.Filters = &f
130+
options.Filters = make(client.Filters)
128131
}
129132

130-
if err := options.Filters.Validate(acceptedStatsFilters); err != nil {
131-
return err
133+
// FIXME(thaJeztah): any way we can (and should?) validate allowed filters?
134+
for filter := range options.Filters {
135+
if _, ok := acceptedStatsFilters[filter]; !ok {
136+
return errdefs.ErrInvalidArgument.WithMessage("invalid filter '" + filter + "'")
137+
}
132138
}
133139

134140
eh := newEventHandler()
@@ -163,7 +169,7 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
163169
// the original set of filters. Custom filters are used both
164170
// to list containers and to filter events, but the "type" filter
165171
// is not valid for filtering containers.
166-
f := options.Filters.Clone()
172+
f := maps.Clone(options.Filters) // FIXME(thaJeztah): is this correct?
167173
f.Add("type", string(events.ContainerEventType))
168174
eventChan, errChan := apiClient.Events(ctx, client.EventsListOptions{
169175
Filters: f,
@@ -199,7 +205,7 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
199205
// to refresh the list of containers.
200206
cs, err := apiClient.ContainerList(ctx, client.ContainerListOptions{
201207
All: options.All,
202-
Filters: *options.Filters,
208+
Filters: options.Filters,
203209
})
204210
if err != nil {
205211
return err
@@ -219,7 +225,7 @@ func RunStats(ctx context.Context, dockerCLI command.Cli, options *StatsOptions)
219225
// only a single code-path is needed, and custom filters can be combined
220226
// with a list of container names/IDs.
221227

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

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: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
2+
//go:build go1.23
3+
14
package image
25

36
import (
47
"context"
58
"errors"
69
"fmt"
10+
"maps"
711
"strconv"
812
"strings"
913

@@ -69,7 +73,7 @@ Are you sure you want to continue?`
6973
)
7074

7175
func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions) (spaceReclaimed uint64, output string, err error) {
72-
pruneFilters := options.filter.Value().Clone()
76+
pruneFilters := maps.Clone(options.filter.Value())
7377
pruneFilters.Add("dangling", strconv.FormatBool(!options.all))
7478
pruneFilters = command.PruneFilters(dockerCli, pruneFilters)
7579

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)