Changed VirtualBox VM builder according to current builder interface

pull/7780/head
Thomas Meckel 7 years ago committed by Thomas Meckel
parent 2ef911f6f0
commit 7d3c84e5f9

@ -12,7 +12,7 @@ import (
"time"
versionUtil "github.com/hashicorp/go-version"
packer "github.com/hashicorp/packer/common"
"github.com/hashicorp/packer/common/retry"
)
type VBox42Driver struct {

@ -1,9 +1,9 @@
package vm
import (
"context"
"errors"
"fmt"
"log"
vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common"
"github.com/hashicorp/packer/common"
@ -32,7 +32,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) {
// Run executes a Packer build and returns a packer.Artifact representing
// a VirtualBox appliance.
func (b *Builder) Run(ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
// Create the driver that we'll use to communicate with VirtualBox
driver, err := vboxcommon.NewDriver()
if err != nil {
@ -154,7 +154,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
}
// Run the steps.
b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state)
b.runner.Run(state)
b.runner.Run(ctx, state)
// Report any errors.
if rawErr, ok := state.GetOk("error"); ok {
@ -176,11 +176,3 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
return vboxcommon.NewArtifact(b.config.OutputDir)
}
}
// Cancel.
func (b *Builder) Cancel() {
if b.runner != nil {
log.Println("Cancelling the step runner...")
b.runner.Cancel()
}
}

Loading…
Cancel
Save