Browse code

Move ExecConfig to types.

Signed-off-by: David Calavera <david.calavera@gmail.com>

David Calavera authored on 2015/12/19 03:17:54
Showing 10 changed files
... ...
@@ -21,8 +21,8 @@ type apiClient interface {
21 21
 	ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)
22 22
 	ContainerCreate(config *runconfig.ContainerConfigWrapper, containerName string) (types.ContainerCreateResponse, error)
23 23
 	ContainerDiff(containerID string) ([]types.ContainerChange, error)
24
-	ContainerExecAttach(execID string, config runconfig.ExecConfig) (types.HijackedResponse, error)
25
-	ContainerExecCreate(config runconfig.ExecConfig) (types.ContainerExecCreateResponse, error)
24
+	ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error)
25
+	ContainerExecCreate(config types.ExecConfig) (types.ContainerExecCreateResponse, error)
26 26
 	ContainerExecInspect(execID string) (types.ContainerExecInspect, error)
27 27
 	ContainerExecResize(options types.ResizeOptions) error
28 28
 	ContainerExecStart(execID string, config types.ExecStartCheck) error
... ...
@@ -4,11 +4,10 @@ import (
4 4
 	"encoding/json"
5 5
 
6 6
 	"github.com/docker/docker/api/types"
7
-	"github.com/docker/docker/runconfig"
8 7
 )
9 8
 
10 9
 // ContainerExecCreate creates a new exec configuration to run an exec process.
11
-func (cli *Client) ContainerExecCreate(config runconfig.ExecConfig) (types.ContainerExecCreateResponse, error) {
10
+func (cli *Client) ContainerExecCreate(config types.ExecConfig) (types.ContainerExecCreateResponse, error) {
12 11
 	var response types.ContainerExecCreateResponse
13 12
 	resp, err := cli.post("/containers/"+config.Container+"/exec", nil, config, nil)
14 13
 	if err != nil {
... ...
@@ -30,7 +29,7 @@ func (cli *Client) ContainerExecStart(execID string, config types.ExecStartCheck
30 30
 // It returns a types.HijackedConnection with the hijacked connection
31 31
 // and the a reader to get output. It's up to the called to close
32 32
 // the hijacked connection by calling types.HijackedResponse.Close.
33
-func (cli *Client) ContainerExecAttach(execID string, config runconfig.ExecConfig) (types.HijackedResponse, error) {
33
+func (cli *Client) ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error) {
34 34
 	headers := map[string][]string{"Content-Type": {"application/json"}}
35 35
 	return cli.postHijacked("/exec/"+execID+"/start", nil, config, headers)
36 36
 }
... ...
@@ -14,7 +14,7 @@ import (
14 14
 
15 15
 // execBackend includes functions to implement to provide exec functionality.
16 16
 type execBackend interface {
17
-	ContainerExecCreate(config *runconfig.ExecConfig) (string, error)
17
+	ContainerExecCreate(config *types.ExecConfig) (string, error)
18 18
 	ContainerExecInspect(id string) (*exec.Config, error)
19 19
 	ContainerExecResize(name string, height, width int) error
20 20
 	ContainerExecStart(name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error
... ...
@@ -11,7 +11,6 @@ import (
11 11
 	"github.com/docker/docker/api/server/httputils"
12 12
 	"github.com/docker/docker/api/types"
13 13
 	"github.com/docker/docker/pkg/stdcopy"
14
-	"github.com/docker/docker/runconfig"
15 14
 	"golang.org/x/net/context"
16 15
 )
17 16
 
... ...
@@ -33,7 +32,7 @@ func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.Re
33 33
 	}
34 34
 	name := vars["name"]
35 35
 
36
-	execConfig := &runconfig.ExecConfig{}
36
+	execConfig := &types.ExecConfig{}
37 37
 	if err := json.NewDecoder(r.Body).Decode(execConfig); err != nil {
38 38
 		return err
39 39
 	}
... ...
@@ -35,3 +35,17 @@ type ContainerCommitConfig struct {
35 35
 	MergeConfigs bool
36 36
 	Config       *runconfig.Config
37 37
 }
38
+
39
+// ExecConfig is a small subset of the Config struct that hold the configuration
40
+// for the exec feature of docker.
41
+type ExecConfig struct {
42
+	User         string   // User that will run the command
43
+	Privileged   bool     // Is the container in privileged mode
44
+	Tty          bool     // Attach standard streams to a tty.
45
+	Container    string   // Name of the container (to execute in)
46
+	AttachStdin  bool     // Attach the standard input, makes possible user interaction
47
+	AttachStderr bool     // Attach the standard output
48
+	AttachStdout bool     // Attach the standard error
49
+	Detach       bool     // Execute in detach mode
50
+	Cmd          []string // Execution commands and args
51
+}
... ...
@@ -6,6 +6,7 @@ import (
6 6
 	"time"
7 7
 
8 8
 	"github.com/Sirupsen/logrus"
9
+	"github.com/docker/docker/api/types"
9 10
 	"github.com/docker/docker/api/types/strslice"
10 11
 	"github.com/docker/docker/container"
11 12
 	"github.com/docker/docker/daemon/exec"
... ...
@@ -13,7 +14,6 @@ import (
13 13
 	derr "github.com/docker/docker/errors"
14 14
 	"github.com/docker/docker/pkg/pools"
15 15
 	"github.com/docker/docker/pkg/promise"
16
-	"github.com/docker/docker/runconfig"
17 16
 )
18 17
 
19 18
 func (d *Daemon) registerExecCommand(container *container.Container, config *exec.Config) {
... ...
@@ -79,7 +79,7 @@ func (d *Daemon) getActiveContainer(name string) (*container.Container, error) {
79 79
 }
80 80
 
81 81
 // ContainerExecCreate sets up an exec in a running container.
82
-func (d *Daemon) ContainerExecCreate(config *runconfig.ExecConfig) (string, error) {
82
+func (d *Daemon) ContainerExecCreate(config *types.ExecConfig) (string, error) {
83 83
 	container, err := d.getActiveContainer(config.Container)
84 84
 	if err != nil {
85 85
 		return "", err
... ...
@@ -3,14 +3,14 @@
3 3
 package daemon
4 4
 
5 5
 import (
6
+	"github.com/docker/docker/api/types"
6 7
 	"github.com/docker/docker/container"
7 8
 	"github.com/docker/docker/daemon/execdriver"
8
-	"github.com/docker/docker/runconfig"
9 9
 )
10 10
 
11 11
 // setPlatformSpecificExecProcessConfig sets platform-specific fields in the
12 12
 // ProcessConfig structure.
13
-func setPlatformSpecificExecProcessConfig(config *runconfig.ExecConfig, container *container.Container, pc *execdriver.ProcessConfig) {
13
+func setPlatformSpecificExecProcessConfig(config *types.ExecConfig, container *container.Container, pc *execdriver.ProcessConfig) {
14 14
 	user := config.User
15 15
 	if len(user) == 0 {
16 16
 		user = container.Config.User
... ...
@@ -1,12 +1,12 @@
1 1
 package daemon
2 2
 
3 3
 import (
4
+	"github.com/docker/docker/api/types"
4 5
 	"github.com/docker/docker/container"
5 6
 	"github.com/docker/docker/daemon/execdriver"
6
-	"github.com/docker/docker/runconfig"
7 7
 )
8 8
 
9 9
 // setPlatformSpecificExecProcessConfig sets platform-specific fields in the
10 10
 // ProcessConfig structure. This is a no-op on Windows
11
-func setPlatformSpecificExecProcessConfig(config *runconfig.ExecConfig, container *container.Container, pc *execdriver.ProcessConfig) {
11
+func setPlatformSpecificExecProcessConfig(config *types.ExecConfig, container *container.Container, pc *execdriver.ProcessConfig) {
12 12
 }
... ...
@@ -1,28 +1,15 @@
1 1
 package runconfig
2 2
 
3 3
 import (
4
+	"github.com/docker/docker/api/types"
4 5
 	flag "github.com/docker/docker/pkg/mflag"
5 6
 )
6 7
 
7
-// ExecConfig is a small subset of the Config struct that hold the configuration
8
-// for the exec feature of docker.
9
-type ExecConfig struct {
10
-	User         string   // User that will run the command
11
-	Privileged   bool     // Is the container in privileged mode
12
-	Tty          bool     // Attach standard streams to a tty.
13
-	Container    string   // Name of the container (to execute in)
14
-	AttachStdin  bool     // Attach the standard input, makes possible user interaction
15
-	AttachStderr bool     // Attach the standard output
16
-	AttachStdout bool     // Attach the standard error
17
-	Detach       bool     // Execute in detach mode
18
-	Cmd          []string // Execution commands and args
19
-}
20
-
21 8
 // ParseExec parses the specified args for the specified command and generates
22 9
 // an ExecConfig from it.
23 10
 // If the minimal number of specified args is not right or if specified args are
24 11
 // not valid, it will return an error.
25
-func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error) {
12
+func ParseExec(cmd *flag.FlagSet, args []string) (*types.ExecConfig, error) {
26 13
 	var (
27 14
 		flStdin      = cmd.Bool([]string{"i", "-interactive"}, false, "Keep STDIN open even if not attached")
28 15
 		flTty        = cmd.Bool([]string{"t", "-tty"}, false, "Allocate a pseudo-TTY")
... ...
@@ -40,7 +27,7 @@ func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error) {
40 40
 	parsedArgs := cmd.Args()
41 41
 	execCmd = parsedArgs[1:]
42 42
 
43
-	execConfig := &ExecConfig{
43
+	execConfig := &types.ExecConfig{
44 44
 		User:       *flUser,
45 45
 		Privileged: *flPrivileged,
46 46
 		Tty:        *flTty,
... ...
@@ -5,6 +5,7 @@ import (
5 5
 	"io/ioutil"
6 6
 	"testing"
7 7
 
8
+	"github.com/docker/docker/api/types"
8 9
 	flag "github.com/docker/docker/pkg/mflag"
9 10
 )
10 11
 
... ...
@@ -18,7 +19,7 @@ func TestParseExec(t *testing.T) {
18 18
 		&arguments{[]string{"-u"}}:       fmt.Errorf("flag needs an argument: -u"),
19 19
 		&arguments{[]string{"--user"}}:   fmt.Errorf("flag needs an argument: --user"),
20 20
 	}
21
-	valids := map[*arguments]*ExecConfig{
21
+	valids := map[*arguments]*types.ExecConfig{
22 22
 		&arguments{
23 23
 			[]string{"container", "command"},
24 24
 		}: {
... ...
@@ -92,7 +93,7 @@ func TestParseExec(t *testing.T) {
92 92
 	}
93 93
 }
94 94
 
95
-func compareExecConfig(config1 *ExecConfig, config2 *ExecConfig) bool {
95
+func compareExecConfig(config1 *types.ExecConfig, config2 *types.ExecConfig) bool {
96 96
 	if config1.AttachStderr != config2.AttachStderr {
97 97
 		return false
98 98
 	}