github.com/daniellockard/packer@v0.7.6-0.20141210173435-5a9390934716/builder/vmware/common/driver_config.go (about) 1 package common 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/mitchellh/packer/packer" 8 ) 9 10 type DriverConfig struct { 11 FusionAppPath string `mapstructure:"fusion_app_path"` 12 } 13 14 func (c *DriverConfig) Prepare(t *packer.ConfigTemplate) []error { 15 if c.FusionAppPath == "" { 16 c.FusionAppPath = os.Getenv("FUSION_APP_PATH") 17 } 18 if c.FusionAppPath == "" { 19 c.FusionAppPath = "/Applications/VMware Fusion.app" 20 } 21 22 templates := map[string]*string{ 23 "fusion_app_path": &c.FusionAppPath, 24 } 25 26 var err error 27 errs := make([]error, 0) 28 for n, ptr := range templates { 29 *ptr, err = t.Process(*ptr, nil) 30 if err != nil { 31 errs = append(errs, fmt.Errorf("Error processing %s: %s", n, err)) 32 } 33 } 34 35 return errs 36 }