2013-12-27 10:37:39 -05:00
|
|
|
package common
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2014-10-28 11:37:12 -04:00
|
|
|
"os"
|
2013-12-27 10:37:39 -05:00
|
|
|
|
|
|
|
"github.com/mitchellh/packer/packer"
|
|
|
|
)
|
|
|
|
|
|
|
|
type DriverConfig struct {
|
|
|
|
FusionAppPath string `mapstructure:"fusion_app_path"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *DriverConfig) Prepare(t *packer.ConfigTemplate) []error {
|
2014-10-28 11:21:39 -04:00
|
|
|
if c.FusionAppPath == "" {
|
|
|
|
c.FusionAppPath = os.Getenv("FUSION_APP_PATH")
|
|
|
|
}
|
2013-12-27 10:37:39 -05:00
|
|
|
if c.FusionAppPath == "" {
|
|
|
|
c.FusionAppPath = "/Applications/VMware Fusion.app"
|
|
|
|
}
|
|
|
|
|
|
|
|
templates := map[string]*string{
|
|
|
|
"fusion_app_path": &c.FusionAppPath,
|
|
|
|
}
|
|
|
|
|
|
|
|
var err error
|
|
|
|
errs := make([]error, 0)
|
|
|
|
for n, ptr := range templates {
|
|
|
|
*ptr, err = t.Process(*ptr, nil)
|
|
|
|
if err != nil {
|
|
|
|
errs = append(errs, fmt.Errorf("Error processing %s: %s", n, err))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return errs
|
|
|
|
}
|