From 8aff01c0b447fa4d68f053c44e8baf7b24247164 Mon Sep 17 00:00:00 2001 From: Michael Crosby Date: Wed, 4 Jun 2014 15:47:57 -0700 Subject: [PATCH] Rename nsinit package to namespaces in libcontainer Docker-DCO-1.1-Signed-off-by: Michael Crosby (github: crosbymichael) --- daemon/execdriver/native/driver.go | 16 ++++++++-------- .../{nsinit => namespaces}/create.go | 2 +- pkg/libcontainer/{nsinit => namespaces}/exec.go | 2 +- .../{nsinit => namespaces}/execin.go | 2 +- pkg/libcontainer/{nsinit => namespaces}/init.go | 2 +- pkg/libcontainer/{nsinit => namespaces}/pid.go | 2 +- .../{nsinit => namespaces}/std_term.go | 2 +- .../{nsinit => namespaces}/sync_pipe.go | 2 +- pkg/libcontainer/{nsinit => namespaces}/term.go | 2 +- .../{nsinit => namespaces}/tty_term.go | 2 +- .../{nsinit => namespaces}/unsupported.go | 2 +- pkg/libcontainer/nsinit/{nsinit => }/main.go | 16 ++++++++-------- 12 files changed, 26 insertions(+), 26 deletions(-) rename pkg/libcontainer/{nsinit => namespaces}/create.go (92%) rename pkg/libcontainer/{nsinit => namespaces}/exec.go (99%) rename pkg/libcontainer/{nsinit => namespaces}/execin.go (99%) rename pkg/libcontainer/{nsinit => namespaces}/init.go (99%) rename pkg/libcontainer/{nsinit => namespaces}/pid.go (97%) rename pkg/libcontainer/{nsinit => namespaces}/std_term.go (97%) rename pkg/libcontainer/{nsinit => namespaces}/sync_pipe.go (98%) rename pkg/libcontainer/{nsinit => namespaces}/term.go (95%) rename pkg/libcontainer/{nsinit => namespaces}/tty_term.go (98%) rename pkg/libcontainer/{nsinit => namespaces}/unsupported.go (97%) rename pkg/libcontainer/nsinit/{nsinit => }/main.go (83%) diff --git a/daemon/execdriver/native/driver.go b/daemon/execdriver/native/driver.go index a57c466f2c..41121a70f3 100644 --- a/daemon/execdriver/native/driver.go +++ b/daemon/execdriver/native/driver.go @@ -16,7 +16,7 @@ import ( "github.com/dotcloud/docker/pkg/libcontainer" "github.com/dotcloud/docker/pkg/libcontainer/cgroups/fs" "github.com/dotcloud/docker/pkg/libcontainer/cgroups/systemd" - "github.com/dotcloud/docker/pkg/libcontainer/nsinit" + "github.com/dotcloud/docker/pkg/libcontainer/namespaces" "github.com/dotcloud/docker/pkg/system" ) @@ -42,11 +42,11 @@ func init() { if err != nil { return err } - syncPipe, err := nsinit.NewSyncPipeFromFd(0, uintptr(args.Pipe)) + syncPipe, err := namespaces.NewSyncPipeFromFd(0, uintptr(args.Pipe)) if err != nil { return err } - if err := nsinit.Init(container, rootfs, args.Console, syncPipe, args.Args); err != nil { + if err := namespaces.Init(container, rootfs, args.Console, syncPipe, args.Args); err != nil { return err } return nil @@ -110,8 +110,8 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba term := getTerminal(c, pipes) - return nsinit.Exec(container, term, c.Rootfs, dataPath, args, func(container *libcontainer.Container, console, rootfs, dataPath, init string, child *os.File, args []string) *exec.Cmd { - // we need to join the rootfs because nsinit will setup the rootfs and chroot + return namespaces.Exec(container, term, c.Rootfs, dataPath, args, func(container *libcontainer.Container, console, rootfs, dataPath, init string, child *os.File, args []string) *exec.Cmd { + // we need to join the rootfs because namespaces will setup the rootfs and chroot initPath := filepath.Join(c.Rootfs, c.InitPath) c.Path = d.initPath @@ -126,7 +126,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba // set this to nil so that when we set the clone flags anything else is reset c.SysProcAttr = nil - system.SetCloneFlags(&c.Cmd, uintptr(nsinit.GetNamespaceFlags(container.Namespaces))) + system.SetCloneFlags(&c.Cmd, uintptr(namespaces.GetNamespaceFlags(container.Namespaces))) c.ExtraFiles = []*os.File{child} c.Env = container.Env @@ -258,8 +258,8 @@ func getEnv(key string, env []string) string { return "" } -func getTerminal(c *execdriver.Command, pipes *execdriver.Pipes) nsinit.Terminal { - var term nsinit.Terminal +func getTerminal(c *execdriver.Command, pipes *execdriver.Pipes) namespaces.Terminal { + var term namespaces.Terminal if c.Tty { term = &dockerTtyTerm{ pipes: pipes, diff --git a/pkg/libcontainer/nsinit/create.go b/pkg/libcontainer/namespaces/create.go similarity index 92% rename from pkg/libcontainer/nsinit/create.go rename to pkg/libcontainer/namespaces/create.go index d5cba464d2..60b2a2db02 100644 --- a/pkg/libcontainer/nsinit/create.go +++ b/pkg/libcontainer/namespaces/create.go @@ -1,4 +1,4 @@ -package nsinit +package namespaces import ( "os" diff --git a/pkg/libcontainer/nsinit/exec.go b/pkg/libcontainer/namespaces/exec.go similarity index 99% rename from pkg/libcontainer/nsinit/exec.go rename to pkg/libcontainer/namespaces/exec.go index f266303f8c..288205ea60 100644 --- a/pkg/libcontainer/nsinit/exec.go +++ b/pkg/libcontainer/namespaces/exec.go @@ -1,6 +1,6 @@ // +build linux -package nsinit +package namespaces import ( "os" diff --git a/pkg/libcontainer/nsinit/execin.go b/pkg/libcontainer/namespaces/execin.go similarity index 99% rename from pkg/libcontainer/nsinit/execin.go rename to pkg/libcontainer/namespaces/execin.go index 40b95093dd..09bf40582a 100644 --- a/pkg/libcontainer/nsinit/execin.go +++ b/pkg/libcontainer/namespaces/execin.go @@ -1,6 +1,6 @@ // +build linux -package nsinit +package namespaces import ( "fmt" diff --git a/pkg/libcontainer/nsinit/init.go b/pkg/libcontainer/namespaces/init.go similarity index 99% rename from pkg/libcontainer/nsinit/init.go rename to pkg/libcontainer/namespaces/init.go index dc983161fa..b53c56668d 100644 --- a/pkg/libcontainer/nsinit/init.go +++ b/pkg/libcontainer/namespaces/init.go @@ -1,6 +1,6 @@ // +build linux -package nsinit +package namespaces import ( "fmt" diff --git a/pkg/libcontainer/nsinit/pid.go b/pkg/libcontainer/namespaces/pid.go similarity index 97% rename from pkg/libcontainer/nsinit/pid.go rename to pkg/libcontainer/namespaces/pid.go index bba2f10e1b..8d97ec1463 100644 --- a/pkg/libcontainer/nsinit/pid.go +++ b/pkg/libcontainer/namespaces/pid.go @@ -1,4 +1,4 @@ -package nsinit +package namespaces import ( "fmt" diff --git a/pkg/libcontainer/nsinit/std_term.go b/pkg/libcontainer/namespaces/std_term.go similarity index 97% rename from pkg/libcontainer/nsinit/std_term.go rename to pkg/libcontainer/namespaces/std_term.go index 2b8201a71b..324336af28 100644 --- a/pkg/libcontainer/nsinit/std_term.go +++ b/pkg/libcontainer/namespaces/std_term.go @@ -1,4 +1,4 @@ -package nsinit +package namespaces import ( "io" diff --git a/pkg/libcontainer/nsinit/sync_pipe.go b/pkg/libcontainer/namespaces/sync_pipe.go similarity index 98% rename from pkg/libcontainer/nsinit/sync_pipe.go rename to pkg/libcontainer/namespaces/sync_pipe.go index d0bfdda865..e12ed447fa 100644 --- a/pkg/libcontainer/nsinit/sync_pipe.go +++ b/pkg/libcontainer/namespaces/sync_pipe.go @@ -1,4 +1,4 @@ -package nsinit +package namespaces import ( "encoding/json" diff --git a/pkg/libcontainer/nsinit/term.go b/pkg/libcontainer/namespaces/term.go similarity index 95% rename from pkg/libcontainer/nsinit/term.go rename to pkg/libcontainer/namespaces/term.go index 5fc801ab53..2a50bf8554 100644 --- a/pkg/libcontainer/nsinit/term.go +++ b/pkg/libcontainer/namespaces/term.go @@ -1,4 +1,4 @@ -package nsinit +package namespaces import ( "io" diff --git a/pkg/libcontainer/nsinit/tty_term.go b/pkg/libcontainer/namespaces/tty_term.go similarity index 98% rename from pkg/libcontainer/nsinit/tty_term.go rename to pkg/libcontainer/namespaces/tty_term.go index fc6e1ab499..272cf2cd65 100644 --- a/pkg/libcontainer/nsinit/tty_term.go +++ b/pkg/libcontainer/namespaces/tty_term.go @@ -1,4 +1,4 @@ -package nsinit +package namespaces import ( "io" diff --git a/pkg/libcontainer/nsinit/unsupported.go b/pkg/libcontainer/namespaces/unsupported.go similarity index 97% rename from pkg/libcontainer/nsinit/unsupported.go rename to pkg/libcontainer/namespaces/unsupported.go index 51509f79a2..b459b4d2f5 100644 --- a/pkg/libcontainer/nsinit/unsupported.go +++ b/pkg/libcontainer/namespaces/unsupported.go @@ -1,6 +1,6 @@ // +build !linux -package nsinit +package namespaces import ( "github.com/dotcloud/docker/pkg/libcontainer" diff --git a/pkg/libcontainer/nsinit/nsinit/main.go b/pkg/libcontainer/nsinit/main.go similarity index 83% rename from pkg/libcontainer/nsinit/nsinit/main.go rename to pkg/libcontainer/nsinit/main.go index 5d968375ed..6659a1310e 100644 --- a/pkg/libcontainer/nsinit/nsinit/main.go +++ b/pkg/libcontainer/nsinit/main.go @@ -13,7 +13,7 @@ import ( "github.com/dotcloud/docker/pkg/libcontainer" "github.com/dotcloud/docker/pkg/libcontainer/cgroups/fs" - "github.com/dotcloud/docker/pkg/libcontainer/nsinit" + "github.com/dotcloud/docker/pkg/libcontainer/namespaces" ) var ( @@ -40,9 +40,9 @@ func main() { } if nspid > 0 { - exitCode, err = nsinit.ExecIn(container, nspid, os.Args[2:]) + exitCode, err = namespaces.ExecIn(container, nspid, os.Args[2:]) } else { - term := nsinit.NewTerminal(os.Stdin, os.Stdout, os.Stderr, container.Tty) + term := namespaces.NewTerminal(os.Stdin, os.Stdout, os.Stderr, container.Tty) exitCode, err = startContainer(container, term, dataPath, os.Args[2:]) } @@ -61,12 +61,12 @@ func main() { if err != nil { log.Fatal(err) } - syncPipe, err := nsinit.NewSyncPipeFromFd(0, uintptr(pipeFd)) + syncPipe, err := namespaces.NewSyncPipeFromFd(0, uintptr(pipeFd)) if err != nil { log.Fatalf("unable to create sync pipe: %s", err) } - if err := nsinit.Init(container, rootfs, console, syncPipe, os.Args[2:]); err != nil { + if err := namespaces.Init(container, rootfs, console, syncPipe, os.Args[2:]); err != nil { log.Fatalf("unable to initialize for container: %s", err) } case "stats": @@ -124,7 +124,7 @@ func readPid() (int, error) { // error. // // Signals sent to the current process will be forwarded to container. -func startContainer(container *libcontainer.Container, term nsinit.Terminal, dataPath string, args []string) (int, error) { +func startContainer(container *libcontainer.Container, term namespaces.Terminal, dataPath string, args []string) (int, error) { var ( cmd *exec.Cmd sigc = make(chan os.Signal, 10) @@ -133,7 +133,7 @@ func startContainer(container *libcontainer.Container, term nsinit.Terminal, dat signal.Notify(sigc) createCommand := func(container *libcontainer.Container, console, rootfs, dataPath, init string, pipe *os.File, args []string) *exec.Cmd { - cmd = nsinit.DefaultCreateCommand(container, console, rootfs, dataPath, init, pipe, args) + cmd = namespaces.DefaultCreateCommand(container, console, rootfs, dataPath, init, pipe, args) return cmd } @@ -145,7 +145,7 @@ func startContainer(container *libcontainer.Container, term nsinit.Terminal, dat }() } - return nsinit.Exec(container, term, "", dataPath, args, createCommand, startCallback) + return namespaces.Exec(container, term, "", dataPath, args, createCommand, startCallback) } // returns the container stats in json format.