Skip to content

Commit e2a4e42

Browse files
authored
Merge pull request docker#6211 from thaJeztah/bump_engine
vendor: update docker, api, client to master, consume client/pkg/stringid
2 parents fdc4397 + d63cae6 commit e2a4e42

37 files changed

+274
-263
lines changed

cli/command/container/client_test.go

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

7-
"github.com/moby/moby/api/types"
87
"github.com/moby/moby/api/types/container"
98
"github.com/moby/moby/api/types/filters"
109
"github.com/moby/moby/api/types/image"
@@ -39,7 +38,7 @@ type fakeClient struct {
3938
containerStopFunc func(ctx context.Context, containerID string, options container.StopOptions) error
4039
containerKillFunc func(ctx context.Context, containerID, signal string) error
4140
containerPruneFunc func(ctx context.Context, pruneFilters filters.Args) (container.PruneReport, error)
42-
containerAttachFunc func(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error)
41+
containerAttachFunc func(ctx context.Context, containerID string, options container.AttachOptions) (client.HijackedResponse, error)
4342
containerDiffFunc func(ctx context.Context, containerID string) ([]container.FilesystemChange, error)
4443
containerRenameFunc func(ctx context.Context, oldName, newName string) error
4544
containerCommitFunc func(ctx context.Context, container string, options container.CommitOptions) (container.CommitResponse, error)
@@ -195,11 +194,11 @@ func (f *fakeClient) ContainerStop(ctx context.Context, containerID string, opti
195194
return nil
196195
}
197196

198-
func (f *fakeClient) ContainerAttach(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error) {
197+
func (f *fakeClient) ContainerAttach(ctx context.Context, containerID string, options container.AttachOptions) (client.HijackedResponse, error) {
199198
if f.containerAttachFunc != nil {
200199
return f.containerAttachFunc(ctx, containerID, options)
201200
}
202-
return types.HijackedResponse{}, nil
201+
return client.HijackedResponse{}, nil
203202
}
204203

205204
func (f *fakeClient) ContainerDiff(ctx context.Context, containerID string) ([]container.FilesystemChange, error) {

cli/command/container/hijack.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import (
99

1010
"github.com/docker/cli/cli/command"
1111
"github.com/moby/moby/api/stdcopy"
12-
"github.com/moby/moby/api/types"
12+
"github.com/moby/moby/client"
1313
"github.com/moby/term"
1414
"github.com/sirupsen/logrus"
1515
)
@@ -38,7 +38,7 @@ type hijackedIOStreamer struct {
3838
outputStream io.Writer
3939
errorStream io.Writer
4040

41-
resp types.HijackedResponse
41+
resp client.HijackedResponse
4242

4343
tty bool
4444
detachKeys string

cli/command/container/run_test.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/moby/moby/api/types/container"
2222
"github.com/moby/moby/api/types/image"
2323
"github.com/moby/moby/api/types/network"
24+
"github.com/moby/moby/client"
2425
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2526
"github.com/spf13/pflag"
2627
"gotest.tools/v3/assert"
@@ -85,14 +86,14 @@ func TestRunAttach(t *testing.T) {
8586
ID: "id",
8687
}, nil
8788
},
88-
containerAttachFunc: func(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error) {
89-
server, client := net.Pipe()
89+
containerAttachFunc: func(ctx context.Context, containerID string, options container.AttachOptions) (client.HijackedResponse, error) {
90+
server, clientConn := net.Pipe()
9091
conn = server
9192
t.Cleanup(func() {
9293
_ = server.Close()
9394
})
9495
attachCh <- struct{}{}
95-
return types.NewHijackedResponse(client, types.MediaTypeRawStream), nil
96+
return client.NewHijackedResponse(clientConn, types.MediaTypeRawStream), nil
9697
},
9798
waitFunc: func(_ string) (<-chan container.WaitResponse, <-chan error) {
9899
responseChan := make(chan container.WaitResponse, 1)
@@ -162,14 +163,14 @@ func TestRunAttachTermination(t *testing.T) {
162163
}
163164
return nil
164165
},
165-
containerAttachFunc: func(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error) {
166-
server, client := net.Pipe()
166+
containerAttachFunc: func(ctx context.Context, containerID string, options container.AttachOptions) (client.HijackedResponse, error) {
167+
server, clientConn := net.Pipe()
167168
conn = server
168169
t.Cleanup(func() {
169170
_ = server.Close()
170171
})
171172
attachCh <- struct{}{}
172-
return types.NewHijackedResponse(client, types.MediaTypeRawStream), nil
173+
return client.NewHijackedResponse(clientConn, types.MediaTypeRawStream), nil
173174
},
174175
waitFunc: func(_ string) (<-chan container.WaitResponse, <-chan error) {
175176
responseChan := make(chan container.WaitResponse, 1)
@@ -233,8 +234,8 @@ func TestRunPullTermination(t *testing.T) {
233234
) (container.CreateResponse, error) {
234235
return container.CreateResponse{}, errors.New("shouldn't try to create a container")
235236
},
236-
containerAttachFunc: func(ctx context.Context, containerID string, options container.AttachOptions) (types.HijackedResponse, error) {
237-
return types.HijackedResponse{}, errors.New("shouldn't try to attach to a container")
237+
containerAttachFunc: func(ctx context.Context, containerID string, options container.AttachOptions) (client.HijackedResponse, error) {
238+
return client.HijackedResponse{}, errors.New("shouldn't try to attach to a container")
238239
},
239240
imageCreateFunc: func(ctx context.Context, parentReference string, options image.CreateOptions) (io.ReadCloser, error) {
240241
server, client := net.Pipe()

cli/command/formatter/displayutils.go

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"strings"
99
"unicode/utf8"
1010

11+
"github.com/moby/moby/client/pkg/stringid"
1112
"golang.org/x/text/width"
1213
)
1314

@@ -27,23 +28,12 @@ func charWidth(r rune) int {
2728
}
2829
}
2930

30-
const shortLen = 12
31-
3231
// TruncateID returns a shorthand version of a string identifier for presentation,
3332
// after trimming digest algorithm prefix (if any).
3433
//
35-
// This function is a copy of [stringid.TruncateID] for presentation / formatting
36-
// purposes.
37-
//
38-
// [stringid.TruncateID]: https://github.com/moby/moby/blob/v28.3.2/pkg/stringid/stringid.go#L19
34+
// This function is a wrapper for [stringid.TruncateID] for convenience.
3935
func TruncateID(id string) string {
40-
if i := strings.IndexRune(id, ':'); i >= 0 {
41-
id = id[i+1:]
42-
}
43-
if len(id) > shortLen {
44-
id = id[:shortLen]
45-
}
46-
return id
36+
return stringid.TruncateID(id)
4737
}
4838

4939
// Ellipsis truncates a string to fit within maxDisplayWidth, and appends ellipsis (…).

cli/command/plugin/client_test.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,45 +12,45 @@ import (
1212

1313
type fakeClient struct {
1414
client.Client
15-
pluginCreateFunc func(createContext io.Reader, createOptions types.PluginCreateOptions) error
16-
pluginDisableFunc func(name string, disableOptions types.PluginDisableOptions) error
17-
pluginEnableFunc func(name string, options types.PluginEnableOptions) error
18-
pluginRemoveFunc func(name string, options types.PluginRemoveOptions) error
19-
pluginInstallFunc func(name string, options types.PluginInstallOptions) (io.ReadCloser, error)
15+
pluginCreateFunc func(createContext io.Reader, createOptions client.PluginCreateOptions) error
16+
pluginDisableFunc func(name string, disableOptions client.PluginDisableOptions) error
17+
pluginEnableFunc func(name string, options client.PluginEnableOptions) error
18+
pluginRemoveFunc func(name string, options client.PluginRemoveOptions) error
19+
pluginInstallFunc func(name string, options client.PluginInstallOptions) (io.ReadCloser, error)
2020
pluginListFunc func(filter filters.Args) (types.PluginsListResponse, error)
2121
pluginInspectFunc func(name string) (*types.Plugin, []byte, error)
22-
pluginUpgradeFunc func(name string, options types.PluginInstallOptions) (io.ReadCloser, error)
22+
pluginUpgradeFunc func(name string, options client.PluginInstallOptions) (io.ReadCloser, error)
2323
}
2424

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

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

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

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

53-
func (c *fakeClient) PluginInstall(_ context.Context, name string, installOptions types.PluginInstallOptions) (io.ReadCloser, error) {
53+
func (c *fakeClient) PluginInstall(_ context.Context, name string, installOptions client.PluginInstallOptions) (io.ReadCloser, error) {
5454
if c.pluginInstallFunc != nil {
5555
return c.pluginInstallFunc(name, installOptions)
5656
}
@@ -77,7 +77,7 @@ func (*fakeClient) Info(context.Context) (system.Info, error) {
7777
return system.Info{}, nil
7878
}
7979

80-
func (c *fakeClient) PluginUpgrade(_ context.Context, name string, options types.PluginInstallOptions) (io.ReadCloser, error) {
80+
func (c *fakeClient) PluginUpgrade(_ context.Context, name string, options client.PluginInstallOptions) (io.ReadCloser, error) {
8181
if c.pluginUpgradeFunc != nil {
8282
return c.pluginUpgradeFunc(name, options)
8383
}

cli/command/plugin/create.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/moby/go-archive"
1515
"github.com/moby/go-archive/compression"
1616
"github.com/moby/moby/api/types"
17+
"github.com/moby/moby/client"
1718
"github.com/pkg/errors"
1819
"github.com/sirupsen/logrus"
1920
"github.com/spf13/cobra"
@@ -113,7 +114,7 @@ func runCreate(ctx context.Context, dockerCli command.Cli, options pluginCreateO
113114
return err
114115
}
115116

116-
err = dockerCli.Client().PluginCreate(ctx, createCtx, types.PluginCreateOptions{RepoName: options.repoName})
117+
err = dockerCli.Client().PluginCreate(ctx, createCtx, client.PluginCreateOptions{RepoName: options.repoName})
117118
if err != nil {
118119
return err
119120
}

cli/command/plugin/create_test.go

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

99
"github.com/docker/cli/internal/test"
10-
"github.com/moby/moby/api/types"
10+
"github.com/moby/moby/client"
1111
"gotest.tools/v3/assert"
1212
is "gotest.tools/v3/assert/cmp"
1313
"gotest.tools/v3/fs"
@@ -96,7 +96,7 @@ func TestCreateErrorFromDaemon(t *testing.T) {
9696
defer tmpDir.Remove()
9797

9898
cmd := newCreateCommand(test.NewFakeCli(&fakeClient{
99-
pluginCreateFunc: func(createContext io.Reader, createOptions types.PluginCreateOptions) error {
99+
pluginCreateFunc: func(createContext io.Reader, createOptions client.PluginCreateOptions) error {
100100
return errors.New("error creating plugin")
101101
},
102102
}))
@@ -113,7 +113,7 @@ func TestCreatePlugin(t *testing.T) {
113113
defer tmpDir.Remove()
114114

115115
cli := test.NewFakeCli(&fakeClient{
116-
pluginCreateFunc: func(createContext io.Reader, createOptions types.PluginCreateOptions) error {
116+
pluginCreateFunc: func(createContext io.Reader, createOptions client.PluginCreateOptions) error {
117117
return nil
118118
},
119119
})

cli/command/plugin/disable.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import (
55

66
"github.com/docker/cli/cli"
77
"github.com/docker/cli/cli/command"
8-
"github.com/moby/moby/api/types"
8+
"github.com/moby/moby/client"
99
"github.com/spf13/cobra"
1010
)
1111

1212
func newDisableCommand(dockerCLI command.Cli) *cobra.Command {
13-
var opts types.PluginDisableOptions
13+
var opts client.PluginDisableOptions
1414

1515
cmd := &cobra.Command{
1616
Use: "disable [OPTIONS] PLUGIN",

cli/command/plugin/disable_test.go

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

88
"github.com/docker/cli/internal/test"
9-
"github.com/moby/moby/api/types"
9+
"github.com/moby/moby/client"
1010
"gotest.tools/v3/assert"
1111
is "gotest.tools/v3/assert/cmp"
1212
)
@@ -15,7 +15,7 @@ func TestPluginDisableErrors(t *testing.T) {
1515
testCases := []struct {
1616
args []string
1717
expectedError string
18-
pluginDisableFunc func(name string, disableOptions types.PluginDisableOptions) error
18+
pluginDisableFunc func(name string, disableOptions client.PluginDisableOptions) error
1919
}{
2020
{
2121
args: []string{},
@@ -28,7 +28,7 @@ func TestPluginDisableErrors(t *testing.T) {
2828
{
2929
args: []string{"plugin-foo"},
3030
expectedError: "error disabling plugin",
31-
pluginDisableFunc: func(name string, disableOptions types.PluginDisableOptions) error {
31+
pluginDisableFunc: func(name string, disableOptions client.PluginDisableOptions) error {
3232
return errors.New("error disabling plugin")
3333
},
3434
},
@@ -48,7 +48,7 @@ func TestPluginDisableErrors(t *testing.T) {
4848

4949
func TestPluginDisable(t *testing.T) {
5050
cli := test.NewFakeCli(&fakeClient{
51-
pluginDisableFunc: func(name string, disableOptions types.PluginDisableOptions) error {
51+
pluginDisableFunc: func(name string, disableOptions client.PluginDisableOptions) error {
5252
return nil
5353
},
5454
})

cli/command/plugin/enable.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ import (
66

77
"github.com/docker/cli/cli"
88
"github.com/docker/cli/cli/command"
9-
"github.com/moby/moby/api/types"
9+
"github.com/moby/moby/client"
1010
"github.com/pkg/errors"
1111
"github.com/spf13/cobra"
1212
)
1313

1414
func newEnableCommand(dockerCli command.Cli) *cobra.Command {
15-
var opts types.PluginEnableOptions
15+
var opts client.PluginEnableOptions
1616

1717
cmd := &cobra.Command{
1818
Use: "enable [OPTIONS] PLUGIN",
@@ -33,7 +33,7 @@ func newEnableCommand(dockerCli command.Cli) *cobra.Command {
3333
return cmd
3434
}
3535

36-
func runEnable(ctx context.Context, dockerCli command.Cli, name string, opts types.PluginEnableOptions) error {
36+
func runEnable(ctx context.Context, dockerCli command.Cli, name string, opts client.PluginEnableOptions) error {
3737
if opts.Timeout < 0 {
3838
return errors.Errorf("negative timeout %d is invalid", opts.Timeout)
3939
}

0 commit comments

Comments
 (0)