builder/virtualbox: Add GuestOSType config
This commit is contained in:
parent
4c18b0ae5b
commit
07cacb6dda
|
@ -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"
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue