Skip to content
This repository was archived by the owner on Jan 15, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ func createRuntimeBundle(w walker, dest, refName, rootfs, platform string) error
return nil
}

func createBundle(w walker, m *manifest, dest, rootfs string) error {
func createBundle(w walker, m *manifest, dest, rootfs string) (retErr error) {
c, err := findConfig(w, &m.Config)
if err != nil {
return err
Expand All @@ -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 retErr != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use err instead of retErr. Otherwise I expect this will always be nil (unless we change to set retErr in the body of createBundle). Or maybe Go does something magic with named returns to set them up before defers fire?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when return ,go will assign the return value to retErr

if err3 := os.RemoveAll(dest); err3 != nil {
fmt.Printf("Failed to clean up %q: %s\n", dest, err3.Error())
}
}
}()
} else {
return err
}
Expand Down