Skip to content

Commit 16d2036

Browse files
authored
Merge pull request #6620 from austinvazquez/vendor-system-disk-usage-changes
vendor: github.com/moby/moby/api master, moby/client master
2 parents cc7275c + 5039eee commit 16d2036

Some content is hidden

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

56 files changed

+951
-645
lines changed

cli/command/container/client_test.go

Lines changed: 6 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,18 @@ package container
33
import (
44
"context"
55
"io"
6-
"reflect"
6+
"net/http"
77
"strings"
8-
"unsafe"
98

109
"github.com/moby/moby/client"
1110
)
1211

1312
func mockContainerExportResult(content string) client.ContainerExportResult {
14-
out := client.ContainerExportResult{}
15-
16-
// Set unexported field "rc"
17-
v := reflect.ValueOf(&out).Elem()
18-
f := v.FieldByName("rc")
19-
r := io.NopCloser(strings.NewReader(content))
20-
reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Elem().Set(reflect.ValueOf(r))
21-
return out
13+
return io.NopCloser(strings.NewReader(content))
2214
}
2315

2416
func mockContainerLogsResult(content string) client.ContainerLogsResult {
25-
out := client.ContainerLogsResult{}
26-
27-
// Set unexported field "rc"
28-
v := reflect.ValueOf(&out).Elem()
29-
f := v.FieldByName("rc")
30-
r := io.NopCloser(strings.NewReader(content))
31-
reflect.NewAt(f.Type(), unsafe.Pointer(f.UnsafeAddr())).Elem().Set(reflect.ValueOf(r))
32-
return out
17+
return io.NopCloser(strings.NewReader(content))
3318
}
3419

3520
type fakeStreamResult struct {
@@ -147,7 +132,7 @@ func (f *fakeClient) ContainerLogs(_ context.Context, containerID string, option
147132
if f.logFunc != nil {
148133
return f.logFunc(containerID, options)
149134
}
150-
return client.ContainerLogsResult{}, nil
135+
return http.NoBody, nil
151136
}
152137

153138
func (f *fakeClient) ClientVersion() string {
@@ -172,7 +157,7 @@ func (f *fakeClient) ContainerExport(_ context.Context, containerID string, _ cl
172157
if f.containerExportFunc != nil {
173158
return f.containerExportFunc(containerID)
174159
}
175-
return client.ContainerExportResult{}, nil
160+
return http.NoBody, nil
176161
}
177162

178163
func (f *fakeClient) ExecResize(_ context.Context, id string, options client.ExecResizeOptions) (client.ExecResizeResult, error) {
@@ -189,7 +174,7 @@ func (f *fakeClient) ContainerKill(ctx context.Context, containerID string, opti
189174
return client.ContainerKillResult{}, nil
190175
}
191176

192-
func (f *fakeClient) ContainersPrune(ctx context.Context, options client.ContainerPruneOptions) (client.ContainerPruneResult, error) {
177+
func (f *fakeClient) ContainerPrune(ctx context.Context, options client.ContainerPruneOptions) (client.ContainerPruneResult, error) {
193178
if f.containerPruneFunc != nil {
194179
return f.containerPruneFunc(ctx, options)
195180
}

cli/command/container/exec.go

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func RunExec(ctx context.Context, dockerCLI command.Cli, containerIDorName strin
101101
return err
102102
}
103103
if !options.Detach {
104-
if err := dockerCLI.In().CheckTty(execOptions.AttachStdin, execOptions.Tty); err != nil {
104+
if err := dockerCLI.In().CheckTty(execOptions.AttachStdin, execOptions.TTY); err != nil {
105105
return err
106106
}
107107
}
@@ -119,27 +119,20 @@ func RunExec(ctx context.Context, dockerCLI command.Cli, containerIDorName strin
119119
}
120120

121121
if options.Detach {
122-
var cs client.ConsoleSize
123-
if execOptions.ConsoleSize != nil {
124-
cs = client.ConsoleSize{
125-
Height: execOptions.ConsoleSize[0],
126-
Width: execOptions.ConsoleSize[1],
127-
}
128-
}
129122
_, err := apiClient.ExecStart(ctx, execID, client.ExecStartOptions{
130123
Detach: options.Detach,
131-
TTY: execOptions.Tty,
132-
ConsoleSize: cs,
124+
TTY: execOptions.TTY,
125+
ConsoleSize: client.ConsoleSize{Height: execOptions.ConsoleSize.Height, Width: execOptions.ConsoleSize.Width},
133126
})
134127
return err
135128
}
136129
return interactiveExec(ctx, dockerCLI, execOptions, execID)
137130
}
138131

139132
func fillConsoleSize(execOptions *client.ExecCreateOptions, dockerCli command.Cli) {
140-
if execOptions.Tty {
133+
if execOptions.TTY {
141134
height, width := dockerCli.Out().GetTtySize()
142-
execOptions.ConsoleSize = &[2]uint{height, width}
135+
execOptions.ConsoleSize = client.ConsoleSize{Height: height, Width: width}
143136
}
144137
}
145138

@@ -157,7 +150,7 @@ func interactiveExec(ctx context.Context, dockerCli command.Cli, execOptions *cl
157150
out = dockerCli.Out()
158151
}
159152
if execOptions.AttachStderr {
160-
if execOptions.Tty {
153+
if execOptions.TTY {
161154
stderr = dockerCli.Out()
162155
} else {
163156
stderr = dockerCli.Err()
@@ -166,16 +159,9 @@ func interactiveExec(ctx context.Context, dockerCli command.Cli, execOptions *cl
166159
fillConsoleSize(execOptions, dockerCli)
167160

168161
apiClient := dockerCli.Client()
169-
var cs client.ConsoleSize
170-
if execOptions.ConsoleSize != nil {
171-
cs = client.ConsoleSize{
172-
Height: execOptions.ConsoleSize[0],
173-
Width: execOptions.ConsoleSize[1],
174-
}
175-
}
176162
resp, err := apiClient.ExecAttach(ctx, execID, client.ExecAttachOptions{
177-
TTY: execOptions.Tty,
178-
ConsoleSize: cs,
163+
TTY: execOptions.TTY,
164+
ConsoleSize: client.ConsoleSize{Height: execOptions.ConsoleSize.Height, Width: execOptions.ConsoleSize.Width},
179165
})
180166
if err != nil {
181167
return err
@@ -193,15 +179,15 @@ func interactiveExec(ctx context.Context, dockerCli command.Cli, execOptions *cl
193179
outputStream: out,
194180
errorStream: stderr,
195181
resp: resp.HijackedResponse,
196-
tty: execOptions.Tty,
182+
tty: execOptions.TTY,
197183
detachKeys: execOptions.DetachKeys,
198184
}
199185

200186
return streamer.stream(ctx)
201187
}()
202188
}()
203189

204-
if execOptions.Tty && dockerCli.In().IsTerminal() {
190+
if execOptions.TTY && dockerCli.In().IsTerminal() {
205191
if err := MonitorTtySize(ctx, dockerCli, execID, true); err != nil {
206192
_, _ = fmt.Fprintln(dockerCli.Err(), "Error monitoring TTY size:", err)
207193
}
@@ -237,7 +223,7 @@ func parseExec(execOpts ExecOptions, configFile *configfile.ConfigFile) (*client
237223
execOptions := &client.ExecCreateOptions{
238224
User: execOpts.User,
239225
Privileged: execOpts.Privileged,
240-
Tty: execOpts.TTY,
226+
TTY: execOpts.TTY,
241227
Cmd: execOpts.Command,
242228
WorkingDir: execOpts.Workdir,
243229
}

cli/command/container/exec_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ TWO=2
6969
AttachStdin: true,
7070
AttachStdout: true,
7171
AttachStderr: true,
72-
Tty: true,
72+
TTY: true,
7373
Cmd: []string{"command"},
7474
},
7575
},
@@ -86,7 +86,7 @@ TWO=2
8686
Detach: true,
8787
}),
8888
expected: client.ExecCreateOptions{
89-
Tty: true,
89+
TTY: true,
9090
Cmd: []string{"command"},
9191
},
9292
},

cli/command/container/prune.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ func runPrune(ctx context.Context, dockerCli command.Cli, options pruneOptions)
7575
}
7676
}
7777

78-
res, err := dockerCli.Client().ContainersPrune(ctx, client.ContainerPruneOptions{
78+
res, err := dockerCli.Client().ContainerPrune(ctx, client.ContainerPruneOptions{
7979
Filters: pruneFilters,
8080
})
8181
if err != nil {

cli/command/formatter/buildcache.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ shared: {{.Shared}}
5151
return Format(source)
5252
}
5353

54-
func buildCacheSort(buildCache []*build.CacheRecord) {
54+
func buildCacheSort(buildCache []build.CacheRecord) {
5555
sort.Slice(buildCache, func(i, j int) bool {
5656
lui, luj := buildCache[i].LastUsedAt, buildCache[j].LastUsedAt
5757
switch {
@@ -70,7 +70,7 @@ func buildCacheSort(buildCache []*build.CacheRecord) {
7070
}
7171

7272
// BuildCacheWrite renders the context for a list of containers
73-
func BuildCacheWrite(ctx Context, buildCaches []*build.CacheRecord) error {
73+
func BuildCacheWrite(ctx Context, buildCaches []build.CacheRecord) error {
7474
render := func(format func(subContext SubContext) error) error {
7575
buildCacheSort(buildCaches)
7676
for _, bc := range buildCaches {
@@ -87,7 +87,7 @@ func BuildCacheWrite(ctx Context, buildCaches []*build.CacheRecord) error {
8787
type buildCacheContext struct {
8888
HeaderContext
8989
trunc bool
90-
v *build.CacheRecord
90+
v build.CacheRecord
9191
}
9292

9393
func newBuildCacheContext() *buildCacheContext {

0 commit comments

Comments
 (0)