Commit e9a491ae authored by Shawn Neal's avatar Shawn Neal

New interpolation for additional vmware disks

parent b665339b
...@@ -45,15 +45,6 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction { ...@@ -45,15 +45,6 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction {
ui.Say("Building and writing VMX file") 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 vmxTemplate := DefaultVMXTemplate
if config.VMXTemplatePath != "" { if config.VMXTemplatePath != "" {
f, err := os.Open(config.VMXTemplatePath) f, err := os.Open(config.VMXTemplatePath)
...@@ -76,14 +67,16 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction { ...@@ -76,14 +67,16 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction {
vmxTemplate = string(rawBytes) vmxTemplate = string(rawBytes)
} }
ctx := config.ctx
if len(config.AdditionalDiskSize) > 0 { if len(config.AdditionalDiskSize) > 0 {
for i, _ := range config.AdditionalDiskSize { for i, _ := range config.AdditionalDiskSize {
data := &additionalDiskTemplateData{ ctx.Data = &additionalDiskTemplateData{
DiskNumber: i + 1, DiskNumber: i + 1,
DiskName: config.DiskName, DiskName: config.DiskName,
} }
diskTemplate, err := config.tpl.Process(DefaultAdditionalDiskTemplate, data) diskTemplate, err := interpolate.Render(DefaultAdditionalDiskTemplate, &ctx)
if err != nil { if err != nil {
err := fmt.Errorf("Error preparing VMX template for additional disk: %s", err) err := fmt.Errorf("Error preparing VMX template for additional disk: %s", err)
state.Put("error", err) state.Put("error", err)
...@@ -95,6 +88,14 @@ func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction { ...@@ -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) vmxContents, err := interpolate.Render(vmxTemplate, &ctx)
if err != nil { if err != nil {
err := fmt.Errorf("Error procesing VMX template: %s", err) err := fmt.Errorf("Error procesing VMX template: %s", err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment