Skip to content
This repository was archived by the owner on May 9, 2025. It is now read-only.

Commit 15a8732

Browse files
authored
Merge pull request #79 from q384566678/add-unpack
create-main.go: If the dest file does not exist to create.
2 parents 121b8c9 + 28fc85e commit 15a8732

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

cmd/oci-create-runtime-bundle/main.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,6 @@ func (v *bundleCmd) Run(cmd *cobra.Command, args []string) {
119119
os.Exit(1)
120120
}
121121

122-
if _, err := os.Stat(args[1]); os.IsNotExist(err) {
123-
v.stderr.Printf("destination path %s does not exist", args[1])
124-
os.Exit(1)
125-
}
126-
127122
if v.typ == "" {
128123
typ, err := image.Autodetect(args[0])
129124
if err != nil {

image/image.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,16 @@ func createRuntimeBundle(w walker, dest, refName, rootfs string) error {
180180
return err
181181
}
182182

183+
if _, err = os.Stat(dest); err != nil {
184+
if os.IsNotExist(err) {
185+
if err2 := os.MkdirAll(dest, 0755); err2 != nil {
186+
return err2
187+
}
188+
} else {
189+
return err
190+
}
191+
}
192+
183193
err = m.unpack(w, filepath.Join(dest, rootfs))
184194
if err != nil {
185195
return err

0 commit comments

Comments
 (0)