Skip to content

Commit

Permalink
adding support for --bundle-dir -b to start, restore, and spec; fixes…
Browse files Browse the repository at this point in the history
… issue #310

Signed-off-by: Mike Brown <[email protected]>
  • Loading branch information
mikebrow committed Oct 27, 2015
1 parent db21ac7 commit b912a00
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
7 changes: 4 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ After creating config files for your root filesystem with runc, you can execute
container in your shell by running:
# cd /mycontainer
# runc start [ -c spec-config-file ] [ -r runtime-config-file ]
# runc start [-b bundle-dir] [-c spec-config-file] [-r runtime-config-file]
If not specified, the default value for the 'spec-config-file' is 'config.json',
and the default value for the 'runtime-config-file' is 'runtime.json'.`
If not specified, the default value for the 'bundle-dir' is './',
'spec-config-file' is 'config.json', and the default value for the
'runtime-config-file' is 'runtime.json'.`
)

func main() {
Expand Down
11 changes: 11 additions & 0 deletions restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ var restoreCommand = cli.Command{
Value: "",
Usage: "cgroups mode: 'soft' (default), 'full' and 'strict'.",
},
cli.StringFlag{
Name: "bundle-dir, b",
Value: "./",
Usage: "path to the root of the bundle directory",
},
cli.StringFlag{
Name: "config-file, c",
Value: "config.json",
Expand All @@ -65,6 +70,12 @@ var restoreCommand = cli.Command{
if imagePath == "" {
imagePath = getDefaultImagePath(context)
}
bundleDir := context.String("bundle-dir")
if bundleDir != "./" {
if err := os.Chdir(bundleDir); err != nil {
fatal(err)
}
}
spec, rspec, err := loadSpec(context.String("config-file"), context.String("runtime-file"))
if err != nil {
fatal(err)
Expand Down
11 changes: 11 additions & 0 deletions spec.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ var specCommand = cli.Command{
Name: "spec",
Usage: "create a new specification file",
Flags: []cli.Flag{
cli.StringFlag{
Name: "bundle-dir, b",
Value: "./",
Usage: "path to the root of the bundle directory",
},
cli.StringFlag{
Name: "config-file, c",
Value: "config.json",
Expand Down Expand Up @@ -247,6 +252,12 @@ var specCommand = cli.Command{
}
return nil
}
bundleDir := context.String("bundle-dir")
if bundleDir != "./" {
if err := os.Chdir(bundleDir); err != nil {
fatal(err)
}
}
cName := context.String("config-file")
rName := context.String("runtime-file")
if err := checkNoFile(cName); err != nil {
Expand Down
11 changes: 11 additions & 0 deletions start.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ var startCommand = cli.Command{
Name: "start",
Usage: "create and run a container",
Flags: []cli.Flag{
cli.StringFlag{
Name: "bundle-dir, b",
Value: "./",
Usage: "path to the root of the bundle directory",
},
cli.StringFlag{
Name: "config-file, c",
Value: "config.json",
Expand All @@ -33,6 +38,12 @@ var startCommand = cli.Command{
},
},
Action: func(context *cli.Context) {
bundleDir := context.String("bundle-dir")
if bundleDir != "./" {
if err := os.Chdir(bundleDir); err != nil {
fatal(err)
}
}
spec, rspec, err := loadSpec(context.String("config-file"), context.String("runtime-file"))
if err != nil {
fatal(err)
Expand Down

0 comments on commit b912a00

Please sign in to comment.