builder/virtualbox: unexport calculated fields
This commit is contained in:
parent
05acb7b461
commit
16960a52f2
|
@ -27,7 +27,6 @@ type Builder struct {
|
||||||
|
|
||||||
type config struct {
|
type config struct {
|
||||||
BootCommand []string `mapstructure:"boot_command"`
|
BootCommand []string `mapstructure:"boot_command"`
|
||||||
BootWait time.Duration ``
|
|
||||||
DiskSize uint `mapstructure:"disk_size"`
|
DiskSize uint `mapstructure:"disk_size"`
|
||||||
FloppyFiles []string `mapstructure:"floppy_files"`
|
FloppyFiles []string `mapstructure:"floppy_files"`
|
||||||
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
||||||
|
@ -43,13 +42,11 @@ type config struct {
|
||||||
ISOUrl string `mapstructure:"iso_url"`
|
ISOUrl string `mapstructure:"iso_url"`
|
||||||
OutputDir string `mapstructure:"output_directory"`
|
OutputDir string `mapstructure:"output_directory"`
|
||||||
ShutdownCommand string `mapstructure:"shutdown_command"`
|
ShutdownCommand string `mapstructure:"shutdown_command"`
|
||||||
ShutdownTimeout time.Duration ``
|
|
||||||
SSHHostPortMin uint `mapstructure:"ssh_host_port_min"`
|
SSHHostPortMin uint `mapstructure:"ssh_host_port_min"`
|
||||||
SSHHostPortMax uint `mapstructure:"ssh_host_port_max"`
|
SSHHostPortMax uint `mapstructure:"ssh_host_port_max"`
|
||||||
SSHPassword string `mapstructure:"ssh_password"`
|
SSHPassword string `mapstructure:"ssh_password"`
|
||||||
SSHPort uint `mapstructure:"ssh_port"`
|
SSHPort uint `mapstructure:"ssh_port"`
|
||||||
SSHUser string `mapstructure:"ssh_username"`
|
SSHUser string `mapstructure:"ssh_username"`
|
||||||
SSHWaitTimeout time.Duration ``
|
|
||||||
VBoxVersionFile string `mapstructure:"virtualbox_version_file"`
|
VBoxVersionFile string `mapstructure:"virtualbox_version_file"`
|
||||||
VBoxManage [][]string `mapstructure:"vboxmanage"`
|
VBoxManage [][]string `mapstructure:"vboxmanage"`
|
||||||
VMName string `mapstructure:"vm_name"`
|
VMName string `mapstructure:"vm_name"`
|
||||||
|
@ -61,6 +58,10 @@ type config struct {
|
||||||
RawBootWait string `mapstructure:"boot_wait"`
|
RawBootWait string `mapstructure:"boot_wait"`
|
||||||
RawShutdownTimeout string `mapstructure:"shutdown_timeout"`
|
RawShutdownTimeout string `mapstructure:"shutdown_timeout"`
|
||||||
RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"`
|
RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"`
|
||||||
|
|
||||||
|
bootWait time.Duration ``
|
||||||
|
shutdownTimeout time.Duration ``
|
||||||
|
sshWaitTimeout time.Duration ``
|
||||||
}
|
}
|
||||||
|
|
||||||
func (b *Builder) Prepare(raws ...interface{}) error {
|
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 {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("Failed parsing boot_wait: %s", err))
|
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.RawSSHWaitTimeout = "20m"
|
||||||
}
|
}
|
||||||
|
|
||||||
b.config.ShutdownTimeout, err = time.ParseDuration(b.config.RawShutdownTimeout)
|
b.config.shutdownTimeout, err = time.ParseDuration(b.config.RawShutdownTimeout)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("Failed parsing shutdown_timeout: %s", err))
|
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."))
|
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 {
|
if err != nil {
|
||||||
errs = append(errs, fmt.Errorf("Failed parsing ssh_wait_timeout: %s", err))
|
errs = append(errs, fmt.Errorf("Failed parsing ssh_wait_timeout: %s", err))
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,9 +40,9 @@ func (s *stepRun) Run(state map[string]interface{}) multistep.StepAction {
|
||||||
|
|
||||||
s.vmName = vmName
|
s.vmName = vmName
|
||||||
|
|
||||||
if int64(config.BootWait) > 0 {
|
if int64(config.bootWait) > 0 {
|
||||||
ui.Say(fmt.Sprintf("Waiting %s for boot...", config.BootWait))
|
ui.Say(fmt.Sprintf("Waiting %s for boot...", config.bootWait))
|
||||||
time.Sleep(config.BootWait)
|
time.Sleep(config.bootWait)
|
||||||
}
|
}
|
||||||
|
|
||||||
return multistep.ActionContinue
|
return multistep.ActionContinue
|
||||||
|
|
|
@ -45,8 +45,8 @@ func (s *stepShutdown) Run(state map[string]interface{}) multistep.StepAction {
|
||||||
cmd.Wait()
|
cmd.Wait()
|
||||||
|
|
||||||
// Wait for the machine to actually shut down
|
// Wait for the machine to actually shut down
|
||||||
log.Printf("Waiting max %s for shutdown to complete", config.ShutdownTimeout)
|
log.Printf("Waiting max %s for shutdown to complete", config.shutdownTimeout)
|
||||||
shutdownTimer := time.After(config.ShutdownTimeout)
|
shutdownTimer := time.After(config.shutdownTimeout)
|
||||||
for {
|
for {
|
||||||
running, _ := driver.IsRunning(vmName)
|
running, _ := driver.IsRunning(vmName)
|
||||||
if !running {
|
if !running {
|
||||||
|
|
|
@ -39,9 +39,8 @@ func (s *stepWaitForSSH) Run(state map[string]interface{}) multistep.StepAction
|
||||||
waitDone <- true
|
waitDone <- true
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.Printf("Waiting for SSH, up to timeout: %s", config.SSHWaitTimeout.String())
|
log.Printf("Waiting for SSH, up to timeout: %s", config.sshWaitTimeout.String())
|
||||||
|
timeout := time.After(config.sshWaitTimeout)
|
||||||
timeout := time.After(config.SSHWaitTimeout)
|
|
||||||
WaitLoop:
|
WaitLoop:
|
||||||
for {
|
for {
|
||||||
// Wait for either SSH to become available, a timeout to occur,
|
// Wait for either SSH to become available, a timeout to occur,
|
||||||
|
|
Loading…
Reference in New Issue