From 6b6beae3b815ce3a36cb93f15bb280de832fab38 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 14 Jul 2013 21:23:46 +0900 Subject: [PATCH] builder/vmware: unexport calculted config fields --- builder/vmware/builder.go | 13 +++++++------ builder/vmware/builder_test.go | 4 ++-- builder/vmware/step_run.go | 6 +++--- builder/vmware/step_shutdown.go | 4 ++-- builder/vmware/step_wait_for_ssh.go | 5 ++--- 5 files changed, 16 insertions(+), 16 deletions(-) diff --git a/builder/vmware/builder.go b/builder/vmware/builder.go index 6445ac97c..832cbd8c3 100644 --- a/builder/vmware/builder.go +++ b/builder/vmware/builder.go @@ -41,14 +41,11 @@ type config struct { HTTPPortMin uint `mapstructure:"http_port_min"` HTTPPortMax uint `mapstructure:"http_port_max"` BootCommand []string `mapstructure:"boot_command"` - BootWait time.Duration `` SkipCompaction bool `mapstructure:"skip_compaction"` ShutdownCommand string `mapstructure:"shutdown_command"` - ShutdownTimeout time.Duration `` SSHUser string `mapstructure:"ssh_username"` SSHPassword string `mapstructure:"ssh_password"` SSHPort uint `mapstructure:"ssh_port"` - SSHWaitTimeout time.Duration `` ToolsUploadFlavor string `mapstructure:"tools_upload_flavor"` ToolsUploadPath string `mapstructure:"tools_upload_path"` VMXData map[string]string `mapstructure:"vmx_data"` @@ -62,6 +59,10 @@ type config struct { RawBootWait string `mapstructure:"boot_wait"` RawShutdownTimeout string `mapstructure:"shutdown_timeout"` RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"` + + bootWait time.Duration `` + shutdownTimeout time.Duration `` + sshWaitTimeout time.Duration `` } func (b *Builder) Prepare(raws ...interface{}) error { @@ -222,7 +223,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { } if b.config.RawBootWait != "" { - b.config.BootWait, err = time.ParseDuration(b.config.RawBootWait) + b.config.bootWait, err = time.ParseDuration(b.config.RawBootWait) if err != nil { errs = append(errs, fmt.Errorf("Failed parsing boot_wait: %s", err)) } @@ -232,7 +233,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { b.config.RawShutdownTimeout = "5m" } - b.config.ShutdownTimeout, err = time.ParseDuration(b.config.RawShutdownTimeout) + b.config.shutdownTimeout, err = time.ParseDuration(b.config.RawShutdownTimeout) if err != nil { errs = append(errs, fmt.Errorf("Failed parsing shutdown_timeout: %s", err)) } @@ -241,7 +242,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { b.config.RawSSHWaitTimeout = "20m" } - b.config.SSHWaitTimeout, err = time.ParseDuration(b.config.RawSSHWaitTimeout) + b.config.sshWaitTimeout, err = time.ParseDuration(b.config.RawSSHWaitTimeout) if err != nil { errs = append(errs, fmt.Errorf("Failed parsing ssh_wait_timeout: %s", err)) } diff --git a/builder/vmware/builder_test.go b/builder/vmware/builder_test.go index be6badd4f..99f0b0d71 100644 --- a/builder/vmware/builder_test.go +++ b/builder/vmware/builder_test.go @@ -126,8 +126,8 @@ func TestBuilderPrepare_Defaults(t *testing.T) { t.Errorf("bad output dir: %s", b.config.OutputDir) } - if b.config.SSHWaitTimeout != (20 * time.Minute) { - t.Errorf("bad wait timeout: %s", b.config.SSHWaitTimeout) + if b.config.sshWaitTimeout != (20 * time.Minute) { + t.Errorf("bad wait timeout: %s", b.config.sshWaitTimeout) } if b.config.VMName != "packer-foo" { diff --git a/builder/vmware/step_run.go b/builder/vmware/step_run.go index 98a5c8a50..75ce071f7 100644 --- a/builder/vmware/step_run.go +++ b/builder/vmware/step_run.go @@ -49,9 +49,9 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction { } // Wait the wait amount - if int64(config.BootWait) > 0 { - ui.Say(fmt.Sprintf("Waiting %s for boot...", config.BootWait.String())) - time.Sleep(config.BootWait) + if int64(config.bootWait) > 0 { + ui.Say(fmt.Sprintf("Waiting %s for boot...", config.bootWait.String())) + time.Sleep(config.bootWait) } return multistep.ActionContinue diff --git a/builder/vmware/step_shutdown.go b/builder/vmware/step_shutdown.go index 004bd775e..97b8efbee 100644 --- a/builder/vmware/step_shutdown.go +++ b/builder/vmware/step_shutdown.go @@ -65,8 +65,8 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction { log.Printf("Shutdown stderr: %s", stderr.String()) // Wait for the machine to actually shut down - log.Printf("Waiting max %s for shutdown to complete", config.ShutdownTimeout) - shutdownTimer := time.After(config.ShutdownTimeout) + log.Printf("Waiting max %s for shutdown to complete", config.shutdownTimeout) + shutdownTimer := time.After(config.shutdownTimeout) for { running, _ := driver.IsRunning(vmxPath) if !running { diff --git a/builder/vmware/step_wait_for_ssh.go b/builder/vmware/step_wait_for_ssh.go index 60c826f2d..84e475454 100644 --- a/builder/vmware/step_wait_for_ssh.go +++ b/builder/vmware/step_wait_for_ssh.go @@ -41,9 +41,8 @@ func (s *stepWaitForSSH) Run(state map[string]interface{}) multistep.StepAction waitDone <- true }() - log.Printf("Waiting for SSH, up to timeout: %s", config.SSHWaitTimeout.String()) - - timeout := time.After(config.SSHWaitTimeout) + log.Printf("Waiting for SSH, up to timeout: %s", config.sshWaitTimeout.String()) + timeout := time.After(config.sshWaitTimeout) WaitLoop: for { // Wait for either SSH to become available, a timeout to occur,