From 2d90ffe7a402164e6961ffaacf5a939fc2676584 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Wed, 4 Nov 2020 15:44:05 -0800 Subject: [PATCH] move GeneratedData struct and PlaceholderMsg to same package under common --- builder/amazon/chroot/builder.go | 4 ++-- builder/amazon/chroot/step_mount_device.go | 4 ++-- builder/amazon/chroot/step_prepare_device.go | 4 ++-- builder/amazon/common/interpolate_build_info.go | 4 ++-- builder/amazon/common/interpolate_build_info_test.go | 6 +++--- builder/amazon/common/step_modify_ami_attributes.go | 4 ++-- builder/amazon/common/step_set_generated_data.go | 4 ++-- builder/amazon/common/tags.go | 4 ++-- builder/amazon/ebs/builder.go | 4 ++-- builder/amazon/ebssurrogate/builder.go | 4 ++-- builder/amazon/ebsvolume/builder.go | 4 ++-- builder/amazon/instance/builder.go | 4 ++-- builder/docker/builder.go | 4 ++-- builder/docker/step_set_generated_data.go | 4 ++-- builder/docker/step_set_generated_data_test.go | 6 +++--- builder/yandex/builder.go | 4 ++-- builder/yandex/step_create_image.go | 4 ++-- builder/yandex/step_create_instance.go | 4 ++-- {builder => common/packerbuilderdata}/generated_data.go | 7 ++++++- .../packerbuilderdata}/generated_data_test.go | 2 +- helper/common/shared_state.go | 6 ------ packer/build.go | 4 ++-- packer/build_test.go | 4 ++-- packer/provisioner.go | 4 ++-- post-processor/yandex-export/post-processor.go | 4 ++-- template/interpolate/funcs.go | 4 ++-- template/interpolate/funcs_test.go | 8 ++++---- 27 files changed, 59 insertions(+), 60 deletions(-) rename {builder => common/packerbuilderdata}/generated_data.go (68%) rename {builder => common/packerbuilderdata}/generated_data_test.go (97%) delete mode 100644 helper/common/shared_state.go diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 9fb431583..814bedd84 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -14,10 +14,10 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/builder" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/chroot" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/hcl2template" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -369,7 +369,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("hook", hook) state.Put("ui", ui) state.Put("wrappedCommand", common.CommandWrapper(wrappedCommand)) - generatedData := &builder.GeneratedData{State: state} + generatedData := &packerbuilderdata.GeneratedData{State: state} // Build the steps steps := []multistep.Step{ diff --git a/builder/amazon/chroot/step_mount_device.go b/builder/amazon/chroot/step_mount_device.go index dffd35854..af796d4b6 100644 --- a/builder/amazon/chroot/step_mount_device.go +++ b/builder/amazon/chroot/step_mount_device.go @@ -10,8 +10,8 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/builder" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" @@ -31,7 +31,7 @@ type StepMountDevice struct { MountPartition string mountPath string - GeneratedData *builder.GeneratedData + GeneratedData *packerbuilderdata.GeneratedData } func (s *StepMountDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { diff --git a/builder/amazon/chroot/step_prepare_device.go b/builder/amazon/chroot/step_prepare_device.go index 098d83858..d91ace7c8 100644 --- a/builder/amazon/chroot/step_prepare_device.go +++ b/builder/amazon/chroot/step_prepare_device.go @@ -6,14 +6,14 @@ import ( "log" "os" - "github.com/hashicorp/packer/builder" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) // StepPrepareDevice finds an available device and sets it. type StepPrepareDevice struct { - GeneratedData *builder.GeneratedData + GeneratedData *packerbuilderdata.GeneratedData } func (s *StepPrepareDevice) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { diff --git a/builder/amazon/common/interpolate_build_info.go b/builder/amazon/common/interpolate_build_info.go index 21647eaa0..e04400f4b 100644 --- a/builder/amazon/common/interpolate_build_info.go +++ b/builder/amazon/common/interpolate_build_info.go @@ -3,7 +3,7 @@ package common import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/builder" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/multistep" ) @@ -17,7 +17,7 @@ type BuildInfoTemplate struct { SourceAMITags map[string]string } -func extractBuildInfo(region string, state multistep.StateBag, generatedData *builder.GeneratedData) *BuildInfoTemplate { +func extractBuildInfo(region string, state multistep.StateBag, generatedData *packerbuilderdata.GeneratedData) *BuildInfoTemplate { rawSourceAMI, hasSourceAMI := state.GetOk("source_image") if !hasSourceAMI { return &BuildInfoTemplate{ diff --git a/builder/amazon/common/interpolate_build_info_test.go b/builder/amazon/common/interpolate_build_info_test.go index a29f82dac..a09490b4f 100644 --- a/builder/amazon/common/interpolate_build_info_test.go +++ b/builder/amazon/common/interpolate_build_info_test.go @@ -6,7 +6,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/builder" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/multistep" ) @@ -35,8 +35,8 @@ func testState() multistep.StateBag { return state } -func testGeneratedData(state multistep.StateBag) builder.GeneratedData { - generatedData := builder.GeneratedData{State: state} +func testGeneratedData(state multistep.StateBag) packerbuilderdata.GeneratedData { + generatedData := packerbuilderdata.GeneratedData{State: state} return generatedData } diff --git a/builder/amazon/common/step_modify_ami_attributes.go b/builder/amazon/common/step_modify_ami_attributes.go index 057650a51..e51bcda41 100644 --- a/builder/amazon/common/step_modify_ami_attributes.go +++ b/builder/amazon/common/step_modify_ami_attributes.go @@ -7,7 +7,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/builder" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" @@ -22,7 +22,7 @@ type StepModifyAMIAttributes struct { Description string Ctx interpolate.Context - GeneratedData *builder.GeneratedData + GeneratedData *packerbuilderdata.GeneratedData } func (s *StepModifyAMIAttributes) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { diff --git a/builder/amazon/common/step_set_generated_data.go b/builder/amazon/common/step_set_generated_data.go index e364390b0..50f0d15fc 100644 --- a/builder/amazon/common/step_set_generated_data.go +++ b/builder/amazon/common/step_set_generated_data.go @@ -4,7 +4,7 @@ import ( "context" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/builder" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/multistep" ) @@ -13,7 +13,7 @@ import ( // }, type StepSetGeneratedData struct { - GeneratedData *builder.GeneratedData + GeneratedData *packerbuilderdata.GeneratedData } func (s *StepSetGeneratedData) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { diff --git a/builder/amazon/common/tags.go b/builder/amazon/common/tags.go index 5b0a4d276..f15925134 100644 --- a/builder/amazon/common/tags.go +++ b/builder/amazon/common/tags.go @@ -5,7 +5,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/builder" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" @@ -23,7 +23,7 @@ func (t EC2Tags) Report(ui packer.Ui) { func (t TagMap) EC2Tags(ictx interpolate.Context, region string, state multistep.StateBag) (EC2Tags, error) { var ec2Tags []*ec2.Tag - generatedData := builder.GeneratedData{State: state} + generatedData := packerbuilderdata.GeneratedData{State: state} ictx.Data = extractBuildInfo(region, state, &generatedData) for key, value := range t { diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 4d4934c43..d5adadacb 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -15,9 +15,9 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/iam" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/builder" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/hcl2template" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" @@ -164,7 +164,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("awsSession", session) state.Put("hook", hook) state.Put("ui", ui) - generatedData := &builder.GeneratedData{State: state} + generatedData := &packerbuilderdata.GeneratedData{State: state} var instanceStep multistep.Step diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index c70026b3e..71faccd37 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -13,9 +13,9 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/iam" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/builder" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/hcl2template" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" @@ -187,7 +187,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("awsSession", session) state.Put("hook", hook) state.Put("ui", ui) - generatedData := &builder.GeneratedData{State: state} + generatedData := &packerbuilderdata.GeneratedData{State: state} var instanceStep multistep.Step diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index d3fb1a03f..34eb8a564 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -12,9 +12,9 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/iam" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/builder" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/hcl2template" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" @@ -168,7 +168,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("iam", iam) state.Put("hook", hook) state.Put("ui", ui) - generatedData := &builder.GeneratedData{State: state} + generatedData := &packerbuilderdata.GeneratedData{State: state} var instanceStep multistep.Step diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 7c050b88e..57b42d977 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -15,9 +15,9 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/aws/aws-sdk-go/service/iam" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/builder" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -250,7 +250,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("awsSession", session) state.Put("hook", hook) state.Put("ui", ui) - generatedData := &builder.GeneratedData{State: state} + generatedData := &packerbuilderdata.GeneratedData{State: state} var instanceStep multistep.Step diff --git a/builder/docker/builder.go b/builder/docker/builder.go index a3f807da4..3097007f2 100644 --- a/builder/docker/builder.go +++ b/builder/docker/builder.go @@ -5,8 +5,8 @@ import ( "log" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/builder" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -52,7 +52,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("config", &b.config) state.Put("hook", hook) state.Put("ui", ui) - generatedData := &builder.GeneratedData{State: state} + generatedData := &packerbuilderdata.GeneratedData{State: state} // Setup the driver that will talk to Docker state.Put("driver", driver) diff --git a/builder/docker/step_set_generated_data.go b/builder/docker/step_set_generated_data.go index 5ab9df8b9..ffe58420d 100644 --- a/builder/docker/step_set_generated_data.go +++ b/builder/docker/step_set_generated_data.go @@ -3,12 +3,12 @@ package docker import ( "context" - "github.com/hashicorp/packer/builder" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/multistep" ) type StepSetGeneratedData struct { - GeneratedData *builder.GeneratedData + GeneratedData *packerbuilderdata.GeneratedData } func (s *StepSetGeneratedData) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { diff --git a/builder/docker/step_set_generated_data_test.go b/builder/docker/step_set_generated_data_test.go index b1e5e2bea..370626c8e 100644 --- a/builder/docker/step_set_generated_data_test.go +++ b/builder/docker/step_set_generated_data_test.go @@ -4,14 +4,14 @@ import ( "context" "testing" - "github.com/hashicorp/packer/builder" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/multistep" ) func TestStepSetGeneratedData_Run(t *testing.T) { state := testState(t) step := new(StepSetGeneratedData) - step.GeneratedData = &builder.GeneratedData{State: state} + step.GeneratedData = &packerbuilderdata.GeneratedData{State: state} driver := state.Get("driver").(*MockDriver) driver.Sha256Result = "80B3BB1B1696E73A9B19DEEF92F664F8979F948DF348088B61F9A3477655AF64" state.Put("image_id", "12345") @@ -33,7 +33,7 @@ func TestStepSetGeneratedData_Run(t *testing.T) { // Image ID not implement state = testState(t) - step.GeneratedData = &builder.GeneratedData{State: state} + step.GeneratedData = &packerbuilderdata.GeneratedData{State: state} driver = state.Get("driver").(*MockDriver) notImplementedMsg := "ERR_IMAGE_SHA256_NOT_FOUND" diff --git a/builder/yandex/builder.go b/builder/yandex/builder.go index 481f7f57f..dec8446a8 100644 --- a/builder/yandex/builder.go +++ b/builder/yandex/builder.go @@ -6,8 +6,8 @@ import ( "github.com/google/uuid" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/builder" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -64,7 +64,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("sdk", driver.SDK()) state.Put("hook", hook) state.Put("ui", ui) - generatedData := &builder.GeneratedData{State: state} + generatedData := &packerbuilderdata.GeneratedData{State: state} // Build the steps steps := []multistep.Step{ diff --git a/builder/yandex/step_create_image.go b/builder/yandex/step_create_image.go index 40a0bf933..13f989b81 100644 --- a/builder/yandex/step_create_image.go +++ b/builder/yandex/step_create_image.go @@ -6,7 +6,7 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/builder" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -15,7 +15,7 @@ import ( ) type stepCreateImage struct { - GeneratedData *builder.GeneratedData + GeneratedData *packerbuilderdata.GeneratedData } func (s *stepCreateImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { diff --git a/builder/yandex/step_create_instance.go b/builder/yandex/step_create_instance.go index e89ba5269..df32eead5 100644 --- a/builder/yandex/step_create_instance.go +++ b/builder/yandex/step_create_instance.go @@ -7,7 +7,7 @@ import ( "io/ioutil" "github.com/c2h5oh/datasize" - "github.com/hashicorp/packer/builder" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/common/uuid" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -23,7 +23,7 @@ type StepCreateInstance struct { Debug bool SerialLogFile string - GeneratedData *builder.GeneratedData + GeneratedData *packerbuilderdata.GeneratedData } func createNetwork(ctx context.Context, c *Config, d Driver) (*vpc.Network, error) { diff --git a/builder/generated_data.go b/common/packerbuilderdata/generated_data.go similarity index 68% rename from builder/generated_data.go rename to common/packerbuilderdata/generated_data.go index 9b84c8d2a..de62677f6 100644 --- a/builder/generated_data.go +++ b/common/packerbuilderdata/generated_data.go @@ -1,7 +1,12 @@ -package builder +package packerbuilderdata import "github.com/hashicorp/packer/helper/multistep" +// This is used in the BasicPlaceholderData() func in the packer/provisioner.go +// To force users to access generated data via the "generated" func. +const PlaceholderMsg = "To set this dynamically in the Packer template, " + + "you must use the `build` function" + // GeneratedData manages variables exported by a builder after // it started. It uses the builder's multistep.StateBag internally, make sure it // is not nil before calling any functions. diff --git a/builder/generated_data_test.go b/common/packerbuilderdata/generated_data_test.go similarity index 97% rename from builder/generated_data_test.go rename to common/packerbuilderdata/generated_data_test.go index 09f673cc1..6cd5761f8 100644 --- a/builder/generated_data_test.go +++ b/common/packerbuilderdata/generated_data_test.go @@ -1,4 +1,4 @@ -package builder +package packerbuilderdata import ( "testing" diff --git a/helper/common/shared_state.go b/helper/common/shared_state.go deleted file mode 100644 index b75d9e091..000000000 --- a/helper/common/shared_state.go +++ /dev/null @@ -1,6 +0,0 @@ -package common - -// This is used in the BasicPlaceholderData() func in the packer/provisioner.go -// To force users to access generated data via the "generated" func. -const PlaceholderMsg = "To set this dynamically in the Packer template, " + - "you must use the `build` function" diff --git a/packer/build.go b/packer/build.go index 201922995..75d978e23 100644 --- a/packer/build.go +++ b/packer/build.go @@ -6,7 +6,7 @@ import ( "log" "sync" - "github.com/hashicorp/packer/helper/common" + "github.com/hashicorp/packer/common/packerbuilderdata" ) const ( @@ -182,7 +182,7 @@ func (b *CoreBuild) Prepare() (warn []string, err error) { if generatedVars != nil { for _, k := range generatedVars { generatedPlaceholderMap[k] = fmt.Sprintf("Build_%s. "+ - common.PlaceholderMsg, k) + packerbuilderdata.PlaceholderMsg, k) } } diff --git a/packer/build_test.go b/packer/build_test.go index dc1d698b6..308c2f03b 100644 --- a/packer/build_test.go +++ b/packer/build_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "github.com/hashicorp/packer/helper/common" + "github.com/hashicorp/packer/common/packerbuilderdata" ) func boolPointer(tf bool) *bool { @@ -214,7 +214,7 @@ func TestBuildPrepare_ProvisionerGetsGeneratedMap(t *testing.T) { } generated := BasicPlaceholderData() - generated["PartyVar"] = "Build_PartyVar. " + common.PlaceholderMsg + generated["PartyVar"] = "Build_PartyVar. " + packerbuilderdata.PlaceholderMsg if !reflect.DeepEqual(prov.PrepConfigs, []interface{}{42, packerConfig, generated}) { t.Fatalf("bad: %#v", prov.PrepConfigs) } diff --git a/packer/provisioner.go b/packer/provisioner.go index 834f7433f..9e34ccc1d 100644 --- a/packer/provisioner.go +++ b/packer/provisioner.go @@ -8,7 +8,7 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/helper/common" + "github.com/hashicorp/packer/common/packerbuilderdata" ) // A provisioner is responsible for installing and configuring software @@ -79,7 +79,7 @@ var BuilderDataCommonKeys = []string{ func BasicPlaceholderData() map[string]string { placeholderData := map[string]string{} for _, key := range BuilderDataCommonKeys { - placeholderData[key] = fmt.Sprintf("Build_%s. "+common.PlaceholderMsg, key) + placeholderData[key] = fmt.Sprintf("Build_%s. "+packerbuilderdata.PlaceholderMsg, key) } // Backwards-compatability: WinRM Password can get through without forcing diff --git a/post-processor/yandex-export/post-processor.go b/post-processor/yandex-export/post-processor.go index 3e995f480..c3d225e42 100644 --- a/post-processor/yandex-export/post-processor.go +++ b/post-processor/yandex-export/post-processor.go @@ -12,9 +12,9 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/builder" "github.com/hashicorp/packer/builder/yandex" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -210,7 +210,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact }, &yandex.StepCreateInstance{ Debug: p.config.PackerDebug, - GeneratedData: &builder.GeneratedData{State: state}, + GeneratedData: &packerbuilderdata.GeneratedData{State: state}, }, new(yandex.StepWaitCloudInitScript), new(yandex.StepTeardownInstance), diff --git a/template/interpolate/funcs.go b/template/interpolate/funcs.go index 8ec9b8c1f..d94be75d8 100644 --- a/template/interpolate/funcs.go +++ b/template/interpolate/funcs.go @@ -10,9 +10,9 @@ import ( "text/template" "time" + "github.com/hashicorp/packer/common/packerbuilderdata" commontpl "github.com/hashicorp/packer/common/template" "github.com/hashicorp/packer/common/uuid" - "github.com/hashicorp/packer/helper/common" "github.com/hashicorp/packer/version" strftime "github.com/jehiah/go-strftime" ) @@ -170,7 +170,7 @@ func passthroughOrInterpolate(data map[interface{}]interface{}, s string) (strin // If we're in the first interpolation pass, the goal is to // make sure that we pass the value through. // TODO match against an actual string constant - if strings.Contains(hp, common.PlaceholderMsg) { + if strings.Contains(hp, packerbuilderdata.PlaceholderMsg) { return fmt.Sprintf("{{.%s}}", s), nil } else { return hp, nil diff --git a/template/interpolate/funcs_test.go b/template/interpolate/funcs_test.go index 363ee9672..92bdd6117 100644 --- a/template/interpolate/funcs_test.go +++ b/template/interpolate/funcs_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/google/go-cmp/cmp" - "github.com/hashicorp/packer/helper/common" + "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/version" ) @@ -351,7 +351,7 @@ func TestFuncPackerBuild(t *testing.T) { }, // Data map is a map[string]string and contains value with placeholder. { - DataMap: map[string]string{"PartyVar": "PartyVal" + common.PlaceholderMsg}, + DataMap: map[string]string{"PartyVar": "PartyVal" + packerbuilderdata.PlaceholderMsg}, ErrExpected: false, Template: "{{ build `PartyVar` }}", OutVal: "{{.PartyVar}}", @@ -372,14 +372,14 @@ func TestFuncPackerBuild(t *testing.T) { }, // Data map is a map[interface{}]interface{} and contains value with placeholder. { - DataMap: map[interface{}]interface{}{"PartyVar": "PartyVal" + common.PlaceholderMsg}, + DataMap: map[interface{}]interface{}{"PartyVar": "PartyVal" + packerbuilderdata.PlaceholderMsg}, ErrExpected: false, Template: "{{ build `PartyVar` }}", OutVal: "{{.PartyVar}}", }, // Data map is a map[interface{}]interface{} and doesn't have value. { - DataMap: map[interface{}]interface{}{"BadVar": "PartyVal" + common.PlaceholderMsg}, + DataMap: map[interface{}]interface{}{"BadVar": "PartyVal" + packerbuilderdata.PlaceholderMsg}, ErrExpected: true, Template: "{{ build `MissingVar` }}", OutVal: "",