From 0b4729c9e42616f6eb45fdc91e789010ead2e1eb Mon Sep 17 00:00:00 2001 From: Michael Kuzmin Date: Sat, 5 May 2018 01:48:16 +0300 Subject: [PATCH] 'configuration_parameters' in clone builder --- clone/builder.go | 7 ++++--- clone/config.go | 1 + {iso => common}/step_config_params.go | 2 +- iso/builder.go | 2 +- iso/config.go | 8 ++++---- 5 files changed, 11 insertions(+), 9 deletions(-) rename {iso => common}/step_config_params.go (98%) diff --git a/clone/builder.go b/clone/builder.go index 2df7a39f0..343677c89 100644 --- a/clone/builder.go +++ b/clone/builder.go @@ -2,11 +2,11 @@ package clone import ( packerCommon "github.com/hashicorp/packer/common" - "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/packer" "github.com/jetbrains-infra/packer-builder-vsphere/common" "github.com/jetbrains-infra/packer-builder-vsphere/driver" "github.com/hashicorp/packer/helper/multistep" + "github.com/hashicorp/packer/helper/communicator" ) type Builder struct { @@ -26,7 +26,6 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, error) { func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error) { state := new(multistep.BasicStateBag) - state.Put("config", b.config) state.Put("comm", &b.config.Comm) state.Put("hook", hook) state.Put("ui", ui) @@ -43,6 +42,9 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe &StepConfigureHardware{ config: &b.config.HardwareConfig, }, + &common.StepConfigParams{ + Config: &b.config.ConfigParamsConfig, + }, ) if b.config.Comm.Type != "none" { @@ -72,7 +74,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe }, ) - // Run! b.runner = packerCommon.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(state) diff --git a/clone/config.go b/clone/config.go index 93f680e3f..d4839163d 100644 --- a/clone/config.go +++ b/clone/config.go @@ -18,6 +18,7 @@ type Config struct { common.ShutdownConfig `mapstructure:",squash"` CreateSnapshot bool `mapstructure:"create_snapshot"` ConvertToTemplate bool `mapstructure:"convert_to_template"` + common.ConfigParamsConfig `mapstructure:",squash"` ctx interpolate.Context } diff --git a/iso/step_config_params.go b/common/step_config_params.go similarity index 98% rename from iso/step_config_params.go rename to common/step_config_params.go index 4bb18ab94..7a85a9068 100644 --- a/iso/step_config_params.go +++ b/common/step_config_params.go @@ -1,4 +1,4 @@ -package iso +package common import ( "github.com/hashicorp/packer/packer" diff --git a/iso/builder.go b/iso/builder.go index bacc83c68..bb12aa4dd 100644 --- a/iso/builder.go +++ b/iso/builder.go @@ -39,7 +39,7 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe &StepCreateVM{ Config: &b.config.CreateConfig, }, - &StepConfigParams{ + &common.StepConfigParams{ Config: &b.config.ConfigParamsConfig, }, ) diff --git a/iso/config.go b/iso/config.go index 73777d571..d415aa527 100644 --- a/iso/config.go +++ b/iso/config.go @@ -19,10 +19,10 @@ type Config struct { CreateSnapshot bool `mapstructure:"create_snapshot"` ConvertToTemplate bool `mapstructure:"convert_to_template"` - CreateConfig `mapstructure:",squash"` - CDRomConfig `mapstructure:",squash"` - FloppyConfig `mapstructure:",squash"` - ConfigParamsConfig `mapstructure:",squash"` + CreateConfig `mapstructure:",squash"` + CDRomConfig `mapstructure:",squash"` + FloppyConfig `mapstructure:",squash"` + common.ConfigParamsConfig `mapstructure:",squash"` ctx interpolate.Context }