From 3977c892e78d91a0c6d2a34fd2512a6c53c8d924 Mon Sep 17 00:00:00 2001 From: Michael Crosby <crosbymichael@gmail.com> Date: Wed, 11 Mar 2015 11:46:11 -0700 Subject: [PATCH] Remove --create from nsinit and make it default More people are using this to test new features and this makes it very simple to run a container with a simple command. `nsinit exec --tty sh` Signed-off-by: Michael Crosby <crosbymichael@gmail.com> --- nsinit/exec.go | 3 +-- nsinit/utils.go | 24 ++++++++++++------------ 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/nsinit/exec.go b/nsinit/exec.go index c2b9b0b0..9d302aa3 100644 --- a/nsinit/exec.go +++ b/nsinit/exec.go @@ -24,8 +24,7 @@ var execCommand = cli.Command{ Flags: append([]cli.Flag{ cli.BoolFlag{Name: "tty,t", Usage: "allocate a TTY to the container"}, cli.StringFlag{Name: "id", Value: "nsinit", Usage: "specify the ID for a container"}, - cli.StringFlag{Name: "config", Value: "container.json", Usage: "path to the configuration file"}, - cli.BoolFlag{Name: "create", Usage: "create the container's configuration on the fly with arguments"}, + cli.StringFlag{Name: "config", Value: "", Usage: "path to the configuration file"}, cli.StringFlag{Name: "user,u", Value: "root", Usage: "set the user, uid, and/or gid for the process"}, cli.StringFlag{Name: "cwd", Value: "", Usage: "set the current working dir"}, cli.StringSliceFlag{Name: "env", Value: standardEnvironment, Usage: "set environment variables for the process"}, diff --git a/nsinit/utils.go b/nsinit/utils.go index dad75aec..4deca766 100644 --- a/nsinit/utils.go +++ b/nsinit/utils.go @@ -11,20 +11,20 @@ import ( ) func loadConfig(context *cli.Context) (*configs.Config, error) { - if context.Bool("create") { - config := getTemplate() - modify(config, context) + if path := context.String("config"); path != "" { + f, err := os.Open(path) + if err != nil { + return nil, err + } + defer f.Close() + var config *configs.Config + if err := json.NewDecoder(f).Decode(&config); err != nil { + return nil, err + } return config, nil } - f, err := os.Open(context.String("config")) - if err != nil { - return nil, err - } - defer f.Close() - var config *configs.Config - if err := json.NewDecoder(f).Decode(&config); err != nil { - return nil, err - } + config := getTemplate() + modify(config, context) return config, nil }