remove unused file, set up prepare() properly to work with HCL2 in vsphere-clone builder
This commit is contained in:
parent
9459e2233b
commit
dfb45e86cc
|
@ -1,20 +0,0 @@
|
|||
<component name="ProjectDictionaryState">
|
||||
<dictionary name="project">
|
||||
<words>
|
||||
<w>abcdefghijklmnopqrstuvwxyz</w>
|
||||
<w>cdrom</w>
|
||||
<w>cdroms</w>
|
||||
<w>datastore</w>
|
||||
<w>datastores</w>
|
||||
<w>esxi</w>
|
||||
<w>hashicorp</w>
|
||||
<w>mozilla</w>
|
||||
<w>sata</w>
|
||||
<w>scancode</w>
|
||||
<w>vcenter</w>
|
||||
<w>vmware</w>
|
||||
<w>vmxnet</w>
|
||||
<w>vsphere</w>
|
||||
</words>
|
||||
</dictionary>
|
||||
</component>
|
|
@ -12,25 +12,23 @@ import (
|
|||
)
|
||||
|
||||
type Builder struct {
|
||||
config *Config
|
||||
config Config
|
||||
runner multistep.Runner
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
||||
state := new(multistep.BasicStateBag)
|
||||
state.Put("comm", &b.config.Comm)
|
||||
state.Put("hook", hook)
|
||||
state.Put("ui", ui)
|
||||
|
||||
|
|
|
@ -35,14 +35,13 @@ 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,
|
||||
}, raws...)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
errs := new(packer.MultiError)
|
||||
|
@ -56,8 +55,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
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
)
|
||||
|
||||
type Builder struct {
|
||||
config *Config
|
||||
config Config
|
||||
runner multistep.Runner
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) {
|
|||
|
||||
func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (packer.Artifact, error) {
|
||||
state := new(multistep.BasicStateBag)
|
||||
state.Put("comm", &b.config.Comm)
|
||||
state.Put("hook", hook)
|
||||
state.Put("ui", ui)
|
||||
|
||||
|
|
Loading…
Reference in New Issue