Commit 07cacb6d authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

builder/virtualbox: Add GuestOSType config

parent 4c18b0ae
...@@ -18,6 +18,7 @@ type Builder struct { ...@@ -18,6 +18,7 @@ type Builder struct {
} }
type config struct { type config struct {
GuestOSType string `mapstructure:"guest_os_type"`
OutputDir string `mapstructure:"output_directory"` OutputDir string `mapstructure:"output_directory"`
} }
...@@ -27,6 +28,10 @@ func (b *Builder) Prepare(raw interface{}) error { ...@@ -27,6 +28,10 @@ func (b *Builder) Prepare(raw interface{}) error {
return err return err
} }
if b.config.GuestOSType == "" {
b.config.GuestOSType = "Other"
}
if b.config.OutputDir == "" { if b.config.OutputDir == "" {
b.config.OutputDir = "virtualbox" b.config.OutputDir = "virtualbox"
} }
......
...@@ -16,3 +16,20 @@ func TestBuilder_ImplementsBuilder(t *testing.T) { ...@@ -16,3 +16,20 @@ func TestBuilder_ImplementsBuilder(t *testing.T) {
t.Error("Builder must implement builder.") t.Error("Builder must implement builder.")
} }
} }
func TestBuilderPrepare_Defaults(t *testing.T) {
var b Builder
config := testConfig()
err := b.Prepare(config)
if err != nil {
t.Fatalf("should not have error: %s", err)
}
if b.config.GuestOSType != "Other" {
t.Errorf("bad guest OS type: %s", b.config.GuestOSType)
}
if b.config.OutputDir != "virtualbox" {
t.Errorf("bad output dir: %s", b.config.OutputDir)
}
}
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