From e9a491ae45871c42bf9b86c302b6ed26657b8acf Mon Sep 17 00:00:00 2001 From: Shawn Neal Date: Thu, 4 Jun 2015 11:44:07 -0700 Subject: [PATCH] New interpolation for additional vmware disks --- builder/vmware/iso/step_create_vmx.go | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go index 97cd1262c..69cb3f261 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/builder/vmware/iso/step_create_vmx.go @@ -45,15 +45,6 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction { ui.Say("Building and writing VMX file") - ctx := config.ctx - ctx.Data = &vmxTemplateData{ - Name: config.VMName, - GuestOS: config.GuestOSType, - DiskName: config.DiskName, - Version: config.Version, - ISOPath: isoPath, - } - vmxTemplate := DefaultVMXTemplate if config.VMXTemplatePath != "" { f, err := os.Open(config.VMXTemplatePath) @@ -76,14 +67,16 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction { vmxTemplate = string(rawBytes) } + ctx := config.ctx + if len(config.AdditionalDiskSize) > 0 { for i, _ := range config.AdditionalDiskSize { - data := &additionalDiskTemplateData{ + ctx.Data = &additionalDiskTemplateData{ DiskNumber: i + 1, DiskName: config.DiskName, } - diskTemplate, err := config.tpl.Process(DefaultAdditionalDiskTemplate, data) + diskTemplate, err := interpolate.Render(DefaultAdditionalDiskTemplate, &ctx) if err != nil { err := fmt.Errorf("Error preparing VMX template for additional disk: %s", err) state.Put("error", err) @@ -95,6 +88,14 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction { } } + ctx.Data = &vmxTemplateData{ + Name: config.VMName, + GuestOS: config.GuestOSType, + DiskName: config.DiskName, + Version: config.Version, + ISOPath: isoPath, + } + vmxContents, err := interpolate.Render(vmxTemplate, &ctx) if err != nil { err := fmt.Errorf("Error procesing VMX template: %s", err)