Skip to content

Commit

Permalink
Respect disk size upon creation (#23)
Browse files Browse the repository at this point in the history
  • Loading branch information
fkorotkov authored Sep 20, 2022
1 parent 15a18d0 commit 13cc207
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion builder/tart/step_create_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"github.com/hashicorp/packer-plugin-sdk/multistep"
packersdk "github.com/hashicorp/packer-plugin-sdk/packer"
"strconv"
)

type stepCreateVM struct{}
Expand All @@ -15,7 +16,17 @@ func (s *stepCreateVM) Run(ctx context.Context, state multistep.StateBag) multis

ui.Say("Creating virtual machine...")

if _, err := TartExec("create", "--from-ipsw", config.FromIPSW, config.VMName); err != nil {
createArguments := []string{
"create", "--from-ipsw", config.FromIPSW,
}

if config.DiskSizeGb > 0 {
createArguments = append(createArguments, "--disk-size", strconv.Itoa(int(config.DiskSizeGb)))
}

createArguments = append(createArguments, config.VMName)

if _, err := TartExec(createArguments...); err != nil {
err := fmt.Errorf("Failed to create a VM: %s", err)
state.Put("error", err)
ui.Error(err.Error())
Expand Down

0 comments on commit 13cc207

Please sign in to comment.