Skip to content

Commit 839f73c

Browse files
committed
Move ExecConfig to types.
Signed-off-by: David Calavera <david.calavera@gmail.com>
1 parent 056e744 commit 839f73c

File tree

10 files changed

+32
-32
lines changed

10 files changed

+32
-32
lines changed

api/client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ type apiClient interface {
2121
ContainerCommit(options types.ContainerCommitOptions) (types.ContainerCommitResponse, error)
2222
ContainerCreate(config *runconfig.ContainerConfigWrapper, containerName string) (types.ContainerCreateResponse, error)
2323
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)
2626
ContainerExecInspect(execID string) (types.ContainerExecInspect, error)
2727
ContainerExecResize(options types.ResizeOptions) error
2828
ContainerExecStart(execID string, config types.ExecStartCheck) error

api/client/lib/exec.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ import (
44
"encoding/json"
55

66
"github.com/docker/docker/api/types"
7-
"github.com/docker/docker/runconfig"
87
)
98

109
// 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) {
1211
var response types.ContainerExecCreateResponse
1312
resp, err := cli.post("/containers/"+config.Container+"/exec", nil, config, nil)
1413
if err != nil {
@@ -30,7 +29,7 @@ func (cli *Client) ContainerExecStart(execID string, config types.ExecStartCheck
3029
// It returns a types.HijackedConnection with the hijacked connection
3130
// and the a reader to get output. It's up to the called to close
3231
// the hijacked connection by calling types.HijackedResponse.Close.
33-
func (cli *Client) ContainerExecAttach(execID string, config runconfig.ExecConfig) (types.HijackedResponse, error) {
32+
func (cli *Client) ContainerExecAttach(execID string, config types.ExecConfig) (types.HijackedResponse, error) {
3433
headers := map[string][]string{"Content-Type": {"application/json"}}
3534
return cli.postHijacked("/exec/"+execID+"/start", nil, config, headers)
3635
}

api/server/router/container/backend.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import (
1414

1515
// execBackend includes functions to implement to provide exec functionality.
1616
type execBackend interface {
17-
ContainerExecCreate(config *runconfig.ExecConfig) (string, error)
17+
ContainerExecCreate(config *types.ExecConfig) (string, error)
1818
ContainerExecInspect(id string) (*exec.Config, error)
1919
ContainerExecResize(name string, height, width int) error
2020
ContainerExecStart(name string, stdin io.ReadCloser, stdout io.Writer, stderr io.Writer) error

api/server/router/container/exec.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import (
1111
"github.com/docker/docker/api/server/httputils"
1212
"github.com/docker/docker/api/types"
1313
"github.com/docker/docker/pkg/stdcopy"
14-
"github.com/docker/docker/runconfig"
1514
"golang.org/x/net/context"
1615
)
1716

@@ -33,7 +32,7 @@ func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.Re
3332
}
3433
name := vars["name"]
3534

36-
execConfig := &runconfig.ExecConfig{}
35+
execConfig := &types.ExecConfig{}
3736
if err := json.NewDecoder(r.Body).Decode(execConfig); err != nil {
3837
return err
3938
}

api/types/configs.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,17 @@ type ContainerCommitConfig struct {
3535
MergeConfigs bool
3636
Config *runconfig.Config
3737
}
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+
}

daemon/exec.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ import (
66
"time"
77

88
"github.com/Sirupsen/logrus"
9+
"github.com/docker/docker/api/types"
910
"github.com/docker/docker/api/types/strslice"
1011
"github.com/docker/docker/container"
1112
"github.com/docker/docker/daemon/exec"
1213
"github.com/docker/docker/daemon/execdriver"
1314
derr "github.com/docker/docker/errors"
1415
"github.com/docker/docker/pkg/pools"
1516
"github.com/docker/docker/pkg/promise"
16-
"github.com/docker/docker/runconfig"
1717
)
1818

1919
func (d *Daemon) registerExecCommand(container *container.Container, config *exec.Config) {
@@ -79,7 +79,7 @@ func (d *Daemon) getActiveContainer(name string) (*container.Container, error) {
7979
}
8080

8181
// 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) {
8383
container, err := d.getActiveContainer(config.Container)
8484
if err != nil {
8585
return "", err

daemon/exec_unix.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
package daemon
44

55
import (
6+
"github.com/docker/docker/api/types"
67
"github.com/docker/docker/container"
78
"github.com/docker/docker/daemon/execdriver"
8-
"github.com/docker/docker/runconfig"
99
)
1010

1111
// setPlatformSpecificExecProcessConfig sets platform-specific fields in the
1212
// 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) {
1414
user := config.User
1515
if len(user) == 0 {
1616
user = container.Config.User

daemon/exec_windows.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
package daemon
22

33
import (
4+
"github.com/docker/docker/api/types"
45
"github.com/docker/docker/container"
56
"github.com/docker/docker/daemon/execdriver"
6-
"github.com/docker/docker/runconfig"
77
)
88

99
// setPlatformSpecificExecProcessConfig sets platform-specific fields in the
1010
// 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) {
1212
}

runconfig/exec.go

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,15 @@
11
package runconfig
22

33
import (
4+
"github.com/docker/docker/api/types"
45
flag "github.com/docker/docker/pkg/mflag"
56
)
67

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-
218
// ParseExec parses the specified args for the specified command and generates
229
// an ExecConfig from it.
2310
// If the minimal number of specified args is not right or if specified args are
2411
// 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) {
2613
var (
2714
flStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Keep STDIN open even if not attached")
2815
flTty = cmd.Bool([]string{"t", "-tty"}, false, "Allocate a pseudo-TTY")
@@ -40,7 +27,7 @@ func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error) {
4027
parsedArgs := cmd.Args()
4128
execCmd = parsedArgs[1:]
4229

43-
execConfig := &ExecConfig{
30+
execConfig := &types.ExecConfig{
4431
User: *flUser,
4532
Privileged: *flPrivileged,
4633
Tty: *flTty,

runconfig/exec_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import (
55
"io/ioutil"
66
"testing"
77

8+
"github.com/docker/docker/api/types"
89
flag "github.com/docker/docker/pkg/mflag"
910
)
1011

@@ -18,7 +19,7 @@ func TestParseExec(t *testing.T) {
1819
&arguments{[]string{"-u"}}: fmt.Errorf("flag needs an argument: -u"),
1920
&arguments{[]string{"--user"}}: fmt.Errorf("flag needs an argument: --user"),
2021
}
21-
valids := map[*arguments]*ExecConfig{
22+
valids := map[*arguments]*types.ExecConfig{
2223
&arguments{
2324
[]string{"container", "command"},
2425
}: {
@@ -92,7 +93,7 @@ func TestParseExec(t *testing.T) {
9293
}
9394
}
9495

95-
func compareExecConfig(config1 *ExecConfig, config2 *ExecConfig) bool {
96+
func compareExecConfig(config1 *types.ExecConfig, config2 *types.ExecConfig) bool {
9697
if config1.AttachStderr != config2.AttachStderr {
9798
return false
9899
}

0 commit comments

Comments
 (0)