Merge pull request #448 from crosbymichael/nsinit-usability
nsinit usability improvements
This commit is contained in:
commit
d658fb8a25
|
@ -24,8 +24,7 @@ var execCommand = cli.Command{
|
||||||
Flags: append([]cli.Flag{
|
Flags: append([]cli.Flag{
|
||||||
cli.BoolFlag{Name: "tty,t", Usage: "allocate a TTY to the container"},
|
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: "id", Value: "nsinit", Usage: "specify the ID for a container"},
|
||||||
cli.StringFlag{Name: "config", Value: "container.json", Usage: "path to the configuration file"},
|
cli.StringFlag{Name: "config", Value: "", Usage: "path to the configuration file"},
|
||||||
cli.BoolFlag{Name: "create", Usage: "create the container's configuration on the fly with arguments"},
|
|
||||||
cli.StringFlag{Name: "user,u", Value: "root", Usage: "set the user, uid, and/or gid for the process"},
|
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.StringFlag{Name: "cwd", Value: "", Usage: "set the current working dir"},
|
||||||
cli.StringSliceFlag{Name: "env", Value: standardEnvironment, Usage: "set environment variables for the process"},
|
cli.StringSliceFlag{Name: "env", Value: standardEnvironment, Usage: "set environment variables for the process"},
|
||||||
|
|
|
@ -14,7 +14,7 @@ func main() {
|
||||||
app.Author = "libcontainer maintainers"
|
app.Author = "libcontainer maintainers"
|
||||||
app.Flags = []cli.Flag{
|
app.Flags = []cli.Flag{
|
||||||
cli.StringFlag{Name: "root", Value: ".", Usage: "root directory for containers"},
|
cli.StringFlag{Name: "root", Value: ".", Usage: "root directory for containers"},
|
||||||
cli.StringFlag{Name: "log-file", Value: "nsinit-debug.log", Usage: "set the log file to output logs to"},
|
cli.StringFlag{Name: "log-file", Value: "", Usage: "set the log file to output logs to"},
|
||||||
cli.BoolFlag{Name: "debug", Usage: "enable debug output in the logs"},
|
cli.BoolFlag{Name: "debug", Usage: "enable debug output in the logs"},
|
||||||
}
|
}
|
||||||
app.Commands = []cli.Command{
|
app.Commands = []cli.Command{
|
||||||
|
|
|
@ -11,20 +11,20 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func loadConfig(context *cli.Context) (*configs.Config, error) {
|
func loadConfig(context *cli.Context) (*configs.Config, error) {
|
||||||
if context.Bool("create") {
|
if path := context.String("config"); path != "" {
|
||||||
config := getTemplate()
|
f, err := os.Open(path)
|
||||||
modify(config, context)
|
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
|
return config, nil
|
||||||
}
|
}
|
||||||
f, err := os.Open(context.String("config"))
|
config := getTemplate()
|
||||||
if err != nil {
|
modify(config, context)
|
||||||
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
|
return config, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue