From dfb45e86ccf50ba57f2c0f3422bc4e5bff0f7831 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Mon, 13 Jan 2020 12:33:56 -0800 Subject: [PATCH] remove unused file, set up prepare() properly to work with HCL2 in vsphere-clone builder --- .idea/dictionaries/project.xml | 20 -------------------- builder/vsphere/clone/builder.go | 6 ++---- builder/vsphere/clone/config.go | 9 ++++----- builder/vsphere/iso/builder.go | 3 +-- 4 files changed, 7 insertions(+), 31 deletions(-) delete mode 100644 .idea/dictionaries/project.xml diff --git a/.idea/dictionaries/project.xml b/.idea/dictionaries/project.xml deleted file mode 100644 index f77b8be28..000000000 --- a/.idea/dictionaries/project.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - abcdefghijklmnopqrstuvwxyz - cdrom - cdroms - datastore - datastores - esxi - hashicorp - mozilla - sata - scancode - vcenter - vmware - vmxnet - vsphere - - - diff --git a/builder/vsphere/clone/builder.go b/builder/vsphere/clone/builder.go index 48e1681c0..4c33f76aa 100644 --- a/builder/vsphere/clone/builder.go +++ b/builder/vsphere/clone/builder.go @@ -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) diff --git a/builder/vsphere/clone/config.go b/builder/vsphere/clone/config.go index f03685a82..a473301be 100644 --- a/builder/vsphere/clone/config.go +++ b/builder/vsphere/clone/config.go @@ -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 } diff --git a/builder/vsphere/iso/builder.go b/builder/vsphere/iso/builder.go index 7c809a746..5c33d10f6 100644 --- a/builder/vsphere/iso/builder.go +++ b/builder/vsphere/iso/builder.go @@ -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)