Browse code

api/types: move ExecStartOptions to api/types/backend

It's a type used by the backend, so moving it there.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Sebastiaan van Stijn authored on 2024/06/09 02:40:13
Showing 6 changed files
... ...
@@ -17,7 +17,7 @@ type execBackend interface {
17 17
 	ContainerExecCreate(name string, options *container.ExecOptions) (string, error)
18 18
 	ContainerExecInspect(id string) (*backend.ExecInspect, error)
19 19
 	ContainerExecResize(name string, height, width int) error
20
-	ContainerExecStart(ctx context.Context, name string, options container.ExecStartOptions) error
20
+	ContainerExecStart(ctx context.Context, name string, options backend.ExecStartConfig) error
21 21
 	ExecExists(name string) (bool, error)
22 22
 }
23 23
 
... ...
@@ -10,6 +10,7 @@ import (
10 10
 	"github.com/containerd/log"
11 11
 	"github.com/docker/docker/api/server/httputils"
12 12
 	"github.com/docker/docker/api/types"
13
+	"github.com/docker/docker/api/types/backend"
13 14
 	"github.com/docker/docker/api/types/container"
14 15
 	"github.com/docker/docker/api/types/versions"
15 16
 	"github.com/docker/docker/errdefs"
... ...
@@ -137,7 +138,7 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res
137 137
 	// Now run the user process in container.
138 138
 	//
139 139
 	// TODO: Maybe we should we pass ctx here if we're not detaching?
140
-	err := s.backend.ContainerExecStart(context.Background(), execName, container.ExecStartOptions{
140
+	err := s.backend.ContainerExecStart(context.Background(), execName, backend.ExecStartConfig{
141 141
 		Stdin:       stdin,
142 142
 		Stdout:      stdout,
143 143
 		Stderr:      stderr,
... ...
@@ -92,6 +92,14 @@ type ContainerStatsConfig struct {
92 92
 	OutStream func() io.Writer
93 93
 }
94 94
 
95
+// ExecStartConfig holds the options to start container's exec.
96
+type ExecStartConfig struct {
97
+	Stdin       io.Reader
98
+	Stdout      io.Writer
99
+	Stderr      io.Writer
100
+	ConsoleSize *[2]uint `json:",omitempty"`
101
+}
102
+
95 103
 // ExecInspect holds information about a running process started
96 104
 // with docker exec.
97 105
 type ExecInspect struct {
... ...
@@ -1,7 +1,6 @@
1 1
 package container // import "github.com/docker/docker/api/types/container"
2 2
 
3 3
 import (
4
-	"io"
5 4
 	"time"
6 5
 
7 6
 	"github.com/docker/docker/api/types/strslice"
... ...
@@ -36,14 +35,6 @@ type StopOptions struct {
36 36
 // HealthConfig holds configuration settings for the HEALTHCHECK feature.
37 37
 type HealthConfig = dockerspec.HealthcheckConfig
38 38
 
39
-// ExecStartOptions holds the options to start container's exec.
40
-type ExecStartOptions struct {
41
-	Stdin       io.Reader
42
-	Stdout      io.Writer
43
-	Stderr      io.Writer
44
-	ConsoleSize *[2]uint `json:",omitempty"`
45
-}
46
-
47 39
 // Config contains the configuration data about a container.
48 40
 // It should hold only portable information about the container.
49 41
 // Here, "portable" means "independent from the host we are running on".
... ...
@@ -11,6 +11,7 @@ import (
11 11
 
12 12
 	"github.com/containerd/containerd"
13 13
 	"github.com/containerd/log"
14
+	"github.com/docker/docker/api/types/backend"
14 15
 	containertypes "github.com/docker/docker/api/types/container"
15 16
 	"github.com/docker/docker/api/types/events"
16 17
 	"github.com/docker/docker/api/types/strslice"
... ...
@@ -147,7 +148,7 @@ func (daemon *Daemon) ContainerExecCreate(name string, options *containertypes.E
147 147
 // ContainerExecStart starts a previously set up exec instance. The
148 148
 // std streams are set up.
149 149
 // If ctx is cancelled, the process is terminated.
150
-func (daemon *Daemon) ContainerExecStart(ctx context.Context, name string, options containertypes.ExecStartOptions) (err error) {
150
+func (daemon *Daemon) ContainerExecStart(ctx context.Context, name string, options backend.ExecStartConfig) (err error) {
151 151
 	var (
152 152
 		cStdin           io.ReadCloser
153 153
 		cStdout, cStderr io.Writer
... ...
@@ -11,7 +11,7 @@ import (
11 11
 
12 12
 	"github.com/containerd/log"
13 13
 	"github.com/docker/docker/api/types"
14
-	containertypes "github.com/docker/docker/api/types/container"
14
+	"github.com/docker/docker/api/types/backend"
15 15
 	"github.com/docker/docker/api/types/events"
16 16
 	"github.com/docker/docker/api/types/strslice"
17 17
 	"github.com/docker/docker/container"
... ...
@@ -97,7 +97,7 @@ func (p *cmdProbe) run(ctx context.Context, d *Daemon, cntr *container.Container
97 97
 	defer cancelProbe()
98 98
 	execErr := make(chan error, 1)
99 99
 
100
-	options := containertypes.ExecStartOptions{
100
+	options := backend.ExecStartConfig{
101 101
 		Stdout: output,
102 102
 		Stderr: output,
103 103
 	}