Quellcode durchsuchen

api/types: move ContainerAttachOptions to api/types/container

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Sebastiaan van Stijn vor 1 Jahr
Ursprung
Commit
30f09b4a1a

+ 0 - 10
api/types/client.go

@@ -11,16 +11,6 @@ import (
 	units "github.com/docker/go-units"
 )
 
-// ContainerAttachOptions holds parameters to attach to a container.
-type ContainerAttachOptions struct {
-	Stream     bool
-	Stdin      bool
-	Stdout     bool
-	Stderr     bool
-	DetachKeys string
-	Logs       bool
-}
-
 // ContainerCommitOptions holds parameters to commit changes into a container.
 type ContainerCommitOptions struct {
 	Reference string

+ 10 - 0
api/types/container/options.go

@@ -7,3 +7,13 @@ type ResizeOptions struct {
 	Height uint
 	Width  uint
 }
+
+// AttachOptions holds parameters to attach to a container.
+type AttachOptions struct {
+	Stream     bool
+	Stdin      bool
+	Stdout     bool
+	Stderr     bool
+	DetachKeys string
+	Logs       bool
+}

+ 5 - 0
api/types/types_deprecated.go

@@ -99,6 +99,11 @@ type ServiceUpdateResponse = swarm.ServiceUpdateResponse
 // Deprecated: use [container.ResizeOptions].
 type ResizeOptions = container.ResizeOptions
 
+// ContainerAttachOptions holds parameters to attach to a container.
+//
+// Deprecated: use [container.AttachOptions].
+type ContainerAttachOptions = container.AttachOptions
+
 // DecodeSecurityOptions decodes a security options string slice to a type safe
 // [system.SecurityOpt].
 //

+ 2 - 1
client/container_attach.go

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

+ 1 - 1
client/interface.go

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

+ 2 - 1
integration-cli/docker_api_attach_test.go

@@ -11,6 +11,7 @@ import (
 	"time"
 
 	"github.com/docker/docker/api/types"
+	"github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/client"
 	"github.com/docker/docker/pkg/stdcopy"
 	"github.com/docker/docker/testutil"
@@ -184,7 +185,7 @@ func (s *DockerAPISuite) TestPostContainersAttach(c *testing.T) {
 	cid = strings.TrimSpace(cid)
 
 	// Make sure we don't see "hello" if Logs is false
-	attachOpts := types.ContainerAttachOptions{
+	attachOpts := container.AttachOptions{
 		Stream: true,
 		Stdin:  true,
 		Stdout: true,

+ 3 - 3
integration/container/attach_test.go

@@ -13,7 +13,7 @@ import (
 
 func TestAttach(t *testing.T) {
 	ctx := setupTest(t)
-	client := testEnv.APIClient()
+	apiClient := testEnv.APIClient()
 
 	tests := []struct {
 		doc               string
@@ -36,7 +36,7 @@ func TestAttach(t *testing.T) {
 			t.Parallel()
 
 			ctx := testutil.StartSpan(ctx, t)
-			resp, err := client.ContainerCreate(ctx,
+			resp, err := apiClient.ContainerCreate(ctx,
 				&container.Config{
 					Image: "busybox",
 					Cmd:   []string{"echo", "hello"},
@@ -48,7 +48,7 @@ func TestAttach(t *testing.T) {
 				"",
 			)
 			assert.NilError(t, err)
-			attach, err := client.ContainerAttach(ctx, resp.ID, types.ContainerAttachOptions{
+			attach, err := apiClient.ContainerAttach(ctx, resp.ID, container.AttachOptions{
 				Stdout: true,
 				Stderr: true,
 			})

+ 1 - 1
integration/container/wait_test.go

@@ -145,7 +145,7 @@ func TestWaitConditions(t *testing.T) {
 			containerID := container.Create(ctx, t, cli, opts...)
 			t.Logf("ContainerID = %v", containerID)
 
-			streams, err := cli.ContainerAttach(ctx, containerID, types.ContainerAttachOptions{Stream: true, Stdin: true})
+			streams, err := cli.ContainerAttach(ctx, containerID, containertypes.AttachOptions{Stream: true, Stdin: true})
 			assert.NilError(t, err)
 			defer streams.Close()
 

+ 1 - 1
integration/internal/container/container.go

@@ -99,7 +99,7 @@ func RunAttach(ctx context.Context, t *testing.T, apiClient client.APIClient, op
 	})
 	id := Create(ctx, t, apiClient, ops...)
 
-	aresp, err := apiClient.ContainerAttach(ctx, id, types.ContainerAttachOptions{
+	aresp, err := apiClient.ContainerAttach(ctx, id, container.AttachOptions{
 		Stream: true,
 		Stdout: true,
 		Stderr: true,

+ 2 - 1
integration/plugin/logging/logging_linux_test.go

@@ -9,6 +9,7 @@ import (
 	"time"
 
 	"github.com/docker/docker/api/types"
+	containertypes "github.com/docker/docker/api/types/container"
 	"github.com/docker/docker/integration/internal/container"
 	"github.com/docker/docker/testutil"
 	"github.com/docker/docker/testutil/daemon"
@@ -49,7 +50,7 @@ func TestContinueAfterPluginCrash(t *testing.T) {
 	defer client.ContainerRemove(ctx, id, types.ContainerRemoveOptions{Force: true})
 
 	// Attach to the container to make sure it's written a few times to stdout
-	attach, err := client.ContainerAttach(ctx, id, types.ContainerAttachOptions{Stream: true, Stdout: true})
+	attach, err := client.ContainerAttach(ctx, id, containertypes.AttachOptions{Stream: true, Stdout: true})
 	assert.NilError(t, err)
 
 	chErr := make(chan error, 1)