Move ExecConfig to types.

Signed-off-by: David Calavera <david.calavera@gmail.com>
Upstream-commit: 839f73c3028629ac1dde6617d6466b98f2bde416
Component: engine
This commit is contained in:
David Calavera
2015-12-22 13:31:46 -05:00
parent b006691148
commit f1f019f89d
10 changed files with 32 additions and 32 deletions
+3 -16
View File
@@ -1,28 +1,15 @@
package runconfig
import (
"github.com/docker/docker/api/types"
flag "github.com/docker/docker/pkg/mflag"
)
// ExecConfig is a small subset of the Config struct that hold the configuration
// for the exec feature of docker.
type ExecConfig struct {
User string // User that will run the command
Privileged bool // Is the container in privileged mode
Tty bool // Attach standard streams to a tty.
Container string // Name of the container (to execute in)
AttachStdin bool // Attach the standard input, makes possible user interaction
AttachStderr bool // Attach the standard output
AttachStdout bool // Attach the standard error
Detach bool // Execute in detach mode
Cmd []string // Execution commands and args
}
// ParseExec parses the specified args for the specified command and generates
// an ExecConfig from it.
// If the minimal number of specified args is not right or if specified args are
// not valid, it will return an error.
func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error) {
func ParseExec(cmd *flag.FlagSet, args []string) (*types.ExecConfig, error) {
var (
flStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Keep STDIN open even if not attached")
flTty = cmd.Bool([]string{"t", "-tty"}, false, "Allocate a pseudo-TTY")
@@ -40,7 +27,7 @@ func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error) {
parsedArgs := cmd.Args()
execCmd = parsedArgs[1:]
execConfig := &ExecConfig{
execConfig := &types.ExecConfig{
User: *flUser,
Privileged: *flPrivileged,
Tty: *flTty,
+3 -2
View File
@@ -5,6 +5,7 @@ import (
"io/ioutil"
"testing"
"github.com/docker/docker/api/types"
flag "github.com/docker/docker/pkg/mflag"
)
@@ -18,7 +19,7 @@ func TestParseExec(t *testing.T) {
&arguments{[]string{"-u"}}: fmt.Errorf("flag needs an argument: -u"),
&arguments{[]string{"--user"}}: fmt.Errorf("flag needs an argument: --user"),
}
valids := map[*arguments]*ExecConfig{
valids := map[*arguments]*types.ExecConfig{
&arguments{
[]string{"container", "command"},
}: {
@@ -92,7 +93,7 @@ func TestParseExec(t *testing.T) {
}
}
func compareExecConfig(config1 *ExecConfig, config2 *ExecConfig) bool {
func compareExecConfig(config1 *types.ExecConfig, config2 *types.ExecConfig) bool {
if config1.AttachStderr != config2.AttachStderr {
return false
}