github.com/rothwerx/packer@v0.9.0/builder/parallels/common/output_config.go (about) 1 package common 2 3 import ( 4 "fmt" 5 "os" 6 7 "github.com/mitchellh/packer/common" 8 "github.com/mitchellh/packer/template/interpolate" 9 ) 10 11 type OutputConfig struct { 12 OutputDir string `mapstructure:"output_directory"` 13 } 14 15 func (c *OutputConfig) Prepare(ctx *interpolate.Context, pc *common.PackerConfig) []error { 16 if c.OutputDir == "" { 17 c.OutputDir = fmt.Sprintf("output-%s", pc.PackerBuildName) 18 } 19 20 var errs []error 21 if !pc.PackerForce { 22 if _, err := os.Stat(c.OutputDir); err == nil { 23 errs = append(errs, fmt.Errorf( 24 "Output directory '%s' already exists. It must not exist.", c.OutputDir)) 25 } 26 } 27 28 return errs 29 }