Skip to content

Commit

Permalink
parallels: error when no VM file found in source
Browse files Browse the repository at this point in the history
The post-processor, when consuming a parallels artifact, checks for the
presence of a pvm or macvm file from the files of the artifact
received, and copies it in the output box for vagrant to use later.
However, if the artifact does not contain a compatible file, the
post-processor does not error, and instead returns a success, leading to
an unusable box being produced.

To avoid this, we count the files copied, and if none were, the box will
be unusable, so the post-processor errors now.
  • Loading branch information
lbajolet-hashicorp committed Jan 9, 2024
1 parent df8fc09 commit 3b41b4d
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions post-processor/vagrant/parallels.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ func (p *ParallelsProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact
// Create the metadata
metadata = map[string]interface{}{"provider": "parallels"}

copied := 0

// Copy all of the original contents into the temporary directory
for _, path := range artifact.Files() {
// If the file isn't critical to the function of the
Expand Down Expand Up @@ -55,6 +57,11 @@ func (p *ParallelsProvider) Process(ui packersdk.Ui, artifact packersdk.Artifact
if err = CopyContents(dstPath, path); err != nil {
return
}
copied++
}

if copied == 0 {
err = fmt.Errorf("No VM file found in source artifact")
}

return
Expand Down

0 comments on commit 3b41b4d

Please sign in to comment.