From 07cacb6ddacf4a840357e3698594de9a838da888 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 11 Jun 2013 15:57:20 -0700 Subject: [PATCH] builder/virtualbox: Add GuestOSType config --- builder/virtualbox/builder.go | 5 +++++ builder/virtualbox/builder_test.go | 17 +++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/builder/virtualbox/builder.go b/builder/virtualbox/builder.go index 09ed1a8fb..b53e4bb73 100644 --- a/builder/virtualbox/builder.go +++ b/builder/virtualbox/builder.go @@ -18,6 +18,7 @@ type Builder struct { } type config struct { + GuestOSType string `mapstructure:"guest_os_type"` OutputDir string `mapstructure:"output_directory"` } @@ -27,6 +28,10 @@ func (b *Builder) Prepare(raw interface{}) error { return err } + if b.config.GuestOSType == "" { + b.config.GuestOSType = "Other" + } + if b.config.OutputDir == "" { b.config.OutputDir = "virtualbox" } diff --git a/builder/virtualbox/builder_test.go b/builder/virtualbox/builder_test.go index fe102130d..904e8f847 100644 --- a/builder/virtualbox/builder_test.go +++ b/builder/virtualbox/builder_test.go @@ -16,3 +16,20 @@ func TestBuilder_ImplementsBuilder(t *testing.T) { 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) + } +}