Skip to content

Commit 563f5fe

Browse files
committed
vendor: github.com/moby/moby/api, moby/moby/client master
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 171a9b7 commit 563f5fe

36 files changed

+261
-208
lines changed

cli/command/container/client_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ type fakeClient struct {
3535
containerRestartFunc func(ctx context.Context, containerID string, options client.ContainerStopOptions) error
3636
containerStopFunc func(ctx context.Context, containerID string, options client.ContainerStopOptions) error
3737
containerKillFunc func(ctx context.Context, containerID, signal string) error
38-
containerPruneFunc func(ctx context.Context, pruneFilters client.Filters) (container.PruneReport, error)
38+
containerPruneFunc func(ctx context.Context, options client.ContainerPruneOptions) (client.ContainerPruneResult, error)
3939
containerAttachFunc func(ctx context.Context, containerID string, options client.ContainerAttachOptions) (client.HijackedResponse, error)
4040
containerDiffFunc func(ctx context.Context, containerID string) ([]container.FilesystemChange, error)
4141
containerRenameFunc func(ctx context.Context, oldName, newName string) error
@@ -171,11 +171,11 @@ func (f *fakeClient) ContainerKill(ctx context.Context, containerID, signal stri
171171
return nil
172172
}
173173

174-
func (f *fakeClient) ContainersPrune(ctx context.Context, pruneFilters client.Filters) (container.PruneReport, error) {
174+
func (f *fakeClient) ContainersPrune(ctx context.Context, options client.ContainerPruneOptions) (client.ContainerPruneResult, error) {
175175
if f.containerPruneFunc != nil {
176-
return f.containerPruneFunc(ctx, pruneFilters)
176+
return f.containerPruneFunc(ctx, options)
177177
}
178-
return container.PruneReport{}, nil
178+
return client.ContainerPruneResult{}, nil
179179
}
180180

181181
func (f *fakeClient) ContainerRestart(ctx context.Context, containerID string, options client.ContainerStopOptions) error {

cli/command/container/prune.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"github.com/docker/cli/internal/prompt"
1212
"github.com/docker/cli/opts"
1313
"github.com/docker/go-units"
14+
"github.com/moby/moby/client"
1415
"github.com/spf13/cobra"
1516
)
1617

@@ -73,17 +74,19 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
7374
}
7475
}
7576

76-
report, err := dockerCli.Client().ContainersPrune(ctx, pruneFilters)
77+
res, err := dockerCli.Client().ContainersPrune(ctx, client.ContainerPruneOptions{
78+
Filters: pruneFilters,
79+
})
7780
if err != nil {
7881
return 0, "", err
7982
}
8083

81-
if len(report.ContainersDeleted) > 0 {
84+
if len(res.Report.ContainersDeleted) > 0 {
8285
output = "Deleted Containers:\n"
83-
for _, id := range report.ContainersDeleted {
86+
for _, id := range res.Report.ContainersDeleted {
8487
output += id + "\n"
8588
}
86-
spaceReclaimed = report.SpaceReclaimed
89+
spaceReclaimed = res.Report.SpaceReclaimed
8790
}
8891

8992
return spaceReclaimed, output, nil

cli/command/container/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/container"
1110
"github.com/moby/moby/client"
1211
)
1312

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

1817
cli := test.NewFakeCli(&fakeClient{
19-
containerPruneFunc: func(ctx context.Context, pruneFilters client.Filters) (container.PruneReport, error) {
20-
return container.PruneReport{}, errors.New("fakeClient containerPruneFunc should not be called")
18+
containerPruneFunc: func(ctx context.Context, opts client.ContainerPruneOptions) (client.ContainerPruneResult, error) {
19+
return client.ContainerPruneResult{}, errors.New("fakeClient containerPruneFunc should not be called")
2120
},
2221
})
2322
cmd := newPruneCommand(cli)

cli/command/image/client_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type fakeClient struct {
1919
imagePushFunc func(ref string, options client.ImagePushOptions) (io.ReadCloser, error)
2020
infoFunc func() (system.Info, error)
2121
imagePullFunc func(ref string, options client.ImagePullOptions) (client.ImagePullResponse, error)
22-
imagesPruneFunc func(pruneFilter client.Filters) (image.PruneReport, error)
22+
imagesPruneFunc func(options client.ImagePruneOptions) (client.ImagePruneResult, error)
2323
imageLoadFunc func(input io.Reader, options ...client.ImageLoadOption) (client.LoadResponse, error)
2424
imageListFunc func(options client.ImageListOptions) ([]image.Summary, error)
2525
imageInspectFunc func(img string) (image.InspectResponse, error)
@@ -72,11 +72,11 @@ func (cli *fakeClient) ImagePull(_ context.Context, ref string, options client.I
7272
return client.ImagePullResponse{}, nil
7373
}
7474

75-
func (cli *fakeClient) ImagesPrune(_ context.Context, pruneFilter client.Filters) (image.PruneReport, error) {
75+
func (cli *fakeClient) ImagesPrune(_ context.Context, opts client.ImagePruneOptions) (client.ImagePruneResult, error) {
7676
if cli.imagesPruneFunc != nil {
77-
return cli.imagesPruneFunc(pruneFilter)
77+
return cli.imagesPruneFunc(opts)
7878
}
79-
return image.PruneReport{}, nil
79+
return client.ImagePruneResult{}, nil
8080
}
8181

8282
func (cli *fakeClient) ImageLoad(_ context.Context, input io.Reader, options ...client.ImageLoadOption) (client.LoadResponse, error) {

cli/command/image/prune.go

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import (
1313
"github.com/docker/cli/internal/prompt"
1414
"github.com/docker/cli/opts"
1515
"github.com/docker/go-units"
16+
"github.com/moby/moby/client"
1617
"github.com/spf13/cobra"
1718
)
1819

@@ -86,15 +87,17 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
8687
}
8788
}
8889

89-
report, err := dockerCli.Client().ImagesPrune(ctx, pruneFilters)
90+
res, err := dockerCli.Client().ImagesPrune(ctx, client.ImagePruneOptions{
91+
Filters: pruneFilters,
92+
})
9093
if err != nil {
9194
return 0, "", err
9295
}
9396

94-
if len(report.ImagesDeleted) > 0 {
95-
var sb strings.Builder
97+
var sb strings.Builder
98+
if len(res.Report.ImagesDeleted) > 0 {
9699
sb.WriteString("Deleted Images:\n")
97-
for _, st := range report.ImagesDeleted {
100+
for _, st := range res.Report.ImagesDeleted {
98101
if st.Untagged != "" {
99102
sb.WriteString("untagged: ")
100103
sb.WriteString(st.Untagged)
@@ -105,11 +108,9 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
105108
sb.WriteByte('\n')
106109
}
107110
}
108-
output = sb.String()
109-
spaceReclaimed = report.SpaceReclaimed
110111
}
111112

112-
return spaceReclaimed, output, nil
113+
return res.Report.SpaceReclaimed, sb.String(), nil
113114
}
114115

115116
type cancelledErr struct{ error }

cli/command/image/prune_test.go

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ func TestNewPruneCommandErrors(t *testing.T) {
2121
name string
2222
args []string
2323
expectedError string
24-
imagesPruneFunc func(pruneFilter client.Filters) (image.PruneReport, error)
24+
imagesPruneFunc func(client.ImagePruneOptions) (client.ImagePruneResult, error)
2525
}{
2626
{
2727
name: "wrong-args",
@@ -32,8 +32,8 @@ func TestNewPruneCommandErrors(t *testing.T) {
3232
name: "prune-error",
3333
args: []string{"--force"},
3434
expectedError: "something went wrong",
35-
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
36-
return image.PruneReport{}, errors.New("something went wrong")
35+
imagesPruneFunc: func(client.ImagePruneOptions) (client.ImagePruneResult, error) {
36+
return client.ImagePruneResult{}, errors.New("something went wrong")
3737
},
3838
},
3939
}
@@ -54,43 +54,47 @@ func TestNewPruneCommandSuccess(t *testing.T) {
5454
testCases := []struct {
5555
name string
5656
args []string
57-
imagesPruneFunc func(pruneFilter client.Filters) (image.PruneReport, error)
57+
imagesPruneFunc func(client.ImagePruneOptions) (client.ImagePruneResult, error)
5858
}{
5959
{
6060
name: "all",
6161
args: []string{"--all"},
62-
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
63-
assert.Check(t, pruneFilter["dangling"]["false"])
64-
return image.PruneReport{}, nil
62+
imagesPruneFunc: func(opts client.ImagePruneOptions) (client.ImagePruneResult, error) {
63+
assert.Check(t, opts.Filters["dangling"]["false"])
64+
return client.ImagePruneResult{}, nil
6565
},
6666
},
6767
{
6868
name: "force-deleted",
6969
args: []string{"--force"},
70-
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
71-
assert.Check(t, pruneFilter["dangling"]["true"])
72-
return image.PruneReport{
73-
ImagesDeleted: []image.DeleteResponse{{Deleted: "image1"}},
74-
SpaceReclaimed: 1,
70+
imagesPruneFunc: func(opts client.ImagePruneOptions) (client.ImagePruneResult, error) {
71+
assert.Check(t, opts.Filters["dangling"]["true"])
72+
return client.ImagePruneResult{
73+
Report: image.PruneReport{
74+
ImagesDeleted: []image.DeleteResponse{{Deleted: "image1"}},
75+
SpaceReclaimed: 1,
76+
},
7577
}, nil
7678
},
7779
},
7880
{
7981
name: "label-filter",
8082
args: []string{"--force", "--filter", "label=foobar"},
81-
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
82-
assert.Check(t, pruneFilter["label"]["foobar"])
83-
return image.PruneReport{}, nil
83+
imagesPruneFunc: func(opts client.ImagePruneOptions) (client.ImagePruneResult, error) {
84+
assert.Check(t, opts.Filters["label"]["foobar"])
85+
return client.ImagePruneResult{}, nil
8486
},
8587
},
8688
{
8789
name: "force-untagged",
8890
args: []string{"--force"},
89-
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
90-
assert.Check(t, pruneFilter["dangling"]["true"])
91-
return image.PruneReport{
92-
ImagesDeleted: []image.DeleteResponse{{Untagged: "image1"}},
93-
SpaceReclaimed: 2,
91+
imagesPruneFunc: func(opts client.ImagePruneOptions) (client.ImagePruneResult, error) {
92+
assert.Check(t, opts.Filters["dangling"]["true"])
93+
return client.ImagePruneResult{
94+
Report: image.PruneReport{
95+
ImagesDeleted: []image.DeleteResponse{{Untagged: "image1"}},
96+
SpaceReclaimed: 2,
97+
},
9498
}, nil
9599
},
96100
},
@@ -116,8 +120,8 @@ func TestPrunePromptTermination(t *testing.T) {
116120
t.Cleanup(cancel)
117121

118122
cli := test.NewFakeCli(&fakeClient{
119-
imagesPruneFunc: func(pruneFilter client.Filters) (image.PruneReport, error) {
120-
return image.PruneReport{}, errors.New("fakeClient imagesPruneFunc should not be called")
123+
imagesPruneFunc: func(client.ImagePruneOptions) (client.ImagePruneResult, error) {
124+
return client.ImagePruneResult{}, errors.New("fakeClient imagesPruneFunc should not be called")
121125
},
122126
})
123127
cmd := newPruneCommand(cli)

cli/command/network/client_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ type fakeClient struct {
1414
networkDisconnectFunc func(ctx context.Context, networkID, container string, force bool) error
1515
networkRemoveFunc func(ctx context.Context, networkID string) error
1616
networkListFunc func(ctx context.Context, options client.NetworkListOptions) ([]network.Summary, error)
17-
networkPruneFunc func(ctx context.Context, pruneFilters client.Filters) (network.PruneReport, error)
17+
networkPruneFunc func(ctx context.Context, options client.NetworkPruneOptions) (client.NetworkPruneResult, error)
1818
networkInspectFunc func(ctx context.Context, networkID string, options client.NetworkInspectOptions) (network.Inspect, []byte, error)
1919
}
2020

@@ -60,9 +60,9 @@ func (c *fakeClient) NetworkInspectWithRaw(ctx context.Context, networkID string
6060
return network.Inspect{}, nil, nil
6161
}
6262

63-
func (c *fakeClient) NetworksPrune(ctx context.Context, pruneFilter client.Filters) (network.PruneReport, error) {
63+
func (c *fakeClient) NetworksPrune(ctx context.Context, opts client.NetworkPruneOptions) (client.NetworkPruneResult, error) {
6464
if c.networkPruneFunc != nil {
65-
return c.networkPruneFunc(ctx, pruneFilter)
65+
return c.networkPruneFunc(ctx, opts)
6666
}
67-
return network.PruneReport{}, nil
67+
return client.NetworkPruneResult{}, nil
6868
}

cli/command/network/prune.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/docker/cli/cli/command/system/pruner"
1111
"github.com/docker/cli/internal/prompt"
1212
"github.com/docker/cli/opts"
13+
"github.com/moby/moby/client"
1314
"github.com/spf13/cobra"
1415
)
1516

@@ -70,14 +71,16 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
7071
}
7172
}
7273

73-
report, err := dockerCli.Client().NetworksPrune(ctx, pruneFilters)
74+
res, err := dockerCli.Client().NetworksPrune(ctx, client.NetworkPruneOptions{
75+
Filters: pruneFilters,
76+
})
7477
if err != nil {
7578
return "", err
7679
}
7780

78-
if len(report.NetworksDeleted) > 0 {
81+
if len(res.Report.NetworksDeleted) > 0 {
7982
output = "Deleted Networks:\n"
80-
for _, id := range report.NetworksDeleted {
83+
for _, id := range res.Report.NetworksDeleted {
8184
output += id + "\n"
8285
}
8386
}

cli/command/network/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/network"
1110
"github.com/moby/moby/client"
1211
)
1312

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

1817
cli := test.NewFakeCli(&fakeClient{
19-
networkPruneFunc: func(ctx context.Context, pruneFilters client.Filters) (network.PruneReport, error) {
20-
return network.PruneReport{}, errors.New("fakeClient networkPruneFunc should not be called")
18+
networkPruneFunc: func(ctx context.Context, opts client.NetworkPruneOptions) (client.NetworkPruneResult, error) {
19+
return client.NetworkPruneResult{}, errors.New("fakeClient networkPruneFunc should not be called")
2120
},
2221
})
2322
cmd := newPruneCommand(cli)

cli/command/plugin/client_test.go

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,54 @@ import (
1111

1212
type fakeClient struct {
1313
client.Client
14-
pluginCreateFunc func(createContext io.Reader, createOptions client.PluginCreateOptions) error
15-
pluginDisableFunc func(name string, disableOptions client.PluginDisableOptions) error
14+
pluginCreateFunc func(createContext io.Reader, options client.PluginCreateOptions) error
15+
pluginDisableFunc func(name string, options client.PluginDisableOptions) error
1616
pluginEnableFunc func(name string, options client.PluginEnableOptions) error
1717
pluginRemoveFunc func(name string, options client.PluginRemoveOptions) error
1818
pluginInstallFunc func(name string, options client.PluginInstallOptions) (io.ReadCloser, error)
19-
pluginListFunc func(filter client.Filters) (plugin.ListResponse, error)
19+
pluginListFunc func(options client.PluginListOptions) (plugin.ListResponse, error)
2020
pluginInspectFunc func(name string) (*plugin.Plugin, []byte, error)
2121
pluginUpgradeFunc func(name string, options client.PluginInstallOptions) (io.ReadCloser, error)
2222
}
2323

24-
func (c *fakeClient) PluginCreate(_ context.Context, createContext io.Reader, createOptions client.PluginCreateOptions) error {
24+
func (c *fakeClient) PluginCreate(_ context.Context, createContext io.Reader, options client.PluginCreateOptions) error {
2525
if c.pluginCreateFunc != nil {
26-
return c.pluginCreateFunc(createContext, createOptions)
26+
return c.pluginCreateFunc(createContext, options)
2727
}
2828
return nil
2929
}
3030

31-
func (c *fakeClient) PluginEnable(_ context.Context, name string, enableOptions client.PluginEnableOptions) error {
31+
func (c *fakeClient) PluginEnable(_ context.Context, name string, options client.PluginEnableOptions) error {
3232
if c.pluginEnableFunc != nil {
33-
return c.pluginEnableFunc(name, enableOptions)
33+
return c.pluginEnableFunc(name, options)
3434
}
3535
return nil
3636
}
3737

38-
func (c *fakeClient) PluginDisable(_ context.Context, name string, disableOptions client.PluginDisableOptions) error {
38+
func (c *fakeClient) PluginDisable(_ context.Context, name string, options client.PluginDisableOptions) error {
3939
if c.pluginDisableFunc != nil {
40-
return c.pluginDisableFunc(name, disableOptions)
40+
return c.pluginDisableFunc(name, options)
4141
}
4242
return nil
4343
}
4444

45-
func (c *fakeClient) PluginRemove(_ context.Context, name string, removeOptions client.PluginRemoveOptions) error {
45+
func (c *fakeClient) PluginRemove(_ context.Context, name string, options client.PluginRemoveOptions) error {
4646
if c.pluginRemoveFunc != nil {
47-
return c.pluginRemoveFunc(name, removeOptions)
47+
return c.pluginRemoveFunc(name, options)
4848
}
4949
return nil
5050
}
5151

52-
func (c *fakeClient) PluginInstall(_ context.Context, name string, installOptions client.PluginInstallOptions) (io.ReadCloser, error) {
52+
func (c *fakeClient) PluginInstall(_ context.Context, name string, options client.PluginInstallOptions) (io.ReadCloser, error) {
5353
if c.pluginInstallFunc != nil {
54-
return c.pluginInstallFunc(name, installOptions)
54+
return c.pluginInstallFunc(name, options)
5555
}
5656
return nil, nil
5757
}
5858

59-
func (c *fakeClient) PluginList(_ context.Context, filter client.Filters) (plugin.ListResponse, error) {
59+
func (c *fakeClient) PluginList(_ context.Context, options client.PluginListOptions) (plugin.ListResponse, error) {
6060
if c.pluginListFunc != nil {
61-
return c.pluginListFunc(filter)
61+
return c.pluginListFunc(options)
6262
}
6363

6464
return plugin.ListResponse{}, nil

0 commit comments

Comments
 (0)