Commit 4abd1c22 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox: Set the default boot_wait [GH-44]

parent 2f84cd6c
...@@ -89,6 +89,10 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -89,6 +89,10 @@ func (b *Builder) Prepare(raws ...interface{}) error {
b.config.OutputDir = "virtualbox" b.config.OutputDir = "virtualbox"
} }
if b.config.RawBootWait == "" {
b.config.RawBootWait = "10s"
}
if b.config.SSHHostPortMin == 0 { if b.config.SSHHostPortMin == 0 {
b.config.SSHHostPortMin = 2222 b.config.SSHHostPortMin = 2222
} }
...@@ -168,11 +172,9 @@ func (b *Builder) Prepare(raws ...interface{}) error { ...@@ -168,11 +172,9 @@ func (b *Builder) Prepare(raws ...interface{}) error {
errs = append(errs, errors.New("Output directory already exists. It must not exist.")) errs = append(errs, errors.New("Output directory already exists. It must not exist."))
} }
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 {
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))
}
} }
if b.config.RawShutdownTimeout == "" { if b.config.RawShutdownTimeout == "" {
......
...@@ -61,9 +61,16 @@ func TestBuilderPrepare_BootWait(t *testing.T) { ...@@ -61,9 +61,16 @@ func TestBuilderPrepare_BootWait(t *testing.T) {
var b Builder var b Builder
config := testConfig() config := testConfig()
// Test a default boot_wait
delete(config, "boot_wait")
err := b.Prepare(config)
if err != nil {
t.Fatalf("err: %s", err)
}
// Test with a bad boot_wait // Test with a bad boot_wait
config["boot_wait"] = "this is not good" config["boot_wait"] = "this is not good"
err := b.Prepare(config) err = b.Prepare(config)
if err == nil { if err == nil {
t.Fatal("should have error") t.Fatal("should have error")
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment