builder/virtualbox: guest-additions_url can use Version var [GH-272]
This commit is contained in:
parent
51ed21e425
commit
171ecaefa6
|
@ -10,6 +10,8 @@ IMPROVEMENTS:
|
|||
|
||||
* core: built with Go 1.1.2
|
||||
* core: packer help output now loads much faster.
|
||||
* builder/virtualbox: guest_additions_url can now use the `Version`
|
||||
variable to get the VirtualBox version. [GH-272]
|
||||
* builder/virtualbox: Do not check for VirtualBox as part of template
|
||||
validation; only check at execution.
|
||||
* builder/vmware: Do not check for VMware as part of template validation;
|
||||
|
|
|
@ -132,8 +132,6 @@ func (b *Builder) Prepare(raws ...interface{}) error {
|
|||
|
||||
// Errors
|
||||
templates := map[string]*string{
|
||||
"guest_additions_path": &b.config.GuestAdditionsPath,
|
||||
"guest_additions_url": &b.config.GuestAdditionsURL,
|
||||
"guest_additions_sha256": &b.config.GuestAdditionsSHA256,
|
||||
"guest_os_type": &b.config.GuestOSType,
|
||||
"http_directory": &b.config.HTTPDir,
|
||||
|
@ -160,6 +158,18 @@ func (b *Builder) Prepare(raws ...interface{}) error {
|
|||
}
|
||||
}
|
||||
|
||||
validates := map[string]*string{
|
||||
"guest_additions_path": &b.config.GuestAdditionsPath,
|
||||
"guest_additions_url": &b.config.GuestAdditionsURL,
|
||||
}
|
||||
|
||||
for n, ptr := range validates {
|
||||
if err := b.config.tpl.Validate(*ptr); err != nil {
|
||||
errs = packer.MultiErrorAppend(
|
||||
errs, fmt.Errorf("Error parsing %s: %s", n, err))
|
||||
}
|
||||
}
|
||||
|
||||
for i, command := range b.config.BootCommand {
|
||||
if err := b.config.tpl.Validate(command); err != nil {
|
||||
errs = packer.MultiErrorAppend(errs,
|
||||
|
|
|
@ -21,6 +21,10 @@ var additionsVersionMap = map[string]string{
|
|||
"4.1.23": "4.1.22",
|
||||
}
|
||||
|
||||
type guestAdditionsUrlTemplate struct {
|
||||
Version string
|
||||
}
|
||||
|
||||
// This step uploads a file containing the VirtualBox version, which
|
||||
// can be useful for various provisioning reasons.
|
||||
//
|
||||
|
@ -69,7 +73,19 @@ func (s *stepDownloadGuestAdditions) Run(state map[string]interface{}) multistep
|
|||
|
||||
// Use the provided source (URL or file path) or generate it
|
||||
url := config.GuestAdditionsURL
|
||||
if url == "" {
|
||||
if url != "" {
|
||||
tplData := &guestAdditionsUrlTemplate{
|
||||
Version: version,
|
||||
}
|
||||
|
||||
url, err = config.tpl.Process(url, tplData)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("Error preparing guest additions url: %s", err)
|
||||
state["error"] = err
|
||||
ui.Error(err.Error())
|
||||
return multistep.ActionHalt
|
||||
}
|
||||
} else {
|
||||
url = fmt.Sprintf(
|
||||
"http://download.virtualbox.org/virtualbox/%s/%s",
|
||||
version,
|
||||
|
|
Loading…
Reference in New Issue