diff --git a/image/image.go b/image/image.go index e95e065..b391719 100644 --- a/image/image.go +++ b/image/image.go @@ -301,6 +301,13 @@ func createBundle(w walker, m *manifest, dest, rootfs string) error { if err2 := os.MkdirAll(dest, 0755); err2 != nil { return err2 } + defer func() { + if err != nil { + if err3 := os.RemoveAll(dest); err3 != nil { + fmt.Printf("Failed to clean up %q: %s\n", dest, err3.Error()) + } + } + }() } else { return err }