mirror of
https://github.com/hashicorp/packer.git
synced 2026-06-11 01:30:06 -04:00
fix config loading to work with HCL2
This commit is contained in:
parent
f84634aff3
commit
9459e2233b
2 changed files with 5 additions and 7 deletions
|
|
@ -19,11 +19,10 @@ type Builder struct {
|
|||
func (b *Builder) ConfigSpec() hcldec.ObjectSpec { return b.config.FlatMapstructure().HCL2Spec() }
|
||||
|
||||
func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
||||
c, warnings, errs := NewConfig(raws...)
|
||||
warnings, errs := b.config.Prepare()
|
||||
if errs != nil {
|
||||
return warnings, nil, errs
|
||||
}
|
||||
b.config = c
|
||||
|
||||
return warnings, nil, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,7 @@ type Config struct {
|
|||
ctx interpolate.Context
|
||||
}
|
||||
|
||||
func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
||||
c := new(Config)
|
||||
func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
|
||||
err := config.Decode(c, &config.DecodeOpts{
|
||||
Interpolate: true,
|
||||
InterpolateContext: &c.ctx,
|
||||
|
|
@ -50,7 +49,7 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|||
},
|
||||
}, raws...)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
warnings := make([]string, 0)
|
||||
|
|
@ -75,8 +74,8 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) {
|
|||
errs = packer.MultiErrorAppend(errs, c.ShutdownConfig.Prepare()...)
|
||||
|
||||
if len(errs.Errors) > 0 {
|
||||
return nil, nil, errs
|
||||
return nil, errs
|
||||
}
|
||||
|
||||
return c, nil, nil
|
||||
return nil, nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue