Skip to content

Commit

Permalink
Merge pull request #263 from mkumatag/fix_segv
Browse files Browse the repository at this point in the history
Fix the sigsegv fault when image not found
  • Loading branch information
ppc64le-cloud-bot authored Jan 13, 2025
2 parents 41c31fb + cd7454c commit 34944a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
5 changes: 4 additions & 1 deletion GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ dev: build
@mkdir -p ~/.packer.d/plugins/
@mv ${BINARY} ~/.packer.d/plugins/${BINARY}

install: build
uninstall:
@packer plugins remove github.com/ppc64le-cloud/powervs

install: build uninstall
@packer plugins install -path ./${BINARY} "github.com/ppc64le-cloud/powervs"

test:
Expand Down
11 changes: 6 additions & 5 deletions builder/powervs/step_import_base_image.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,14 +163,15 @@ func (s *StepImageBaseImage) Run(_ context.Context, state multistep.StateBag) mu
imageRef = image
}
}
ui.Message(fmt.Sprintf("Image found with ID: %s", *imageRef.ImageID))

if imageRef != nil {
state.Put("source_image", imageRef)
return multistep.ActionContinue
} else {
if imageRef == nil {
ui.Error("failed to find an image")
return multistep.ActionHalt
}

ui.Message(fmt.Sprintf("Image found with ID: %s", *imageRef.ImageID))
state.Put("source_image", imageRef)
return multistep.ActionContinue
}

// Cleanup can be used to clean up any artifact created by the step.
Expand Down

0 comments on commit 34944a2

Please sign in to comment.