From bade17edefffe1cbe9c7a88bf19c4b2132ae3e37 Mon Sep 17 00:00:00 2001 From: Steven Merrill Date: Tue, 2 Jul 2013 01:12:57 -0400 Subject: [PATCH] Integrate code review comments. --- builder/vmware/builder.go | 4 ---- builder/vmware/step_compact_disk.go | 7 ++++--- builder/vmware/step_create_disk.go | 5 ++++- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/builder/vmware/builder.go b/builder/vmware/builder.go index dab0880b6..413619f1e 100644 --- a/builder/vmware/builder.go +++ b/builder/vmware/builder.go @@ -52,7 +52,6 @@ type config struct { PackerBuildName string `mapstructure:"packer_build_name"` PackerDebug bool `mapstructure:"packer_debug"` - FullDiskPath string `` RawBootWait string `mapstructure:"boot_wait"` RawShutdownTimeout string `mapstructure:"shutdown_timeout"` @@ -115,9 +114,6 @@ func (b *Builder) Prepare(raws ...interface{}) error { b.config.ToolsUploadPath = "{{ .Flavor }}.iso" } - // Store the full path to the disk file. - b.config.FullDiskPath = filepath.Join(b.config.OutputDir, b.config.DiskName+".vmdk") - // Accumulate any errors var err error errs := make([]error, 0) diff --git a/builder/vmware/step_compact_disk.go b/builder/vmware/step_compact_disk.go index 18034bb87..34da410b8 100644 --- a/builder/vmware/step_compact_disk.go +++ b/builder/vmware/step_compact_disk.go @@ -6,7 +6,8 @@ import ( "github.com/mitchellh/packer/packer" ) -// This step compacts the virtual disks for the VM. +// This step compacts the virtual disk for the VM. If "compact_disk" is not +// true, it will immediately return. // // Uses: // config *config @@ -18,12 +19,12 @@ import ( type stepCompactDisk struct{} func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction { - config := state["config"].(*config) driver := state["driver"].(Driver) ui := state["ui"].(packer.Ui) + full_disk_path := state["full_disk_path"].(string) ui.Say("Compacting the disk image") - if err := driver.CompactDisk(config.FullDiskPath); err != nil { + if err := driver.CompactDisk(full_disk_path); err != nil { err := fmt.Errorf("Error compacting disk: %s", err) state["error"] = err ui.Error(err.Error()) diff --git a/builder/vmware/step_create_disk.go b/builder/vmware/step_create_disk.go index 7a6ce21b2..56ae154a8 100644 --- a/builder/vmware/step_create_disk.go +++ b/builder/vmware/step_create_disk.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/mitchellh/multistep" "github.com/mitchellh/packer/packer" + "path/filepath" ) // This step creates the virtual disks for the VM. @@ -23,12 +24,14 @@ func (stepCreateDisk) Run(state map[string]interface{}) multistep.StepAction { ui := state["ui"].(packer.Ui) ui.Say("Creating virtual machine disk") - if err := driver.CreateDisk(config.FullDiskPath, fmt.Sprintf("%dM", config.DiskSize)); err != nil { + full_disk_path := filepath.Join(config.OutputDir, config.DiskName+".vmdk") + if err := driver.CreateDisk(full_disk_path, fmt.Sprintf("%dM", config.DiskSize)); err != nil { err := fmt.Errorf("Error creating disk: %s", err) state["error"] = err ui.Error(err.Error()) return multistep.ActionHalt } + state["full_disk_path"] = full_disk_path return multistep.ActionContinue }