Skip to content

Commit

Permalink
Introduce "create_grace_time" option (#26)
Browse files Browse the repository at this point in the history
* Introduce "create_grace_time" option

* Show exactly how much time we're going to wait
  • Loading branch information
edigaryev authored Oct 6, 2022
1 parent 04688ea commit d018787
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions builder/tart/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/hashicorp/packer-plugin-sdk/packer"
"github.com/hashicorp/packer-plugin-sdk/template/config"
"github.com/hashicorp/packer-plugin-sdk/template/interpolate"
"time"
)

const BuilderId = "tart.builder"
Expand All @@ -30,6 +31,7 @@ type Config struct {
Display string `mapstructure:"display" required:"false"`
DiskSizeGb uint16 `mapstructure:"disk_size_gb" required:"false"`
Headless bool `mapstructure:"headless" required:"false"`
CreateGraceTime time.Duration `mapstructure:"create_grace_time" required:"false"`
Comm communicator.Config `mapstructure:",squash"`

ctx interpolate.Context
Expand Down
2 changes: 2 additions & 0 deletions builder/tart/builder.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions builder/tart/step_create_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/hashicorp/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
"strconv"
"time"
)

type stepCreateVM struct{}
Expand Down Expand Up @@ -34,6 +35,13 @@ func (s *stepCreateVM) Run(ctx context.Context, state multistep.StateBag) multis
return multistep.ActionHalt
}

if config.CreateGraceTime != 0 {
message := fmt.Sprintf("Waiting %v to let the Virtualization.Framework's installation process "+
"to finish correctly...", config.CreateGraceTime)
ui.Say(message)
time.Sleep(config.CreateGraceTime)
}

return multistep.ActionContinue
}

Expand Down

0 comments on commit d018787

Please sign in to comment.