post-processor/vsphere: comments and style

This commit is contained in:
Mitchell Hashimoto 2014-04-30 15:52:01 -07:00
parent 12d16cace1
commit 3c2df9a132
1 changed files with 6 additions and 4 deletions

View File

@ -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 {
"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 {
} }
} }
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 {