Change panic to multierror
This commit is contained in:
parent
775450f46a
commit
1c71eaaa91
|
@ -59,6 +59,8 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var errs *packer.MultiError
|
||||||
|
|
||||||
// Set defaults.
|
// Set defaults.
|
||||||
if c.Network == "" {
|
if c.Network == "" {
|
||||||
c.Network = "default"
|
c.Network = "default"
|
||||||
|
@ -75,12 +77,11 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
||||||
if c.ImageName == "" {
|
if c.ImageName == "" {
|
||||||
img, err := interpolate.Render("packer-{{timestamp}}", nil)
|
img, err := interpolate.Render("packer-{{timestamp}}", nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
errs = packer.MultiErrorAppend(errs,
|
||||||
}
|
fmt.Errorf("Unable to parse image name: %s ", err))
|
||||||
|
|
||||||
// Default to packer-{{ unix timestamp (utc) }}
|
|
||||||
c.ImageName = img
|
c.ImageName = img
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if c.InstanceName == "" {
|
if c.InstanceName == "" {
|
||||||
c.InstanceName = fmt.Sprintf("packer-%s", uuid.TimeOrderedUUID())
|
c.InstanceName = fmt.Sprintf("packer-%s", uuid.TimeOrderedUUID())
|
||||||
|
@ -102,7 +103,6 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
||||||
c.Comm.SSHUsername = "root"
|
c.Comm.SSHUsername = "root"
|
||||||
}
|
}
|
||||||
|
|
||||||
var errs *packer.MultiError
|
|
||||||
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
|
if es := c.Comm.Prepare(&c.ctx); len(es) > 0 {
|
||||||
errs = packer.MultiErrorAppend(errs, es...)
|
errs = packer.MultiErrorAppend(errs, es...)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue