Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: #7 #115

Merged
merged 3 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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: 9 additions & 0 deletions builder/hyperv/common/step_create_build_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ type StepCreateBuildDir struct {
// The full path to the build directory. This is the concatenation of
// TempPath plus a directory uniquely named for the build
buildDir string
// If true, the build directory will not be deleted when the step
// Cleanup() method is called
KeepRegistered bool
}

// Creates the main directory used to house the VMs files and folders
Expand Down Expand Up @@ -62,6 +65,12 @@ func (s *StepCreateBuildDir) Cleanup(state multistep.StateBag) {
}

ui := state.Get("ui").(packersdk.Ui)

if s.KeepRegistered {
remi-espie marked this conversation as resolved.
Show resolved Hide resolved
ui.Say("Keeping build directory...")
return
}

ui.Say("Deleting build directory...")

err := os.RemoveAll(s.buildDir)
Expand Down
3 changes: 2 additions & 1 deletion builder/hyperv/iso/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)

steps := []multistep.Step{
&hypervcommon.StepCreateBuildDir{
TempPath: b.config.TempPath,
TempPath: b.config.TempPath,
KeepRegistered: b.config.KeepRegistered,
},
&commonsteps.StepOutputDir{
Force: b.config.PackerForce,
Expand Down
3 changes: 2 additions & 1 deletion builder/hyperv/vmcx/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook)

steps := []multistep.Step{
&hypervcommon.StepCreateBuildDir{
TempPath: b.config.TempPath,
TempPath: b.config.TempPath,
KeepRegistered: b.config.KeepRegistered,
},
&commonsteps.StepOutputDir{
Force: b.config.PackerForce,
Expand Down