|
|
|
|
@ -24,13 +24,14 @@ type Config struct {
|
|
|
|
|
vboxcommon.VBoxManagePostConfig `mapstructure:",squash"`
|
|
|
|
|
vboxcommon.VBoxVersionConfig `mapstructure:",squash"`
|
|
|
|
|
|
|
|
|
|
SourcePath string `mapstructure:"source_path"`
|
|
|
|
|
GuestAdditionsMode string `mapstructure:"guest_additions_mode"`
|
|
|
|
|
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
|
|
|
|
GuestAdditionsURL string `mapstructure:"guest_additions_url"`
|
|
|
|
|
GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
|
|
|
|
|
VMName string `mapstructure:"vm_name"`
|
|
|
|
|
ImportOpts string `mapstructure:"import_opts"`
|
|
|
|
|
SourcePath string `mapstructure:"source_path"`
|
|
|
|
|
GuestAdditionsMode string `mapstructure:"guest_additions_mode"`
|
|
|
|
|
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
|
|
|
|
|
GuestAdditionsURL string `mapstructure:"guest_additions_url"`
|
|
|
|
|
GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
|
|
|
|
|
VMName string `mapstructure:"vm_name"`
|
|
|
|
|
ImportOpts string `mapstructure:"import_opts"`
|
|
|
|
|
ImportFlags []string `mapstructure:"import_flags"`
|
|
|
|
|
|
|
|
|
|
tpl *packer.ConfigTemplate
|
|
|
|
|
}
|
|
|
|
|
@ -90,6 +91,21 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sliceTemplates := map[string][]string{
|
|
|
|
|
"import_flags": c.ImportFlags,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for n, slice := range sliceTemplates {
|
|
|
|
|
for i, elem := range slice {
|
|
|
|
|
var err error
|
|
|
|
|
slice[i], err = c.tpl.Process(elem, nil)
|
|
|
|
|
if err != nil {
|
|
|
|
|
errs = packer.MultiErrorAppend(
|
|
|
|
|
errs, fmt.Errorf("Error processing %s[%d]: %s", n, i, err))
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if c.SourcePath == "" {
|
|
|
|
|
errs = packer.MultiErrorAppend(errs, fmt.Errorf("source_path is required"))
|
|
|
|
|
} else {
|
|
|
|
|
@ -147,5 +163,10 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|
|
|
|
return nil, warnings, errs
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// TODO: Write a packer fix and just remove import_opts
|
|
|
|
|
if c.ImportOpts != "" {
|
|
|
|
|
c.ImportFlags = append(c.ImportFlags, "--options", c.ImportOpts)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return c, warnings, nil
|
|
|
|
|
}
|
|
|
|
|
|