Remove unused sysinfo parameter to runconfig.Parse

Removing dead code.

Signed-off-by: John Gossman <johngos@microsoft.com>
This commit is contained in:
John Gossman 2014-10-30 09:35:49 -07:00 коммит произвёл Ahmet Alp Balkan
Родитель 2180aa4f6f
Коммит e45b0f9271
8 изменённых файлов: 28 добавлений и 41 удалений

Просмотреть файл

@ -2183,7 +2183,7 @@ func (cli *DockerCli) CmdCreate(args ...string) error {
flName = cmd.String([]string{"-name"}, "", "Assign a name to the container")
)
config, hostConfig, cmd, err := runconfig.Parse(cmd, args, nil)
config, hostConfig, cmd, err := runconfig.Parse(cmd, args)
if err != nil {
return err
}
@ -2219,7 +2219,7 @@ func (cli *DockerCli) CmdRun(args ...string) error {
ErrConflictDetachAutoRemove = fmt.Errorf("Conflicting options: --rm and -d")
)
config, hostConfig, cmd, err := runconfig.Parse(cmd, args, nil)
config, hostConfig, cmd, err := runconfig.Parse(cmd, args)
if err != nil {
return err
}

Просмотреть файл

@ -183,7 +183,7 @@ func run(b *Builder, args []string, attributes map[string]bool, original string)
runCmd.SetOutput(ioutil.Discard)
runCmd.Usage = nil
config, _, _, err := runconfig.Parse(runCmd, append([]string{b.image}, args...), nil)
config, _, _, err := runconfig.Parse(runCmd, append([]string{b.image}, args...))
if err != nil {
return err
}

Просмотреть файл

@ -661,7 +661,7 @@ func TestDefaultContainerName(t *testing.T) {
daemon := mkDaemonFromEngine(eng, t)
defer nuke(daemon)
config, _, _, err := parseRun([]string{unitTestImageID, "echo test"}, nil)
config, _, _, err := parseRun([]string{unitTestImageID, "echo test"})
if err != nil {
t.Fatal(err)
}
@ -685,7 +685,7 @@ func TestRandomContainerName(t *testing.T) {
daemon := mkDaemonFromEngine(eng, t)
defer nuke(daemon)
config, _, _, err := parseRun([]string{GetTestImage(daemon).ID, "echo test"}, nil)
config, _, _, err := parseRun([]string{GetTestImage(daemon).ID, "echo test"})
if err != nil {
t.Fatal(err)
}
@ -716,7 +716,7 @@ func TestContainerNameValidation(t *testing.T) {
{"abc-123_AAA.1", true},
{"\000asdf", false},
} {
config, _, _, err := parseRun([]string{unitTestImageID, "echo test"}, nil)
config, _, _, err := parseRun([]string{unitTestImageID, "echo test"})
if err != nil {
if !test.Valid {
continue
@ -757,7 +757,7 @@ func TestLinkChildContainer(t *testing.T) {
daemon := mkDaemonFromEngine(eng, t)
defer nuke(daemon)
config, _, _, err := parseRun([]string{unitTestImageID, "echo test"}, nil)
config, _, _, err := parseRun([]string{unitTestImageID, "echo test"})
if err != nil {
t.Fatal(err)
}
@ -773,7 +773,7 @@ func TestLinkChildContainer(t *testing.T) {
t.Fatalf("Expect webapp id to match container id: %s != %s", webapp.ID, container.ID)
}
config, _, _, err = parseRun([]string{GetTestImage(daemon).ID, "echo test"}, nil)
config, _, _, err = parseRun([]string{GetTestImage(daemon).ID, "echo test"})
if err != nil {
t.Fatal(err)
}
@ -799,7 +799,7 @@ func TestGetAllChildren(t *testing.T) {
daemon := mkDaemonFromEngine(eng, t)
defer nuke(daemon)
config, _, _, err := parseRun([]string{unitTestImageID, "echo test"}, nil)
config, _, _, err := parseRun([]string{unitTestImageID, "echo test"})
if err != nil {
t.Fatal(err)
}
@ -815,7 +815,7 @@ func TestGetAllChildren(t *testing.T) {
t.Fatalf("Expect webapp id to match container id: %s != %s", webapp.ID, container.ID)
}
config, _, _, err = parseRun([]string{unitTestImageID, "echo test"}, nil)
config, _, _, err = parseRun([]string{unitTestImageID, "echo test"})
if err != nil {
t.Fatal(err)
}

Просмотреть файл

@ -12,7 +12,7 @@ func TestCreateNumberHostname(t *testing.T) {
eng := NewTestEngine(t)
defer mkDaemonFromEngine(eng, t).Nuke()
config, _, _, err := parseRun([]string{"-h", "web.0", unitTestImageID, "echo test"}, nil)
config, _, _, err := parseRun([]string{"-h", "web.0", unitTestImageID, "echo test"})
if err != nil {
t.Fatal(err)
}
@ -24,7 +24,7 @@ func TestCommit(t *testing.T) {
eng := NewTestEngine(t)
defer mkDaemonFromEngine(eng, t).Nuke()
config, _, _, err := parseRun([]string{unitTestImageID, "/bin/cat"}, nil)
config, _, _, err := parseRun([]string{unitTestImageID, "/bin/cat"})
if err != nil {
t.Fatal(err)
}
@ -48,7 +48,7 @@ func TestMergeConfigOnCommit(t *testing.T) {
container1, _, _ := mkContainer(runtime, []string{"-e", "FOO=bar", unitTestImageID, "echo test > /tmp/foo"}, t)
defer runtime.Destroy(container1)
config, _, _, err := parseRun([]string{container1.ID, "cat /tmp/foo"}, nil)
config, _, _, err := parseRun([]string{container1.ID, "cat /tmp/foo"})
if err != nil {
t.Error(err)
}
@ -102,7 +102,7 @@ func TestRestartKillWait(t *testing.T) {
runtime := mkDaemonFromEngine(eng, t)
defer runtime.Nuke()
config, hostConfig, _, err := parseRun([]string{"-i", unitTestImageID, "/bin/cat"}, nil)
config, hostConfig, _, err := parseRun([]string{"-i", unitTestImageID, "/bin/cat"})
if err != nil {
t.Fatal(err)
}
@ -163,7 +163,7 @@ func TestCreateStartRestartStopStartKillRm(t *testing.T) {
eng := NewTestEngine(t)
defer mkDaemonFromEngine(eng, t).Nuke()
config, hostConfig, _, err := parseRun([]string{"-i", unitTestImageID, "/bin/cat"}, nil)
config, hostConfig, _, err := parseRun([]string{"-i", unitTestImageID, "/bin/cat"})
if err != nil {
t.Fatal(err)
}

Просмотреть файл

@ -19,7 +19,6 @@ import (
"github.com/docker/docker/daemon"
"github.com/docker/docker/engine"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/sysinfo"
"github.com/docker/docker/runconfig"
"github.com/docker/docker/utils"
)
@ -250,7 +249,7 @@ func readFile(src string, t *testing.T) (content string) {
// The caller is responsible for destroying the container.
// Call t.Fatal() at the first error.
func mkContainer(r *daemon.Daemon, args []string, t *testing.T) (*daemon.Container, *runconfig.HostConfig, error) {
config, hc, _, err := parseRun(args, nil)
config, hc, _, err := parseRun(args)
defer func() {
if err != nil && t != nil {
t.Fatal(err)
@ -351,9 +350,9 @@ func getImages(eng *engine.Engine, t *testing.T, all bool, filter string) *engin
}
func parseRun(args []string, sysInfo *sysinfo.SysInfo) (*runconfig.Config, *runconfig.HostConfig, *flag.FlagSet, error) {
func parseRun(args []string) (*runconfig.Config, *runconfig.HostConfig, *flag.FlagSet, error) {
cmd := flag.NewFlagSet("run", flag.ContinueOnError)
cmd.SetOutput(ioutil.Discard)
cmd.Usage = nil
return runconfig.Parse(cmd, args, sysInfo)
return runconfig.Parse(cmd, args)
}

Просмотреть файл

@ -9,7 +9,7 @@ import (
)
func parse(t *testing.T, args string) (*Config, *HostConfig, error) {
config, hostConfig, _, err := parseRun(strings.Split(args+" ubuntu bash", " "), nil)
config, hostConfig, _, err := parseRun(strings.Split(args+" ubuntu bash", " "))
return config, hostConfig, err
}

Просмотреть файл

@ -10,7 +10,6 @@ import (
"github.com/docker/docker/opts"
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/sysinfo"
"github.com/docker/docker/pkg/units"
"github.com/docker/docker/utils"
)
@ -24,7 +23,7 @@ var (
ErrConflictHostNetworkAndLinks = fmt.Errorf("Conflicting options: --net=host can't be used with links. This would result in undefined behavior.")
)
func Parse(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Config, *HostConfig, *flag.FlagSet, error) {
func Parse(cmd *flag.FlagSet, args []string) (*Config, *HostConfig, *flag.FlagSet, error) {
var (
// FIXME: use utils.ListOpts for attach and volumes?
flAttach = opts.NewListOpts(opts.ValidateAttach)
@ -88,11 +87,6 @@ func Parse(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Config,
return nil, nil, cmd, err
}
// Check if the kernel supports memory limit cgroup.
if sysInfo != nil && *flMemoryString != "" && !sysInfo.MemoryLimit {
*flMemoryString = ""
}
// Validate input params
if *flWorkingDir != "" && !path.IsAbs(*flWorkingDir) {
return nil, nil, cmd, ErrInvalidWorkingDirectory
@ -302,11 +296,6 @@ func Parse(cmd *flag.FlagSet, args []string, sysInfo *sysinfo.SysInfo) (*Config,
RestartPolicy: restartPolicy,
}
if sysInfo != nil && flMemory > 0 && !sysInfo.SwapLimit {
//fmt.Fprintf(stdout, "WARNING: Your kernel does not support swap limit capabilities. Limitation discarded.\n")
config.MemorySwap = -1
}
// When allocating stdin in attached mode, close stdin at client disconnect
if config.OpenStdin && config.AttachStdin {
config.StdinOnce = true

Просмотреть файл

@ -6,14 +6,13 @@ import (
flag "github.com/docker/docker/pkg/mflag"
"github.com/docker/docker/pkg/parsers"
"github.com/docker/docker/pkg/sysinfo"
)
func parseRun(args []string, sysInfo *sysinfo.SysInfo) (*Config, *HostConfig, *flag.FlagSet, error) {
func parseRun(args []string) (*Config, *HostConfig, *flag.FlagSet, error) {
cmd := flag.NewFlagSet("run", flag.ContinueOnError)
cmd.SetOutput(ioutil.Discard)
cmd.Usage = nil
return Parse(cmd, args, sysInfo)
return Parse(cmd, args)
}
func TestParseLxcConfOpt(t *testing.T) {
@ -34,27 +33,27 @@ func TestParseLxcConfOpt(t *testing.T) {
}
func TestNetHostname(t *testing.T) {
if _, _, _, err := parseRun([]string{"-h=name", "img", "cmd"}, nil); err != nil {
if _, _, _, err := parseRun([]string{"-h=name", "img", "cmd"}); err != nil {
t.Fatalf("Unexpected error: %s", err)
}
if _, _, _, err := parseRun([]string{"--net=host", "img", "cmd"}, nil); err != nil {
if _, _, _, err := parseRun([]string{"--net=host", "img", "cmd"}); err != nil {
t.Fatalf("Unexpected error: %s", err)
}
if _, _, _, err := parseRun([]string{"-h=name", "--net=bridge", "img", "cmd"}, nil); err != nil {
if _, _, _, err := parseRun([]string{"-h=name", "--net=bridge", "img", "cmd"}); err != nil {
t.Fatalf("Unexpected error: %s", err)
}
if _, _, _, err := parseRun([]string{"-h=name", "--net=none", "img", "cmd"}, nil); err != nil {
if _, _, _, err := parseRun([]string{"-h=name", "--net=none", "img", "cmd"}); err != nil {
t.Fatalf("Unexpected error: %s", err)
}
if _, _, _, err := parseRun([]string{"-h=name", "--net=host", "img", "cmd"}, nil); err != ErrConflictNetworkHostname {
if _, _, _, err := parseRun([]string{"-h=name", "--net=host", "img", "cmd"}); err != ErrConflictNetworkHostname {
t.Fatalf("Expected error ErrConflictNetworkHostname, got: %s", err)
}
if _, _, _, err := parseRun([]string{"-h=name", "--net=container:other", "img", "cmd"}, nil); err != ErrConflictNetworkHostname {
if _, _, _, err := parseRun([]string{"-h=name", "--net=container:other", "img", "cmd"}); err != ErrConflictNetworkHostname {
t.Fatalf("Expected error ErrConflictNetworkHostname, got: %s", err)
}
}