Browse code

client: rename `ResizeOptions` type to `ContainerResizeOptions`

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>

Austin Vazquez authored on 2025/08/20 21:41:57
Showing 8 changed files
... ...
@@ -72,7 +72,7 @@ type ContainerAPIClient interface {
72 72
 	ContainerExecAttach(ctx context.Context, execID string, options container.ExecAttachOptions) (HijackedResponse, error)
73 73
 	ContainerExecCreate(ctx context.Context, container string, options container.ExecOptions) (container.ExecCreateResponse, error)
74 74
 	ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error)
75
-	ContainerExecResize(ctx context.Context, execID string, options ResizeOptions) error
75
+	ContainerExecResize(ctx context.Context, execID string, options ContainerResizeOptions) error
76 76
 	ContainerExecStart(ctx context.Context, execID string, options container.ExecStartOptions) error
77 77
 	ContainerExport(ctx context.Context, container string) (io.ReadCloser, error)
78 78
 	ContainerInspect(ctx context.Context, container string) (container.InspectResponse, error)
... ...
@@ -83,7 +83,7 @@ type ContainerAPIClient interface {
83 83
 	ContainerPause(ctx context.Context, container string) error
84 84
 	ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error
85 85
 	ContainerRename(ctx context.Context, container, newContainerName string) error
86
-	ContainerResize(ctx context.Context, container string, options ResizeOptions) error
86
+	ContainerResize(ctx context.Context, container string, options ContainerResizeOptions) error
87 87
 	ContainerRestart(ctx context.Context, container string, options container.StopOptions) error
88 88
 	ContainerStatPath(ctx context.Context, container, path string) (container.PathStat, error)
89 89
 	ContainerStats(ctx context.Context, container string, stream bool) (StatsResponseReader, error)
... ...
@@ -6,16 +6,16 @@ import (
6 6
 	"strconv"
7 7
 )
8 8
 
9
-// ResizeOptions holds parameters to resize a TTY.
9
+// ContainerResizeOptions holds parameters to resize a TTY.
10 10
 // It can be used to resize container TTYs and
11 11
 // exec process TTYs too.
12
-type ResizeOptions struct {
12
+type ContainerResizeOptions struct {
13 13
 	Height uint
14 14
 	Width  uint
15 15
 }
16 16
 
17 17
 // ContainerResize changes the size of the pseudo-TTY for a container.
18
-func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ResizeOptions) error {
18
+func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ContainerResizeOptions) error {
19 19
 	containerID, err := trimID("container", containerID)
20 20
 	if err != nil {
21 21
 		return err
... ...
@@ -24,7 +24,7 @@ func (cli *Client) ContainerResize(ctx context.Context, containerID string, opti
24 24
 }
25 25
 
26 26
 // ContainerExecResize changes the size of the tty for an exec process running inside a container.
27
-func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options ResizeOptions) error {
27
+func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options ContainerResizeOptions) error {
28 28
 	execID, err := trimID("exec", execID)
29 29
 	if err != nil {
30 30
 		return err
... ...
@@ -17,14 +17,14 @@ func TestContainerResizeError(t *testing.T) {
17 17
 	client := &Client{
18 18
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
19 19
 	}
20
-	err := client.ContainerResize(context.Background(), "container_id", ResizeOptions{})
20
+	err := client.ContainerResize(context.Background(), "container_id", ContainerResizeOptions{})
21 21
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
22 22
 
23
-	err = client.ContainerResize(context.Background(), "", ResizeOptions{})
23
+	err = client.ContainerResize(context.Background(), "", ContainerResizeOptions{})
24 24
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
25 25
 	assert.Check(t, is.ErrorContains(err, "value is empty"))
26 26
 
27
-	err = client.ContainerResize(context.Background(), "    ", ResizeOptions{})
27
+	err = client.ContainerResize(context.Background(), "    ", ContainerResizeOptions{})
28 28
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInvalidArgument))
29 29
 	assert.Check(t, is.ErrorContains(err, "value is empty"))
30 30
 }
... ...
@@ -33,7 +33,7 @@ func TestContainerExecResizeError(t *testing.T) {
33 33
 	client := &Client{
34 34
 		client: newMockClient(errorMock(http.StatusInternalServerError, "Server error")),
35 35
 	}
36
-	err := client.ContainerExecResize(context.Background(), "exec_id", ResizeOptions{})
36
+	err := client.ContainerExecResize(context.Background(), "exec_id", ContainerResizeOptions{})
37 37
 	assert.Check(t, is.ErrorType(err, cerrdefs.IsInternal))
38 38
 }
39 39
 
... ...
@@ -42,18 +42,18 @@ func TestContainerResize(t *testing.T) {
42 42
 
43 43
 	tests := []struct {
44 44
 		doc                           string
45
-		opts                          ResizeOptions
45
+		opts                          ContainerResizeOptions
46 46
 		expectedHeight, expectedWidth string
47 47
 	}{
48 48
 		{
49 49
 			doc:            "zero width height", // valid, but not very useful
50
-			opts:           ResizeOptions{},
50
+			opts:           ContainerResizeOptions{},
51 51
 			expectedWidth:  "0",
52 52
 			expectedHeight: "0",
53 53
 		},
54 54
 		{
55 55
 			doc: "valid resize",
56
-			opts: ResizeOptions{
56
+			opts: ContainerResizeOptions{
57 57
 				Height: 500,
58 58
 				Width:  600,
59 59
 			},
... ...
@@ -62,7 +62,7 @@ func TestContainerResize(t *testing.T) {
62 62
 		},
63 63
 		{
64 64
 			doc: "larger than maxint64",
65
-			opts: ResizeOptions{
65
+			opts: ContainerResizeOptions{
66 66
 				Height: math.MaxInt64 + 1,
67 67
 				Width:  math.MaxInt64 + 2,
68 68
 			},
... ...
@@ -85,18 +85,18 @@ func TestContainerExecResize(t *testing.T) {
85 85
 	const expectedURL = "/exec/exec_id/resize"
86 86
 	tests := []struct {
87 87
 		doc                           string
88
-		opts                          ResizeOptions
88
+		opts                          ContainerResizeOptions
89 89
 		expectedHeight, expectedWidth string
90 90
 	}{
91 91
 		{
92 92
 			doc:            "zero width height", // valid, but not very useful
93
-			opts:           ResizeOptions{},
93
+			opts:           ContainerResizeOptions{},
94 94
 			expectedWidth:  "0",
95 95
 			expectedHeight: "0",
96 96
 		},
97 97
 		{
98 98
 			doc: "valid resize",
99
-			opts: ResizeOptions{
99
+			opts: ContainerResizeOptions{
100 100
 				Height: 500,
101 101
 				Width:  600,
102 102
 			},
... ...
@@ -105,7 +105,7 @@ func TestContainerExecResize(t *testing.T) {
105 105
 		},
106 106
 		{
107 107
 			doc: "larger than maxint64",
108
-			opts: ResizeOptions{
108
+			opts: ContainerResizeOptions{
109 109
 				Height: math.MaxInt64 + 1,
110 110
 				Width:  math.MaxInt64 + 2,
111 111
 			},
... ...
@@ -453,7 +453,7 @@ func (s *DockerCLIEventSuite) TestEventsResize(c *testing.T) {
453 453
 	assert.NilError(c, err)
454 454
 	defer apiClient.Close()
455 455
 
456
-	options := client.ResizeOptions{
456
+	options := client.ContainerResizeOptions{
457 457
 		Height: 80,
458 458
 		Width:  24,
459 459
 	}
... ...
@@ -138,7 +138,7 @@ func TestExecResize(t *testing.T) {
138 138
 	assert.NilError(t, err)
139 139
 
140 140
 	t.Run("success", func(t *testing.T) {
141
-		err := apiClient.ContainerExecResize(ctx, execID, client.ResizeOptions{
141
+		err := apiClient.ContainerExecResize(ctx, execID, client.ContainerResizeOptions{
142 142
 			Height: 40,
143 143
 			Width:  40,
144 144
 		})
... ...
@@ -247,7 +247,7 @@ func TestExecResize(t *testing.T) {
247 247
 	})
248 248
 
249 249
 	t.Run("unknown execID", func(t *testing.T) {
250
-		err = apiClient.ContainerExecResize(ctx, "no-such-exec-id", client.ResizeOptions{
250
+		err = apiClient.ContainerExecResize(ctx, "no-such-exec-id", client.ContainerResizeOptions{
251 251
 			Height: 40,
252 252
 			Width:  40,
253 253
 		})
... ...
@@ -275,7 +275,7 @@ func TestExecResize(t *testing.T) {
275 275
 		err := apiClient.ContainerKill(ctx, cID, "SIGKILL")
276 276
 		assert.NilError(t, err)
277 277
 
278
-		err = apiClient.ContainerExecResize(ctx, execID, client.ResizeOptions{
278
+		err = apiClient.ContainerExecResize(ctx, execID, client.ContainerResizeOptions{
279 279
 			Height: 40,
280 280
 			Width:  40,
281 281
 		})
... ...
@@ -23,7 +23,7 @@ func TestResize(t *testing.T) {
23 23
 	t.Run("success", func(t *testing.T) {
24 24
 		cID := container.Run(ctx, t, apiClient, container.WithTty(true))
25 25
 		defer container.Remove(ctx, t, apiClient, cID, containertypes.RemoveOptions{Force: true})
26
-		err := apiClient.ContainerResize(ctx, cID, client.ResizeOptions{
26
+		err := apiClient.ContainerResize(ctx, cID, client.ContainerResizeOptions{
27 27
 			Height: 40,
28 28
 			Width:  40,
29 29
 		})
... ...
@@ -130,7 +130,7 @@ func TestResize(t *testing.T) {
130 130
 	t.Run("invalid state", func(t *testing.T) {
131 131
 		cID := container.Create(ctx, t, apiClient, container.WithCmd("echo"))
132 132
 		defer container.Remove(ctx, t, apiClient, cID, containertypes.RemoveOptions{Force: true})
133
-		err := apiClient.ContainerResize(ctx, cID, client.ResizeOptions{
133
+		err := apiClient.ContainerResize(ctx, cID, client.ContainerResizeOptions{
134 134
 			Height: 40,
135 135
 			Width:  40,
136 136
 		})
... ...
@@ -72,7 +72,7 @@ type ContainerAPIClient interface {
72 72
 	ContainerExecAttach(ctx context.Context, execID string, options container.ExecAttachOptions) (HijackedResponse, error)
73 73
 	ContainerExecCreate(ctx context.Context, container string, options container.ExecOptions) (container.ExecCreateResponse, error)
74 74
 	ContainerExecInspect(ctx context.Context, execID string) (container.ExecInspect, error)
75
-	ContainerExecResize(ctx context.Context, execID string, options ResizeOptions) error
75
+	ContainerExecResize(ctx context.Context, execID string, options ContainerResizeOptions) error
76 76
 	ContainerExecStart(ctx context.Context, execID string, options container.ExecStartOptions) error
77 77
 	ContainerExport(ctx context.Context, container string) (io.ReadCloser, error)
78 78
 	ContainerInspect(ctx context.Context, container string) (container.InspectResponse, error)
... ...
@@ -83,7 +83,7 @@ type ContainerAPIClient interface {
83 83
 	ContainerPause(ctx context.Context, container string) error
84 84
 	ContainerRemove(ctx context.Context, container string, options container.RemoveOptions) error
85 85
 	ContainerRename(ctx context.Context, container, newContainerName string) error
86
-	ContainerResize(ctx context.Context, container string, options ResizeOptions) error
86
+	ContainerResize(ctx context.Context, container string, options ContainerResizeOptions) error
87 87
 	ContainerRestart(ctx context.Context, container string, options container.StopOptions) error
88 88
 	ContainerStatPath(ctx context.Context, container, path string) (container.PathStat, error)
89 89
 	ContainerStats(ctx context.Context, container string, stream bool) (StatsResponseReader, error)
... ...
@@ -6,16 +6,16 @@ import (
6 6
 	"strconv"
7 7
 )
8 8
 
9
-// ResizeOptions holds parameters to resize a TTY.
9
+// ContainerResizeOptions holds parameters to resize a TTY.
10 10
 // It can be used to resize container TTYs and
11 11
 // exec process TTYs too.
12
-type ResizeOptions struct {
12
+type ContainerResizeOptions struct {
13 13
 	Height uint
14 14
 	Width  uint
15 15
 }
16 16
 
17 17
 // ContainerResize changes the size of the pseudo-TTY for a container.
18
-func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ResizeOptions) error {
18
+func (cli *Client) ContainerResize(ctx context.Context, containerID string, options ContainerResizeOptions) error {
19 19
 	containerID, err := trimID("container", containerID)
20 20
 	if err != nil {
21 21
 		return err
... ...
@@ -24,7 +24,7 @@ func (cli *Client) ContainerResize(ctx context.Context, containerID string, opti
24 24
 }
25 25
 
26 26
 // ContainerExecResize changes the size of the tty for an exec process running inside a container.
27
-func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options ResizeOptions) error {
27
+func (cli *Client) ContainerExecResize(ctx context.Context, execID string, options ContainerResizeOptions) error {
28 28
 	execID, err := trimID("exec", execID)
29 29
 	if err != nil {
30 30
 		return err