From 16960a52f21ad7ff65b45fe936d2d32c1a6bf146 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 14 Jul 2013 21:22:11 +0900 Subject: [PATCH] builder/virtualbox: unexport calculated fields --- builder/virtualbox/builder.go | 13 +++++++------ builder/virtualbox/step_run.go | 6 +++--- builder/virtualbox/step_shutdown.go | 4 ++-- builder/virtualbox/step_wait_for_ssh.go | 5 ++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/builder/virtualbox/builder.go b/builder/virtualbox/builder.go index c19b51b91..da716d30c 100644 --- a/builder/virtualbox/builder.go +++ b/builder/virtualbox/builder.go @@ -27,7 +27,6 @@ type Builder struct { type config struct { BootCommand []string `mapstructure:"boot_command"` - BootWait time.Duration `` DiskSize uint `mapstructure:"disk_size"` FloppyFiles []string `mapstructure:"floppy_files"` GuestAdditionsPath string `mapstructure:"guest_additions_path"` @@ -43,13 +42,11 @@ type config struct { ISOUrl string `mapstructure:"iso_url"` OutputDir string `mapstructure:"output_directory"` ShutdownCommand string `mapstructure:"shutdown_command"` - ShutdownTimeout time.Duration `` SSHHostPortMin uint `mapstructure:"ssh_host_port_min"` SSHHostPortMax uint `mapstructure:"ssh_host_port_max"` SSHPassword string `mapstructure:"ssh_password"` SSHPort uint `mapstructure:"ssh_port"` SSHUser string `mapstructure:"ssh_username"` - SSHWaitTimeout time.Duration `` VBoxVersionFile string `mapstructure:"virtualbox_version_file"` VBoxManage [][]string `mapstructure:"vboxmanage"` VMName string `mapstructure:"vm_name"` @@ -61,6 +58,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 { @@ -261,7 +262,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { } } - 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)) } @@ -274,7 +275,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { b.config.RawSSHWaitTimeout = "20m" } - 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)) } @@ -287,7 +288,7 @@ func (b *Builder) Prepare(raws ...interface{}) error { errs = append(errs, errors.New("An ssh_username must be specified.")) } - 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/virtualbox/step_run.go b/builder/virtualbox/step_run.go index df978bdb6..2cf9ba093 100644 --- a/builder/virtualbox/step_run.go +++ b/builder/virtualbox/step_run.go @@ -40,9 +40,9 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction { s.vmName = vmName - if int64(config.BootWait) > 0 { - ui.Say(fmt.Sprintf("Waiting %s for boot...", config.BootWait)) - time.Sleep(config.BootWait) + if int64(config.bootWait) > 0 { + ui.Say(fmt.Sprintf("Waiting %s for boot...", config.bootWait)) + time.Sleep(config.bootWait) } return multistep.ActionContinue diff --git a/builder/virtualbox/step_shutdown.go b/builder/virtualbox/step_shutdown.go index 9b250a843..f2d076927 100644 --- a/builder/virtualbox/step_shutdown.go +++ b/builder/virtualbox/step_shutdown.go @@ -45,8 +45,8 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction { cmd.Wait() // 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(vmName) if !running { diff --git a/builder/virtualbox/step_wait_for_ssh.go b/builder/virtualbox/step_wait_for_ssh.go index 55327d754..8a2db4133 100644 --- a/builder/virtualbox/step_wait_for_ssh.go +++ b/builder/virtualbox/step_wait_for_ssh.go @@ -39,9 +39,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,