Change panic to multierror

This commit is contained in:
Chris Bednarski 2015-07-07 17:12:21 -06:00
parent 775450f46a
commit 1c71eaaa91
1 changed files with 5 additions and 5 deletions

View File

@ -59,6 +59,8 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
return nil, nil, err
}
var errs *packer.MultiError
// Set defaults.
if c.Network == "" {
c.Network = "default"
@ -75,11 +77,10 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
if c.ImageName == "" {
img, err := interpolate.Render("packer-{{timestamp}}", nil)
if err != nil {
panic(err)
errs = packer.MultiErrorAppend(errs,
fmt.Errorf("Unable to parse image name: %s ", err))
c.ImageName = img
}
// Default to packer-{{ unix timestamp (utc) }}
c.ImageName = img
}
if c.InstanceName == "" {
@ -102,7 +103,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
c.Comm.SSHUsername = "root"
}
var errs *packer.MultiError
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
errs = packer.MultiErrorAppend(errs, es...)
}