Commit 3c2df9a1 authored by Mitchell Hashimoto's avatar Mitchell Hashimoto

post-processor/vsphere: comments and style

parent 12d16cac
...@@ -61,6 +61,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -61,6 +61,7 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
errs, fmt.Errorf("ovftool not found: %s", err)) errs, fmt.Errorf("ovftool not found: %s", err))
} }
// First define all our templatable parameters that are _required_
templates := map[string]*string{ templates := map[string]*string{
"cluster": &p.config.Cluster, "cluster": &p.config.Cluster,
"datacenter": &p.config.Datacenter, "datacenter": &p.config.Datacenter,
...@@ -71,7 +72,6 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -71,7 +72,6 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
"username": &p.config.Username, "username": &p.config.Username,
"vm_name": &p.config.VMName, "vm_name": &p.config.VMName,
} }
for key, ptr := range templates { for key, ptr := range templates {
if *ptr == "" { if *ptr == "" {
errs = packer.MultiErrorAppend( errs = packer.MultiErrorAppend(
...@@ -79,10 +79,12 @@ func (p *PostProcessor) Configure(raws ...interface{}) error { ...@@ -79,10 +79,12 @@ func (p *PostProcessor) Configure(raws ...interface{}) error {
} }
} }
templates ["datastore"] = &p.config.Datastore // Then define the ones that are optional
templates ["vm_network"] = &p.config.VMNetwork templates["datastore"] = &p.config.Datastore
templates ["vm_folder"] = &p.config.VMFolder templates["vm_network"] = &p.config.VMNetwork
templates["vm_folder"] = &p.config.VMFolder
// Template process
for key, ptr := range templates { for key, ptr := range templates {
*ptr, err = p.config.tpl.Process(*ptr, nil) *ptr, err = p.config.tpl.Process(*ptr, nil)
if err != nil { if err != nil {
......
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