From 8600e6f3158bafe927706f0613c1520971d16c32 Mon Sep 17 00:00:00 2001 From: Alexander Morozov Date: Wed, 25 Feb 2015 09:11:39 -0800 Subject: [PATCH] Add default InitArgs for factory Signed-off-by: Alexander Morozov --- README.md | 4 +--- factory_linux.go | 1 + integration/exec_test.go | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e06370245..c5d2000a9 100644 --- a/README.md +++ b/README.md @@ -21,9 +21,7 @@ To use the current binary that is spawning the containers and acting as the pare you can use `os.Args[0]` and we have a command called `init` setup. ```go -initArgs := []string{os.Args[0], "init"} - -root, err := libcontainer.New("/var/lib/container", initArgs) +root, err := libcontainer.New("/var/lib/container", libcontainer.InitArgs(os.Args[0], "init")) if err != nil { log.Fatal(err) } diff --git a/factory_linux.go b/factory_linux.go index 12e072ae8..468398c01 100644 --- a/factory_linux.go +++ b/factory_linux.go @@ -90,6 +90,7 @@ func New(root string, options ...func(*LinuxFactory) error) (Factory, error) { Root: root, Validator: validate.New(), } + InitArgs(os.Args[0], "init")(l) Cgroupfs(l) for _, opt := range options { if err := opt(l); err != nil { diff --git a/integration/exec_test.go b/integration/exec_test.go index 3d425e4b4..cc3740d62 100644 --- a/integration/exec_test.go +++ b/integration/exec_test.go @@ -232,7 +232,7 @@ func TestEnter(t *testing.T) { config := newTemplateConfig(rootfs) - factory, err := libcontainer.New(root, libcontainer.InitArgs(os.Args[0], "init", "--"), libcontainer.Cgroupfs) + factory, err := libcontainer.New(root, libcontainer.Cgroupfs) if err != nil { t.Fatal(err) } @@ -348,7 +348,7 @@ func TestFreeze(t *testing.T) { config := newTemplateConfig(rootfs) - factory, err := libcontainer.New(root, libcontainer.InitArgs(os.Args[0], "init", "--"), libcontainer.Cgroupfs) + factory, err := libcontainer.New(root, libcontainer.Cgroupfs) if err != nil { t.Fatal(err) }