Skip to content

Commit 30f09b4

Browse files
committed
api/types: move ContainerAttachOptions to api/types/container
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 95b92b1 commit 30f09b4

10 files changed

Lines changed: 27 additions & 19 deletions

File tree

api/types/client.go

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,6 @@ import (
1111
units "github.com/docker/go-units"
1212
)
1313

14-
// ContainerAttachOptions holds parameters to attach to a container.
15-
type ContainerAttachOptions struct {
16-
Stream bool
17-
Stdin bool
18-
Stdout bool
19-
Stderr bool
20-
DetachKeys string
21-
Logs bool
22-
}
23-
2414
// ContainerCommitOptions holds parameters to commit changes into a container.
2515
type ContainerCommitOptions struct {
2616
Reference string

api/types/container/options.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,13 @@ type ResizeOptions struct {
77
Height uint
88
Width uint
99
}
10+
11+
// AttachOptions holds parameters to attach to a container.
12+
type AttachOptions struct {
13+
Stream bool
14+
Stdin bool
15+
Stdout bool
16+
Stderr bool
17+
DetachKeys string
18+
Logs bool
19+
}

api/types/types_deprecated.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@ type ServiceUpdateResponse = swarm.ServiceUpdateResponse
9999
// Deprecated: use [container.ResizeOptions].
100100
type ResizeOptions = container.ResizeOptions
101101

102+
// ContainerAttachOptions holds parameters to attach to a container.
103+
//
104+
// Deprecated: use [container.AttachOptions].
105+
type ContainerAttachOptions = container.AttachOptions
106+
102107
// DecodeSecurityOptions decodes a security options string slice to a type safe
103108
// [system.SecurityOpt].
104109
//

client/container_attach.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"net/url"
77

88
"github.com/docker/docker/api/types"
9+
"github.com/docker/docker/api/types/container"
910
)
1011

1112
// ContainerAttach attaches a connection to a container in the server.
@@ -32,7 +33,7 @@ import (
3233
//
3334
// You can use github.com/docker/docker/pkg/stdcopy.StdCopy to demultiplex this
3435
// stream.
35-
func (cli *Client) ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error) {
36+
func (cli *Client) ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error) {
3637
query := url.Values{}
3738
if options.Stream {
3839
query.Set("stream", "1")

client/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ type CommonAPIClient interface {
4646

4747
// ContainerAPIClient defines API client methods for the containers
4848
type ContainerAPIClient interface {
49-
ContainerAttach(ctx context.Context, container string, options types.ContainerAttachOptions) (types.HijackedResponse, error)
49+
ContainerAttach(ctx context.Context, container string, options container.AttachOptions) (types.HijackedResponse, error)
5050
ContainerCommit(ctx context.Context, container string, options types.ContainerCommitOptions) (types.IDResponse, error)
5151
ContainerCreate(ctx context.Context, config *container.Config, hostConfig *container.HostConfig, networkingConfig *network.NetworkingConfig, platform *ocispec.Platform, containerName string) (container.CreateResponse, error)
5252
ContainerDiff(ctx context.Context, container string) ([]container.FilesystemChange, error)

integration-cli/docker_api_attach_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"time"
1212

1313
"github.com/docker/docker/api/types"
14+
"github.com/docker/docker/api/types/container"
1415
"github.com/docker/docker/client"
1516
"github.com/docker/docker/pkg/stdcopy"
1617
"github.com/docker/docker/testutil"
@@ -184,7 +185,7 @@ func (s *DockerAPISuite) TestPostContainersAttach(c *testing.T) {
184185
cid = strings.TrimSpace(cid)
185186

186187
// Make sure we don't see "hello" if Logs is false
187-
attachOpts := types.ContainerAttachOptions{
188+
attachOpts := container.AttachOptions{
188189
Stream: true,
189190
Stdin: true,
190191
Stdout: true,

integration/container/attach_test.go

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

1414
func TestAttach(t *testing.T) {
1515
ctx := setupTest(t)
16-
client := testEnv.APIClient()
16+
apiClient := testEnv.APIClient()
1717

1818
tests := []struct {
1919
doc string
@@ -36,7 +36,7 @@ func TestAttach(t *testing.T) {
3636
t.Parallel()
3737

3838
ctx := testutil.StartSpan(ctx, t)
39-
resp, err := client.ContainerCreate(ctx,
39+
resp, err := apiClient.ContainerCreate(ctx,
4040
&container.Config{
4141
Image: "busybox",
4242
Cmd: []string{"echo", "hello"},
@@ -48,7 +48,7 @@ func TestAttach(t *testing.T) {
4848
"",
4949
)
5050
assert.NilError(t, err)
51-
attach, err := client.ContainerAttach(ctx, resp.ID, types.ContainerAttachOptions{
51+
attach, err := apiClient.ContainerAttach(ctx, resp.ID, container.AttachOptions{
5252
Stdout: true,
5353
Stderr: true,
5454
})

integration/container/wait_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func TestWaitConditions(t *testing.T) {
145145
containerID := container.Create(ctx, t, cli, opts...)
146146
t.Logf("ContainerID = %v", containerID)
147147

148-
streams, err := cli.ContainerAttach(ctx, containerID, types.ContainerAttachOptions{Stream: true, Stdin: true})
148+
streams, err := cli.ContainerAttach(ctx, containerID, containertypes.AttachOptions{Stream: true, Stdin: true})
149149
assert.NilError(t, err)
150150
defer streams.Close()
151151

integration/internal/container/container.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func RunAttach(ctx context.Context, t *testing.T, apiClient client.APIClient, op
9999
})
100100
id := Create(ctx, t, apiClient, ops...)
101101

102-
aresp, err := apiClient.ContainerAttach(ctx, id, types.ContainerAttachOptions{
102+
aresp, err := apiClient.ContainerAttach(ctx, id, container.AttachOptions{
103103
Stream: true,
104104
Stdout: true,
105105
Stderr: true,

integration/plugin/logging/logging_linux_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"time"
1010

1111
"github.com/docker/docker/api/types"
12+
containertypes "github.com/docker/docker/api/types/container"
1213
"github.com/docker/docker/integration/internal/container"
1314
"github.com/docker/docker/testutil"
1415
"github.com/docker/docker/testutil/daemon"
@@ -49,7 +50,7 @@ func TestContinueAfterPluginCrash(t *testing.T) {
4950
defer client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{Force: true})
5051

5152
// Attach to the container to make sure it's written a few times to stdout
52-
attach, err := client.ContainerAttach(ctx, id, types.ContainerAttachOptions{Stream: true, Stdout: true})
53+
attach, err := client.ContainerAttach(ctx, id, containertypes.AttachOptions{Stream: true, Stdout: true})
5354
assert.NilError(t, err)
5455

5556
chErr := make(chan error, 1)

0 commit comments

Comments
 (0)