Integrate code review comments.

This commit is contained in:
Steven Merrill 2013-07-02 01:12:57 -04:00
parent c072a56b40
commit bade17edef
3 changed files with 8 additions and 8 deletions

View File

@ -52,7 +52,6 @@ type config struct {
PackerBuildName string `mapstructure:"packer_build_name"` PackerBuildName string `mapstructure:"packer_build_name"`
PackerDebug bool `mapstructure:"packer_debug"` PackerDebug bool `mapstructure:"packer_debug"`
FullDiskPath string ``
RawBootWait string `mapstructure:"boot_wait"` RawBootWait string `mapstructure:"boot_wait"`
RawShutdownTimeout string `mapstructure:"shutdown_timeout"` RawShutdownTimeout string `mapstructure:"shutdown_timeout"`
@ -115,9 +114,6 @@ func (b *Builder) Prepare(raws ...interface{}) error {
b.config.ToolsUploadPath = "{{ .Flavor }}.iso" 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 // Accumulate any errors
var err error var err error
errs := make([]error, 0) errs := make([]error, 0)

View File

@ -6,7 +6,8 @@ import (
"github.com/mitchellh/packer/packer" "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: // Uses:
// config *config // config *config
@ -18,12 +19,12 @@ import (
type stepCompactDisk struct{} type stepCompactDisk struct{}
func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction { func (stepCompactDisk) Run(state map[string]interface{}) multistep.StepAction {
config := state["config"].(*config)
driver := state["driver"].(Driver) driver := state["driver"].(Driver)
ui := state["ui"].(packer.Ui) ui := state["ui"].(packer.Ui)
full_disk_path := state["full_disk_path"].(string)
ui.Say("Compacting the disk image") 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) err := fmt.Errorf("Error compacting disk: %s", err)
state["error"] = err state["error"] = err
ui.Error(err.Error()) ui.Error(err.Error())

View File

@ -4,6 +4,7 @@ import (
"fmt" "fmt"
"github.com/mitchellh/multistep" "github.com/mitchellh/multistep"
"github.com/mitchellh/packer/packer" "github.com/mitchellh/packer/packer"
"path/filepath"
) )
// This step creates the virtual disks for the VM. // 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 := state["ui"].(packer.Ui)
ui.Say("Creating virtual machine disk") 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) err := fmt.Errorf("Error creating disk: %s", err)
state["error"] = err state["error"] = err
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt
} }
state["full_disk_path"] = full_disk_path
return multistep.ActionContinue return multistep.ActionContinue
} }