Skip to content

Commit

Permalink
Merge pull request #79 from q384566678/add-unpack
Browse files Browse the repository at this point in the history
create-main.go: If the dest file does not exist to create.
  • Loading branch information
xiekeyang authored Feb 3, 2017
2 parents 121b8c9 + 28fc85e commit 15a8732
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
5 changes: 0 additions & 5 deletions cmd/oci-create-runtime-bundle/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,6 @@ func (v *bundleCmd) Run(cmd *cobra.Command, args []string) {
os.Exit(1)
}

if _, err := os.Stat(args[1]); os.IsNotExist(err) {
v.stderr.Printf("destination path %s does not exist", args[1])
os.Exit(1)
}

if v.typ == "" {
typ, err := image.Autodetect(args[0])
if err != nil {
Expand Down
10 changes: 10 additions & 0 deletions image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,16 @@ func createRuntimeBundle(w walker, dest, refName, rootfs string) error {
return err
}

if _, err = os.Stat(dest); err != nil {
if os.IsNotExist(err) {
if err2 := os.MkdirAll(dest, 0755); err2 != nil {
return err2
}
} else {
return err
}
}

err = m.unpack(w, filepath.Join(dest, rootfs))
if err != nil {
return err
Expand Down

0 comments on commit 15a8732

Please sign in to comment.