diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 5f7973723..08a7dad08 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -10,9 +10,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) // The unique ID for this builder diff --git a/builder/alicloud/ecs/packer_helper.go b/builder/alicloud/ecs/packer_helper.go index 2486b81cf..15f257381 100644 --- a/builder/alicloud/ecs/packer_helper.go +++ b/builder/alicloud/ecs/packer_helper.go @@ -3,8 +3,8 @@ package ecs import ( "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func message(state multistep.StateBag, module string) { diff --git a/builder/alicloud/ecs/ssh_helper.go b/builder/alicloud/ecs/ssh_helper.go index e08b3afff..aac733ece 100644 --- a/builder/alicloud/ecs/ssh_helper.go +++ b/builder/alicloud/ecs/ssh_helper.go @@ -7,7 +7,7 @@ import ( "time" packerssh "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" ) diff --git a/builder/alicloud/ecs/step_attach_keypair.go b/builder/alicloud/ecs/step_attach_keypair.go index b28de52b9..8fa2eedfb 100644 --- a/builder/alicloud/ecs/step_attach_keypair.go +++ b/builder/alicloud/ecs/step_attach_keypair.go @@ -1,20 +1,21 @@ package ecs import ( + "context" "fmt" "time" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepAttachKeyPar struct { } -func (s *stepAttachKeyPar) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepAttachKeyPar) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { keyPairName := state.Get("keyPair").(string) if keyPairName == "" { return multistep.ActionContinue diff --git a/builder/alicloud/ecs/step_check_source_image.go b/builder/alicloud/ecs/step_check_source_image.go index 4990f99d5..6090d8868 100644 --- a/builder/alicloud/ecs/step_check_source_image.go +++ b/builder/alicloud/ecs/step_check_source_image.go @@ -1,19 +1,20 @@ package ecs import ( + "context" "fmt" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepCheckAlicloudSourceImage struct { SourceECSImageId string } -func (s *stepCheckAlicloudSourceImage) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCheckAlicloudSourceImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) config := state.Get("config").(Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/alicloud/ecs/step_config_eip.go b/builder/alicloud/ecs/step_config_eip.go index b0845ba2a..c9446bc47 100644 --- a/builder/alicloud/ecs/step_config_eip.go +++ b/builder/alicloud/ecs/step_config_eip.go @@ -1,12 +1,13 @@ package ecs import ( + "context" "fmt" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type setpConfigAlicloudEIP struct { @@ -16,7 +17,7 @@ type setpConfigAlicloudEIP struct { allocatedId string } -func (s *setpConfigAlicloudEIP) Run(state multistep.StateBag) multistep.StepAction { +func (s *setpConfigAlicloudEIP) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) ui := state.Get("ui").(packer.Ui) instance := state.Get("instance").(*ecs.InstanceAttributesType) diff --git a/builder/alicloud/ecs/step_config_key_pair.go b/builder/alicloud/ecs/step_config_key_pair.go index 22ccd28b6..e49ae65fb 100644 --- a/builder/alicloud/ecs/step_config_key_pair.go +++ b/builder/alicloud/ecs/step_config_key_pair.go @@ -1,6 +1,7 @@ package ecs import ( + "context" "fmt" "io/ioutil" "os" @@ -8,8 +9,8 @@ import ( "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepConfigAlicloudKeyPair struct { @@ -24,7 +25,7 @@ type StepConfigAlicloudKeyPair struct { keyName string } -func (s *StepConfigAlicloudKeyPair) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepConfigAlicloudKeyPair) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if s.PrivateKeyFile != "" { diff --git a/builder/alicloud/ecs/step_config_public_ip.go b/builder/alicloud/ecs/step_config_public_ip.go index 65b7f3fe2..7e0a246e0 100644 --- a/builder/alicloud/ecs/step_config_public_ip.go +++ b/builder/alicloud/ecs/step_config_public_ip.go @@ -1,11 +1,12 @@ package ecs import ( + "context" "fmt" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepConfigAlicloudPublicIP struct { @@ -13,7 +14,7 @@ type stepConfigAlicloudPublicIP struct { RegionId string } -func (s *stepConfigAlicloudPublicIP) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepConfigAlicloudPublicIP) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) ui := state.Get("ui").(packer.Ui) instance := state.Get("instance").(*ecs.InstanceAttributesType) diff --git a/builder/alicloud/ecs/step_config_security_group.go b/builder/alicloud/ecs/step_config_security_group.go index dc8c083b2..951f6e6fe 100644 --- a/builder/alicloud/ecs/step_config_security_group.go +++ b/builder/alicloud/ecs/step_config_security_group.go @@ -1,14 +1,15 @@ package ecs import ( + "context" "errors" "fmt" "time" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepConfigAlicloudSecurityGroup struct { @@ -20,7 +21,7 @@ type stepConfigAlicloudSecurityGroup struct { isCreate bool } -func (s *stepConfigAlicloudSecurityGroup) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepConfigAlicloudSecurityGroup) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) ui := state.Get("ui").(packer.Ui) networkType := state.Get("networktype").(InstanceNetWork) diff --git a/builder/alicloud/ecs/step_config_vpc.go b/builder/alicloud/ecs/step_config_vpc.go index c4bdd59a3..36d52838f 100644 --- a/builder/alicloud/ecs/step_config_vpc.go +++ b/builder/alicloud/ecs/step_config_vpc.go @@ -1,14 +1,15 @@ package ecs import ( + "context" "errors" "fmt" "time" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepConfigAlicloudVPC struct { @@ -18,7 +19,7 @@ type stepConfigAlicloudVPC struct { isCreate bool } -func (s *stepConfigAlicloudVPC) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepConfigAlicloudVPC) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(Config) client := state.Get("client").(*ecs.Client) ui := state.Get("ui").(packer.Ui) diff --git a/builder/alicloud/ecs/step_config_vswitch.go b/builder/alicloud/ecs/step_config_vswitch.go index dfa858d0b..c1494e9d0 100644 --- a/builder/alicloud/ecs/step_config_vswitch.go +++ b/builder/alicloud/ecs/step_config_vswitch.go @@ -1,14 +1,15 @@ package ecs import ( + "context" "errors" "fmt" "time" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepConfigAlicloudVSwitch struct { @@ -19,7 +20,7 @@ type stepConfigAlicloudVSwitch struct { VSwitchName string } -func (s *stepConfigAlicloudVSwitch) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepConfigAlicloudVSwitch) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) ui := state.Get("ui").(packer.Ui) vpcId := state.Get("vpcid").(string) diff --git a/builder/alicloud/ecs/step_create_image.go b/builder/alicloud/ecs/step_create_image.go index 5060c78ca..ae5840c09 100644 --- a/builder/alicloud/ecs/step_create_image.go +++ b/builder/alicloud/ecs/step_create_image.go @@ -1,19 +1,20 @@ package ecs import ( + "context" "fmt" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepCreateAlicloudImage struct { image *ecs.ImageType } -func (s *stepCreateAlicloudImage) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateAlicloudImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(Config) client := state.Get("client").(*ecs.Client) ui := state.Get("ui").(packer.Ui) diff --git a/builder/alicloud/ecs/step_create_instance.go b/builder/alicloud/ecs/step_create_instance.go index c4f33f19c..5001fe4df 100644 --- a/builder/alicloud/ecs/step_create_instance.go +++ b/builder/alicloud/ecs/step_create_instance.go @@ -1,14 +1,15 @@ package ecs import ( + "context" "fmt" "io/ioutil" "log" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepCreateAlicloudInstance struct { @@ -25,7 +26,7 @@ type stepCreateAlicloudInstance struct { instance *ecs.InstanceAttributesType } -func (s *stepCreateAlicloudInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateAlicloudInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) config := state.Get("config").(Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/alicloud/ecs/step_delete_images_snapshots.go b/builder/alicloud/ecs/step_delete_images_snapshots.go index 24104fef0..d3f6139f0 100644 --- a/builder/alicloud/ecs/step_delete_images_snapshots.go +++ b/builder/alicloud/ecs/step_delete_images_snapshots.go @@ -1,13 +1,14 @@ package ecs import ( + "context" "fmt" "log" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepDeleteAlicloudImageSnapshots struct { @@ -16,7 +17,7 @@ type stepDeleteAlicloudImageSnapshots struct { AlicloudImageName string } -func (s *stepDeleteAlicloudImageSnapshots) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepDeleteAlicloudImageSnapshots) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) ui := state.Get("ui").(packer.Ui) config := state.Get("config").(Config) diff --git a/builder/alicloud/ecs/step_mount_disk.go b/builder/alicloud/ecs/step_mount_disk.go index 222b27f08..642605bee 100644 --- a/builder/alicloud/ecs/step_mount_disk.go +++ b/builder/alicloud/ecs/step_mount_disk.go @@ -1,17 +1,18 @@ package ecs import ( + "context" "fmt" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepMountAlicloudDisk struct { } -func (s *stepMountAlicloudDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepMountAlicloudDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) config := state.Get("config").(Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/alicloud/ecs/step_pre_validate.go b/builder/alicloud/ecs/step_pre_validate.go index 527d84fbf..6bc3b1060 100644 --- a/builder/alicloud/ecs/step_pre_validate.go +++ b/builder/alicloud/ecs/step_pre_validate.go @@ -1,12 +1,13 @@ package ecs import ( + "context" "fmt" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepPreValidate struct { @@ -14,7 +15,7 @@ type stepPreValidate struct { ForceDelete bool } -func (s *stepPreValidate) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepPreValidate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if s.ForceDelete { ui.Say("Force delete flag found, skipping prevalidating image name.") diff --git a/builder/alicloud/ecs/step_region_copy_image.go b/builder/alicloud/ecs/step_region_copy_image.go index f92878712..dddf08488 100644 --- a/builder/alicloud/ecs/step_region_copy_image.go +++ b/builder/alicloud/ecs/step_region_copy_image.go @@ -1,12 +1,13 @@ package ecs import ( + "context" "fmt" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type setpRegionCopyAlicloudImage struct { @@ -15,7 +16,7 @@ type setpRegionCopyAlicloudImage struct { RegionId string } -func (s *setpRegionCopyAlicloudImage) Run(state multistep.StateBag) multistep.StepAction { +func (s *setpRegionCopyAlicloudImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { if len(s.AlicloudImageDestinationRegions) == 0 { return multistep.ActionContinue } diff --git a/builder/alicloud/ecs/step_run_instance.go b/builder/alicloud/ecs/step_run_instance.go index a92637648..72491dd1d 100644 --- a/builder/alicloud/ecs/step_run_instance.go +++ b/builder/alicloud/ecs/step_run_instance.go @@ -1,17 +1,18 @@ package ecs import ( + "context" "fmt" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepRunAlicloudInstance struct { } -func (s *stepRunAlicloudInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepRunAlicloudInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) ui := state.Get("ui").(packer.Ui) instance := state.Get("instance").(*ecs.InstanceAttributesType) diff --git a/builder/alicloud/ecs/step_share_image.go b/builder/alicloud/ecs/step_share_image.go index 50e5a640f..f954eb421 100644 --- a/builder/alicloud/ecs/step_share_image.go +++ b/builder/alicloud/ecs/step_share_image.go @@ -1,12 +1,13 @@ package ecs import ( + "context" "fmt" "github.com/denverdino/aliyungo/common" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type setpShareAlicloudImage struct { @@ -15,7 +16,7 @@ type setpShareAlicloudImage struct { RegionId string } -func (s *setpShareAlicloudImage) Run(state multistep.StateBag) multistep.StepAction { +func (s *setpShareAlicloudImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) ui := state.Get("ui").(packer.Ui) alicloudImages := state.Get("alicloudimages").(map[string]string) diff --git a/builder/alicloud/ecs/step_stop_instance.go b/builder/alicloud/ecs/step_stop_instance.go index b12a74c63..d57a52c12 100644 --- a/builder/alicloud/ecs/step_stop_instance.go +++ b/builder/alicloud/ecs/step_stop_instance.go @@ -1,18 +1,19 @@ package ecs import ( + "context" "fmt" "github.com/denverdino/aliyungo/ecs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepStopAlicloudInstance struct { ForceStop bool } -func (s *stepStopAlicloudInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepStopAlicloudInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*ecs.Client) instance := state.Get("instance").(*ecs.InstanceAttributesType) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 80d6ae1b9..607ad06a9 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -13,9 +13,9 @@ import ( awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) // The unique ID for this builder diff --git a/builder/amazon/chroot/cleanup.go b/builder/amazon/chroot/cleanup.go index 0be3bef3f..0befac174 100644 --- a/builder/amazon/chroot/cleanup.go +++ b/builder/amazon/chroot/cleanup.go @@ -1,7 +1,7 @@ package chroot import ( - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) // Cleanup is an interface that some steps implement for early cleanup. diff --git a/builder/amazon/chroot/step_attach_volume.go b/builder/amazon/chroot/step_attach_volume.go index 6b83f440b..01ab32464 100644 --- a/builder/amazon/chroot/step_attach_volume.go +++ b/builder/amazon/chroot/step_attach_volume.go @@ -1,6 +1,7 @@ package chroot import ( + "context" "errors" "fmt" "strings" @@ -8,8 +9,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepAttachVolume attaches the previously created volume to an @@ -23,7 +24,7 @@ type StepAttachVolume struct { volumeId string } -func (s *StepAttachVolume) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepAttachVolume) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) device := state.Get("device").(string) instance := state.Get("instance").(*ec2.Instance) diff --git a/builder/amazon/chroot/step_check_root_device.go b/builder/amazon/chroot/step_check_root_device.go index fa0097aa4..5ff66d055 100644 --- a/builder/amazon/chroot/step_check_root_device.go +++ b/builder/amazon/chroot/step_check_root_device.go @@ -1,17 +1,18 @@ package chroot import ( + "context" "fmt" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCheckRootDevice makes sure the root device on the AMI is EBS-backed. type StepCheckRootDevice struct{} -func (s *StepCheckRootDevice) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCheckRootDevice) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { image := state.Get("source_image").(*ec2.Image) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/chroot/step_chroot_provision.go b/builder/amazon/chroot/step_chroot_provision.go index 941e071b1..be8667077 100644 --- a/builder/amazon/chroot/step_chroot_provision.go +++ b/builder/amazon/chroot/step_chroot_provision.go @@ -1,17 +1,18 @@ package chroot import ( + "context" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepChrootProvision provisions the instance within a chroot. type StepChrootProvision struct { } -func (s *StepChrootProvision) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepChrootProvision) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { hook := state.Get("hook").(packer.Hook) mountPath := state.Get("mount_path").(string) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/chroot/step_copy_files.go b/builder/amazon/chroot/step_copy_files.go index e5c8e2215..a973a5d81 100644 --- a/builder/amazon/chroot/step_copy_files.go +++ b/builder/amazon/chroot/step_copy_files.go @@ -2,12 +2,13 @@ package chroot import ( "bytes" + "context" "fmt" "log" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCopyFiles copies some files from the host into the chroot environment. @@ -19,7 +20,7 @@ type StepCopyFiles struct { files []string } -func (s *StepCopyFiles) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCopyFiles) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) mountPath := state.Get("mount_path").(string) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/chroot/step_create_volume.go b/builder/amazon/chroot/step_create_volume.go index c1ecbf1a9..b3c205b26 100644 --- a/builder/amazon/chroot/step_create_volume.go +++ b/builder/amazon/chroot/step_create_volume.go @@ -1,14 +1,15 @@ package chroot import ( + "context" "fmt" "log" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCreateVolume creates a new volume from the snapshot of the root @@ -21,7 +22,7 @@ type StepCreateVolume struct { RootVolumeSize int64 } -func (s *StepCreateVolume) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateVolume) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ec2conn := state.Get("ec2").(*ec2.EC2) instance := state.Get("instance").(*ec2.Instance) diff --git a/builder/amazon/chroot/step_early_cleanup.go b/builder/amazon/chroot/step_early_cleanup.go index ebbf3a0ed..34e7817df 100644 --- a/builder/amazon/chroot/step_early_cleanup.go +++ b/builder/amazon/chroot/step_early_cleanup.go @@ -1,18 +1,19 @@ package chroot import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepEarlyCleanup performs some of the cleanup steps early in order to // prepare for snapshotting and creating an AMI. type StepEarlyCleanup struct{} -func (s *StepEarlyCleanup) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepEarlyCleanup) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) cleanupKeys := []string{ "copy_files_cleanup", diff --git a/builder/amazon/chroot/step_early_unflock.go b/builder/amazon/chroot/step_early_unflock.go index b1399c167..225e91fb9 100644 --- a/builder/amazon/chroot/step_early_unflock.go +++ b/builder/amazon/chroot/step_early_unflock.go @@ -1,17 +1,18 @@ package chroot import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepEarlyUnflock unlocks the flock. type StepEarlyUnflock struct{} -func (s *StepEarlyUnflock) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepEarlyUnflock) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { cleanup := state.Get("flock_cleanup").(Cleanup) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/chroot/step_flock.go b/builder/amazon/chroot/step_flock.go index 711b2581e..d75adc7f0 100644 --- a/builder/amazon/chroot/step_flock.go +++ b/builder/amazon/chroot/step_flock.go @@ -1,13 +1,14 @@ package chroot import ( + "context" "fmt" "log" "os" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepFlock provisions the instance within a chroot. @@ -18,7 +19,7 @@ type StepFlock struct { fh *os.File } -func (s *StepFlock) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepFlock) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) lockfile := "/var/lock/packer-chroot/lock" diff --git a/builder/amazon/chroot/step_instance_info.go b/builder/amazon/chroot/step_instance_info.go index 652808952..558e28a8d 100644 --- a/builder/amazon/chroot/step_instance_info.go +++ b/builder/amazon/chroot/step_instance_info.go @@ -1,20 +1,21 @@ package chroot import ( + "context" "fmt" "log" "github.com/aws/aws-sdk-go/aws/ec2metadata" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepInstanceInfo verifies that this builder is running on an EC2 instance. type StepInstanceInfo struct{} -func (s *StepInstanceInfo) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepInstanceInfo) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) session := state.Get("awsSession").(*session.Session) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/chroot/step_mount_device.go b/builder/amazon/chroot/step_mount_device.go index 8f740bd6e..f9fc7b0a8 100644 --- a/builder/amazon/chroot/step_mount_device.go +++ b/builder/amazon/chroot/step_mount_device.go @@ -2,6 +2,7 @@ package chroot import ( "bytes" + "context" "fmt" "log" "os" @@ -9,9 +10,9 @@ import ( "strings" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type mountPathData struct { @@ -30,7 +31,7 @@ type StepMountDevice struct { mountPath string } -func (s *StepMountDevice) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepMountDevice) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) device := state.Get("device").(string) diff --git a/builder/amazon/chroot/step_mount_extra.go b/builder/amazon/chroot/step_mount_extra.go index fb62467ba..ffd8ac027 100644 --- a/builder/amazon/chroot/step_mount_extra.go +++ b/builder/amazon/chroot/step_mount_extra.go @@ -2,13 +2,14 @@ package chroot import ( "bytes" + "context" "fmt" "os" "os/exec" "syscall" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepMountExtra mounts the attached device. @@ -19,7 +20,7 @@ type StepMountExtra struct { mounts []string } -func (s *StepMountExtra) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepMountExtra) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) mountPath := state.Get("mount_path").(string) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/chroot/step_post_mount_commands.go b/builder/amazon/chroot/step_post_mount_commands.go index de927f9aa..a00e8e1bf 100644 --- a/builder/amazon/chroot/step_post_mount_commands.go +++ b/builder/amazon/chroot/step_post_mount_commands.go @@ -1,8 +1,10 @@ package chroot import ( + "context" + + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type postMountCommandsData struct { @@ -16,7 +18,7 @@ type StepPostMountCommands struct { Commands []string } -func (s *StepPostMountCommands) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepPostMountCommands) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) device := state.Get("device").(string) mountPath := state.Get("mount_path").(string) diff --git a/builder/amazon/chroot/step_pre_mount_commands.go b/builder/amazon/chroot/step_pre_mount_commands.go index 63aa6d15a..ce3c26e02 100644 --- a/builder/amazon/chroot/step_pre_mount_commands.go +++ b/builder/amazon/chroot/step_pre_mount_commands.go @@ -1,8 +1,10 @@ package chroot import ( + "context" + + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type preMountCommandsData struct { @@ -14,7 +16,7 @@ type StepPreMountCommands struct { Commands []string } -func (s *StepPreMountCommands) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepPreMountCommands) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) device := state.Get("device").(string) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/chroot/step_prepare_device.go b/builder/amazon/chroot/step_prepare_device.go index 6cbefb2cc..0939d33cd 100644 --- a/builder/amazon/chroot/step_prepare_device.go +++ b/builder/amazon/chroot/step_prepare_device.go @@ -1,19 +1,20 @@ package chroot import ( + "context" "fmt" "log" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepPrepareDevice finds an available device and sets it. type StepPrepareDevice struct { } -func (s *StepPrepareDevice) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepPrepareDevice) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/chroot/step_register_ami.go b/builder/amazon/chroot/step_register_ami.go index a19266f57..6fa9838b0 100644 --- a/builder/amazon/chroot/step_register_ami.go +++ b/builder/amazon/chroot/step_register_ami.go @@ -1,13 +1,14 @@ package chroot import ( + "context" "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepRegisterAMI creates the AMI. @@ -17,7 +18,7 @@ type StepRegisterAMI struct { EnableAMISriovNetSupport bool } -func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRegisterAMI) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ec2conn := state.Get("ec2").(*ec2.EC2) snapshotId := state.Get("snapshot_id").(string) diff --git a/builder/amazon/chroot/step_snapshot.go b/builder/amazon/chroot/step_snapshot.go index 5cd646662..3fb3ff701 100644 --- a/builder/amazon/chroot/step_snapshot.go +++ b/builder/amazon/chroot/step_snapshot.go @@ -1,14 +1,15 @@ package chroot import ( + "context" "errors" "fmt" "time" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepSnapshot creates a snapshot of the created volume. @@ -19,7 +20,7 @@ type StepSnapshot struct { snapshotId string } -func (s *StepSnapshot) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepSnapshot) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) ui := state.Get("ui").(packer.Ui) volumeId := state.Get("volume_id").(string) diff --git a/builder/amazon/common/ssh.go b/builder/amazon/common/ssh.go index be414a8a0..086bc12ee 100644 --- a/builder/amazon/common/ssh.go +++ b/builder/amazon/common/ssh.go @@ -9,7 +9,7 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" packerssh "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" ) diff --git a/builder/amazon/common/ssh_test.go b/builder/amazon/common/ssh_test.go index e39088e67..02823d1d9 100644 --- a/builder/amazon/common/ssh_test.go +++ b/builder/amazon/common/ssh_test.go @@ -5,7 +5,7 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) const ( diff --git a/builder/amazon/common/state.go b/builder/amazon/common/state.go index 42beb0e00..4b5fe0d46 100644 --- a/builder/amazon/common/state.go +++ b/builder/amazon/common/state.go @@ -12,7 +12,7 @@ import ( "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) // StateRefreshFunc is a function type used for StateChangeConf that is diff --git a/builder/amazon/common/step_ami_region_copy.go b/builder/amazon/common/step_ami_region_copy.go index f98dcbb92..a3d92b467 100644 --- a/builder/amazon/common/step_ami_region_copy.go +++ b/builder/amazon/common/step_ami_region_copy.go @@ -1,14 +1,15 @@ package common import ( + "context" "fmt" "sync" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepAMIRegionCopy struct { @@ -19,7 +20,7 @@ type StepAMIRegionCopy struct { Name string } -func (s *StepAMIRegionCopy) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepAMIRegionCopy) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) ui := state.Get("ui").(packer.Ui) amis := state.Get("amis").(map[string]string) diff --git a/builder/amazon/common/step_create_tags.go b/builder/amazon/common/step_create_tags.go index d3183c7a7..47078b6ac 100644 --- a/builder/amazon/common/step_create_tags.go +++ b/builder/amazon/common/step_create_tags.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "github.com/aws/aws-sdk-go/aws" @@ -8,9 +9,9 @@ import ( "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ec2" retry "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type StepCreateTags struct { @@ -19,7 +20,7 @@ type StepCreateTags struct { Ctx interpolate.Context } -func (s *StepCreateTags) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateTags) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) session := state.Get("awsSession").(*session.Session) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/common/step_deregister_ami.go b/builder/amazon/common/step_deregister_ami.go index 188a40808..9c176d3c7 100644 --- a/builder/amazon/common/step_deregister_ami.go +++ b/builder/amazon/common/step_deregister_ami.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepDeregisterAMI struct { @@ -17,7 +18,7 @@ type StepDeregisterAMI struct { Regions []string } -func (s *StepDeregisterAMI) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepDeregisterAMI) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { // Check for force deregister if !s.ForceDeregister { return multistep.ActionContinue diff --git a/builder/amazon/common/step_encrypted_ami.go b/builder/amazon/common/step_encrypted_ami.go index 16c4ce7a8..a07c0ee25 100644 --- a/builder/amazon/common/step_encrypted_ami.go +++ b/builder/amazon/common/step_encrypted_ami.go @@ -1,13 +1,14 @@ package common import ( + "context" "fmt" "log" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepCreateEncryptedAMICopy struct { @@ -18,7 +19,7 @@ type StepCreateEncryptedAMICopy struct { AMIMappings []BlockDevice } -func (s *StepCreateEncryptedAMICopy) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateEncryptedAMICopy) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) ui := state.Get("ui").(packer.Ui) kmsKeyId := s.KeyID diff --git a/builder/amazon/common/step_get_password.go b/builder/amazon/common/step_get_password.go index b457658b9..5e2a236c2 100644 --- a/builder/amazon/common/step_get_password.go +++ b/builder/amazon/common/step_get_password.go @@ -1,6 +1,7 @@ package common import ( + "context" "crypto/rsa" "crypto/x509" "encoding/base64" @@ -12,8 +13,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepGetPassword reads the password from a Windows server and sets it @@ -24,7 +25,7 @@ type StepGetPassword struct { Timeout time.Duration } -func (s *StepGetPassword) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepGetPassword) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) // Skip if we're not using winrm diff --git a/builder/amazon/common/step_key_pair.go b/builder/amazon/common/step_key_pair.go index 68ce5af2d..927101fcf 100644 --- a/builder/amazon/common/step_key_pair.go +++ b/builder/amazon/common/step_key_pair.go @@ -1,14 +1,15 @@ package common import ( + "context" "fmt" "io/ioutil" "os" "runtime" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepKeyPair struct { @@ -22,7 +23,7 @@ type StepKeyPair struct { doCleanup bool } -func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if s.PrivateKeyFile != "" { diff --git a/builder/amazon/common/step_modify_ami_attributes.go b/builder/amazon/common/step_modify_ami_attributes.go index 295d98ce9..26ab31986 100644 --- a/builder/amazon/common/step_modify_ami_attributes.go +++ b/builder/amazon/common/step_modify_ami_attributes.go @@ -1,14 +1,15 @@ package common import ( + "context" "fmt" "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/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type StepModifyAMIAttributes struct { @@ -21,7 +22,7 @@ type StepModifyAMIAttributes struct { Ctx interpolate.Context } -func (s *StepModifyAMIAttributes) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepModifyAMIAttributes) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) session := state.Get("awsSession").(*session.Session) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/common/step_modify_ebs_instance.go b/builder/amazon/common/step_modify_ebs_instance.go index 12c2367aa..c2c454e06 100644 --- a/builder/amazon/common/step_modify_ebs_instance.go +++ b/builder/amazon/common/step_modify_ebs_instance.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepModifyEBSBackedInstance struct { @@ -14,7 +15,7 @@ type StepModifyEBSBackedInstance struct { EnableAMISriovNetSupport bool } -func (s *StepModifyEBSBackedInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepModifyEBSBackedInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) instance := state.Get("instance").(*ec2.Instance) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/common/step_pre_validate.go b/builder/amazon/common/step_pre_validate.go index 4c57cce0b..73b4022b7 100644 --- a/builder/amazon/common/step_pre_validate.go +++ b/builder/amazon/common/step_pre_validate.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepPreValidate provides an opportunity to pre-validate any configuration for @@ -17,7 +18,7 @@ type StepPreValidate struct { ForceDeregister bool } -func (s *StepPreValidate) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepPreValidate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if s.ForceDeregister { ui.Say("Force Deregister flag found, skipping prevalidating AMI Name") diff --git a/builder/amazon/common/step_run_source_instance.go b/builder/amazon/common/step_run_source_instance.go index aba0e9ab5..cc343961d 100644 --- a/builder/amazon/common/step_run_source_instance.go +++ b/builder/amazon/common/step_run_source_instance.go @@ -1,6 +1,7 @@ package common import ( + "context" "encoding/base64" "fmt" "io/ioutil" @@ -9,9 +10,9 @@ import ( "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type StepRunSourceInstance struct { @@ -35,7 +36,7 @@ type StepRunSourceInstance struct { instanceId string } -func (s *StepRunSourceInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRunSourceInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) var keyName string if name, ok := state.GetOk("keyPair"); ok { diff --git a/builder/amazon/common/step_run_spot_instance.go b/builder/amazon/common/step_run_spot_instance.go index 27938ece6..c5e3382ec 100644 --- a/builder/amazon/common/step_run_spot_instance.go +++ b/builder/amazon/common/step_run_spot_instance.go @@ -1,6 +1,7 @@ package common import ( + "context" "encoding/base64" "fmt" "io/ioutil" @@ -13,9 +14,9 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" retry "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type StepRunSpotInstance struct { @@ -42,7 +43,7 @@ type StepRunSpotInstance struct { spotRequest *ec2.SpotInstanceRequest } -func (s *StepRunSpotInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRunSpotInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) var keyName string if name, ok := state.GetOk("keyPair"); ok { diff --git a/builder/amazon/common/step_security_group.go b/builder/amazon/common/step_security_group.go index 8027903f5..031842cd3 100644 --- a/builder/amazon/common/step_security_group.go +++ b/builder/amazon/common/step_security_group.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "log" "time" @@ -10,8 +11,8 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/common/uuid" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepSecurityGroup struct { @@ -23,7 +24,7 @@ type StepSecurityGroup struct { createdGroupId string } -func (s *StepSecurityGroup) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepSecurityGroup) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/common/step_source_ami_info.go b/builder/amazon/common/step_source_ami_info.go index c7e9f733e..5e57c2fbf 100644 --- a/builder/amazon/common/step_source_ami_info.go +++ b/builder/amazon/common/step_source_ami_info.go @@ -1,14 +1,15 @@ package common import ( + "context" "fmt" "log" "sort" "time" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepSourceAMIInfo extracts critical information from the source AMI @@ -52,7 +53,7 @@ func mostRecentAmi(images []*ec2.Image) *ec2.Image { return sortedImages[len(sortedImages)-1] } -func (s *StepSourceAMIInfo) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepSourceAMIInfo) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/common/step_stop_ebs_instance.go b/builder/amazon/common/step_stop_ebs_instance.go index 7d6b2e943..10a2f5a45 100644 --- a/builder/amazon/common/step_stop_ebs_instance.go +++ b/builder/amazon/common/step_stop_ebs_instance.go @@ -1,13 +1,14 @@ package common import ( + "context" "fmt" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepStopEBSBackedInstance struct { @@ -15,7 +16,7 @@ type StepStopEBSBackedInstance struct { DisableStopInstance bool } -func (s *StepStopEBSBackedInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepStopEBSBackedInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) instance := state.Get("instance").(*ec2.Instance) ui := state.Get("ui").(packer.Ui) diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index e22901a74..44e14b695 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -14,9 +14,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) // The unique ID for this builder diff --git a/builder/amazon/ebs/step_cleanup_volumes.go b/builder/amazon/ebs/step_cleanup_volumes.go index d056f5457..3fd0de64f 100644 --- a/builder/amazon/ebs/step_cleanup_volumes.go +++ b/builder/amazon/ebs/step_cleanup_volumes.go @@ -1,13 +1,14 @@ package ebs import ( + "context" "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/packer/builder/amazon/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // stepCleanupVolumes cleans up any orphaned volumes that were not designated to @@ -17,7 +18,7 @@ type stepCleanupVolumes struct { BlockDevices common.BlockDevices } -func (s *stepCleanupVolumes) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCleanupVolumes) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { // stepCleanupVolumes is for Cleanup only return multistep.ActionContinue } diff --git a/builder/amazon/ebs/step_create_ami.go b/builder/amazon/ebs/step_create_ami.go index 9cb4bcee2..0dde4fc30 100644 --- a/builder/amazon/ebs/step_create_ami.go +++ b/builder/amazon/ebs/step_create_ami.go @@ -1,19 +1,20 @@ package ebs import ( + "context" "fmt" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepCreateAMI struct { image *ec2.Image } -func (s *stepCreateAMI) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateAMI) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(Config) ec2conn := state.Get("ec2").(*ec2.EC2) instance := state.Get("instance").(*ec2.Instance) diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index c622a4b73..6dba669d8 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -12,9 +12,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) const BuilderId = "mitchellh.amazon.ebssurrogate" diff --git a/builder/amazon/ebssurrogate/step_register_ami.go b/builder/amazon/ebssurrogate/step_register_ami.go index f0d145f35..002ed00af 100644 --- a/builder/amazon/ebssurrogate/step_register_ami.go +++ b/builder/amazon/ebssurrogate/step_register_ami.go @@ -1,13 +1,14 @@ package ebssurrogate import ( + "context" "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepRegisterAMI creates the AMI. @@ -19,7 +20,7 @@ type StepRegisterAMI struct { image *ec2.Image } -func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRegisterAMI) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ec2conn := state.Get("ec2").(*ec2.EC2) snapshotId := state.Get("snapshot_id").(string) diff --git a/builder/amazon/ebssurrogate/step_snapshot_new_root.go b/builder/amazon/ebssurrogate/step_snapshot_new_root.go index e00a75cdb..3b607fbd0 100644 --- a/builder/amazon/ebssurrogate/step_snapshot_new_root.go +++ b/builder/amazon/ebssurrogate/step_snapshot_new_root.go @@ -1,14 +1,15 @@ package ebssurrogate import ( + "context" "errors" "fmt" "time" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepSnapshotNewRootVolume creates a snapshot of the created volume. @@ -20,7 +21,7 @@ type StepSnapshotNewRootVolume struct { snapshotId string } -func (s *StepSnapshotNewRootVolume) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepSnapshotNewRootVolume) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) ui := state.Get("ui").(packer.Ui) instance := state.Get("instance").(*ec2.Instance) diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index b95af11f8..83fc271fb 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) const BuilderId = "mitchellh.amazon.ebsvolume" diff --git a/builder/amazon/ebsvolume/step_tag_ebs_volumes.go b/builder/amazon/ebsvolume/step_tag_ebs_volumes.go index 992459560..a638ec439 100644 --- a/builder/amazon/ebsvolume/step_tag_ebs_volumes.go +++ b/builder/amazon/ebsvolume/step_tag_ebs_volumes.go @@ -1,13 +1,14 @@ package ebsvolume import ( + "context" "fmt" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type stepTagEBSVolumes struct { @@ -15,7 +16,7 @@ type stepTagEBSVolumes struct { Ctx interpolate.Context } -func (s *stepTagEBSVolumes) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepTagEBSVolumes) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ec2conn := state.Get("ec2").(*ec2.EC2) instance := state.Get("instance").(*ec2.Instance) sourceAMI := state.Get("source_image").(*ec2.Image) diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index 776f4fc67..828733a9f 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -14,9 +14,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) // The unique ID for this builder diff --git a/builder/amazon/instance/step_bundle_volume.go b/builder/amazon/instance/step_bundle_volume.go index a8e27d635..1c8b006b8 100644 --- a/builder/amazon/instance/step_bundle_volume.go +++ b/builder/amazon/instance/step_bundle_volume.go @@ -1,12 +1,13 @@ package instance import ( + "context" "fmt" "github.com/aws/aws-sdk-go/service/ec2" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type bundleCmdData struct { @@ -23,7 +24,7 @@ type StepBundleVolume struct { Debug bool } -func (s *StepBundleVolume) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepBundleVolume) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) config := state.Get("config").(*Config) instance := state.Get("instance").(*ec2.Instance) diff --git a/builder/amazon/instance/step_register_ami.go b/builder/amazon/instance/step_register_ami.go index d363bdfdd..c46ff8ae4 100644 --- a/builder/amazon/instance/step_register_ami.go +++ b/builder/amazon/instance/step_register_ami.go @@ -1,13 +1,14 @@ package instance import ( + "context" "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/service/ec2" awscommon "github.com/hashicorp/packer/builder/amazon/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepRegisterAMI struct { @@ -15,7 +16,7 @@ type StepRegisterAMI struct { EnableAMISriovNetSupport bool } -func (s *StepRegisterAMI) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRegisterAMI) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ec2conn := state.Get("ec2").(*ec2.EC2) manifestPath := state.Get("remote_manifest_path").(string) diff --git a/builder/amazon/instance/step_upload_bundle.go b/builder/amazon/instance/step_upload_bundle.go index a38a77c93..1e7711d42 100644 --- a/builder/amazon/instance/step_upload_bundle.go +++ b/builder/amazon/instance/step_upload_bundle.go @@ -1,11 +1,12 @@ package instance import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type uploadCmdData struct { @@ -22,7 +23,7 @@ type StepUploadBundle struct { Debug bool } -func (s *StepUploadBundle) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepUploadBundle) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) config := state.Get("config").(*Config) manifestName := state.Get("manifest_name").(string) diff --git a/builder/amazon/instance/step_upload_x509_cert.go b/builder/amazon/instance/step_upload_x509_cert.go index dffcf4d2b..14ea955e5 100644 --- a/builder/amazon/instance/step_upload_x509_cert.go +++ b/builder/amazon/instance/step_upload_x509_cert.go @@ -1,16 +1,17 @@ package instance import ( + "context" "fmt" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepUploadX509Cert struct{} -func (s *StepUploadX509Cert) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepUploadX509Cert) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index d1f98bbd2..62afe6fa5 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -18,8 +18,8 @@ import ( "github.com/Azure/go-autorest/autorest/adal" packerCommon "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type Builder struct { diff --git a/builder/azure/arm/step.go b/builder/azure/arm/step.go index 707a1a07e..4ac33d1b5 100644 --- a/builder/azure/arm/step.go +++ b/builder/azure/arm/step.go @@ -3,7 +3,7 @@ package arm import ( "github.com/hashicorp/packer/builder/azure/common" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func processInterruptibleResult( diff --git a/builder/azure/arm/step_capture_image.go b/builder/azure/arm/step_capture_image.go index 10d29069e..9e640a891 100644 --- a/builder/azure/arm/step_capture_image.go +++ b/builder/azure/arm/step_capture_image.go @@ -1,13 +1,14 @@ package arm import ( + "context" "fmt" "github.com/Azure/azure-sdk-for-go/arm/compute" "github.com/hashicorp/packer/builder/azure/common" "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepCaptureImage struct { @@ -67,7 +68,7 @@ func (s *StepCaptureImage) captureImage(resourceGroupName string, computeName st return <-errChan } -func (s *StepCaptureImage) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCaptureImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { s.say("Capturing image ...") var computeName = state.Get(constants.ArmComputeName).(string) diff --git a/builder/azure/arm/step_capture_image_test.go b/builder/azure/arm/step_capture_image_test.go index 4527627a3..52bcbd1b7 100644 --- a/builder/azure/arm/step_capture_image_test.go +++ b/builder/azure/arm/step_capture_image_test.go @@ -1,12 +1,13 @@ package arm import ( + "context" "fmt" "testing" "github.com/Azure/azure-sdk-for-go/arm/compute" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepCaptureImageShouldFailIfCaptureFails(t *testing.T) { @@ -26,7 +27,7 @@ func TestStepCaptureImageShouldFailIfCaptureFails(t *testing.T) { stateBag := createTestStateBagStepCaptureImage() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -51,7 +52,7 @@ func TestStepCaptureImageShouldPassIfCapturePasses(t *testing.T) { stateBag := createTestStateBagStepCaptureImage() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -91,7 +92,7 @@ func TestStepCaptureImageShouldTakeStepArgumentsFromStateBag(t *testing.T) { } stateBag := createTestStateBagStepCaptureImage() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) diff --git a/builder/azure/arm/step_create_resource_group.go b/builder/azure/arm/step_create_resource_group.go index 934cb3225..e0535adf6 100644 --- a/builder/azure/arm/step_create_resource_group.go +++ b/builder/azure/arm/step_create_resource_group.go @@ -1,13 +1,14 @@ package arm import ( + "context" "errors" "fmt" "github.com/Azure/azure-sdk-for-go/arm/resources/resources" "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepCreateResourceGroup struct { @@ -51,7 +52,7 @@ func (s *StepCreateResourceGroup) doesResourceGroupExist(resourceGroupName strin return exists.Response.StatusCode != 404, err } -func (s *StepCreateResourceGroup) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateResourceGroup) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { var doubleResource, ok = state.GetOk(constants.ArmDoubleResourceGroupNameSet) if ok && doubleResource.(bool) { err := errors.New("You have filled in both temp_resource_group_name and build_resource_group_name. Please choose one.") diff --git a/builder/azure/arm/step_create_resource_group_test.go b/builder/azure/arm/step_create_resource_group_test.go index afd47cfef..3c4deeb03 100644 --- a/builder/azure/arm/step_create_resource_group_test.go +++ b/builder/azure/arm/step_create_resource_group_test.go @@ -1,12 +1,13 @@ package arm import ( + "context" "errors" "fmt" "testing" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepCreateResourceGroupShouldFailIfBothGroupNames(t *testing.T) { @@ -26,7 +27,7 @@ func TestStepCreateResourceGroupShouldFailIfBothGroupNames(t *testing.T) { error: func(e error) {}, exists: func(string) (bool, error) { return false, nil }, } - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -46,7 +47,7 @@ func TestStepCreateResourceGroupShouldFailIfCreateFails(t *testing.T) { stateBag := createTestStateBagStepCreateResourceGroup() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -66,7 +67,7 @@ func TestStepCreateResourceGroupShouldFailIfExistsFails(t *testing.T) { stateBag := createTestStateBagStepCreateResourceGroup() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -86,7 +87,7 @@ func TestStepCreateResourceGroupShouldPassIfCreatePasses(t *testing.T) { stateBag := createTestStateBagStepCreateResourceGroup() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -114,7 +115,7 @@ func TestStepCreateResourceGroupShouldTakeStepArgumentsFromStateBag(t *testing.T } stateBag := createTestStateBagStepCreateResourceGroup() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) @@ -152,7 +153,7 @@ func TestStepCreateResourceGroupMarkShouldFailIfTryingExistingButDoesntExist(t * stateBag := createTestExistingStateBagStepCreateResourceGroup() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -172,7 +173,7 @@ func TestStepCreateResourceGroupMarkShouldFailIfTryingTempButExist(t *testing.T) stateBag := createTestStateBagStepCreateResourceGroup() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } diff --git a/builder/azure/arm/step_delete_os_disk.go b/builder/azure/arm/step_delete_os_disk.go index 878c45cc6..723c87db0 100644 --- a/builder/azure/arm/step_delete_os_disk.go +++ b/builder/azure/arm/step_delete_os_disk.go @@ -1,6 +1,7 @@ package arm import ( + "context" "errors" "fmt" "net/url" @@ -8,8 +9,8 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepDeleteOSDisk struct { @@ -50,7 +51,7 @@ func (s *StepDeleteOSDisk) deleteManagedDisk(resourceGroupName string, imageName return err } -func (s *StepDeleteOSDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepDeleteOSDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { s.say("Deleting the temporary OS disk ...") var osDisk = state.Get(constants.ArmOSDiskVhd).(string) diff --git a/builder/azure/arm/step_delete_os_disk_test.go b/builder/azure/arm/step_delete_os_disk_test.go index 5a962dd8a..6c8b12550 100644 --- a/builder/azure/arm/step_delete_os_disk_test.go +++ b/builder/azure/arm/step_delete_os_disk_test.go @@ -1,12 +1,13 @@ package arm import ( + "context" "errors" "fmt" "testing" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepDeleteOSDiskShouldFailIfGetFails(t *testing.T) { @@ -19,7 +20,7 @@ func TestStepDeleteOSDiskShouldFailIfGetFails(t *testing.T) { stateBag := DeleteTestStateBagStepDeleteOSDisk("http://storage.blob.core.windows.net/images/pkrvm_os.vhd") - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -38,7 +39,7 @@ func TestStepDeleteOSDiskShouldPassIfGetPasses(t *testing.T) { stateBag := DeleteTestStateBagStepDeleteOSDisk("http://storage.blob.core.windows.net/images/pkrvm_os.vhd") - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -63,7 +64,7 @@ func TestStepDeleteOSDiskShouldTakeStepArgumentsFromStateBag(t *testing.T) { } stateBag := DeleteTestStateBagStepDeleteOSDisk("http://storage.blob.core.windows.net/images/pkrvm_os.vhd") - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) @@ -93,7 +94,7 @@ func TestStepDeleteOSDiskShouldHandleComplexStorageContainerNames(t *testing.T) } stateBag := DeleteTestStateBagStepDeleteOSDisk("http://storage.blob.core.windows.net/abc/def/pkrvm_os.vhd") - testSubject.Run(stateBag) + testSubject.Run(context.Background(), stateBag) if actualStorageContainerName != "abc" { t.Fatalf("Expected the storage container name to be 'abc/def', but found '%s'.", actualStorageContainerName) @@ -115,7 +116,7 @@ func TestStepDeleteOSDiskShouldFailIfVHDNameCannotBeURLParsed(t *testing.T) { // Invalid URL per https://golang.org/src/net/url/url_test.go stateBag := DeleteTestStateBagStepDeleteOSDisk("http://[fe80::1%en0]/") - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%v'.", result) } @@ -134,7 +135,7 @@ func TestStepDeleteOSDiskShouldFailIfVHDNameIsTooShort(t *testing.T) { stateBag := DeleteTestStateBagStepDeleteOSDisk("storage.blob.core.windows.net/abc") - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -157,7 +158,7 @@ func TestStepDeleteOSDiskShouldPassIfManagedDiskInTempResourceGroup(t *testing.T stateBag.Put(constants.ArmIsExistingResourceGroup, false) stateBag.Put(constants.ArmResourceGroupName, "testgroup") - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -181,7 +182,7 @@ func TestStepDeleteOSDiskShouldFailIfManagedDiskInExistingResourceGroupFailsToDe stateBag.Put(constants.ArmIsExistingResourceGroup, true) stateBag.Put(constants.ArmResourceGroupName, "testgroup") - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -205,7 +206,7 @@ func TestStepDeleteOSDiskShouldFailIfManagedDiskInExistingResourceGroupIsDeleted stateBag.Put(constants.ArmIsExistingResourceGroup, true) stateBag.Put(constants.ArmResourceGroupName, "testgroup") - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } diff --git a/builder/azure/arm/step_delete_resource_group.go b/builder/azure/arm/step_delete_resource_group.go index c3db6de0a..a16ebf8f2 100644 --- a/builder/azure/arm/step_delete_resource_group.go +++ b/builder/azure/arm/step_delete_resource_group.go @@ -1,13 +1,14 @@ package arm import ( + "context" "fmt" "github.com/Azure/go-autorest/autorest" "github.com/hashicorp/packer/builder/azure/common" "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const ( @@ -117,7 +118,7 @@ func (s *StepDeleteResourceGroup) reportIfError(err error, resourceName string) } } -func (s *StepDeleteResourceGroup) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepDeleteResourceGroup) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { s.say("Deleting resource group ...") var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) diff --git a/builder/azure/arm/step_delete_resource_group_test.go b/builder/azure/arm/step_delete_resource_group_test.go index c9d6e22da..823f1f6ac 100644 --- a/builder/azure/arm/step_delete_resource_group_test.go +++ b/builder/azure/arm/step_delete_resource_group_test.go @@ -1,11 +1,12 @@ package arm import ( + "context" "fmt" "testing" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepDeleteResourceGroupShouldFailIfDeleteFails(t *testing.T) { @@ -17,7 +18,7 @@ func TestStepDeleteResourceGroupShouldFailIfDeleteFails(t *testing.T) { stateBag := DeleteTestStateBagStepDeleteResourceGroup() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -36,7 +37,7 @@ func TestStepDeleteResourceGroupShouldPassIfDeletePasses(t *testing.T) { stateBag := DeleteTestStateBagStepDeleteResourceGroup() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -56,7 +57,7 @@ func TestStepDeleteResourceGroupShouldDeleteStateBagArmResourceGroupCreated(t *t } stateBag := DeleteTestStateBagStepDeleteResourceGroup() - testSubject.Run(stateBag) + testSubject.Run(context.Background(), stateBag) value, ok := stateBag.GetOk(constants.ArmIsResourceGroupCreated) if !ok { diff --git a/builder/azure/arm/step_deploy_template.go b/builder/azure/arm/step_deploy_template.go index 5978a8811..af838c301 100644 --- a/builder/azure/arm/step_deploy_template.go +++ b/builder/azure/arm/step_deploy_template.go @@ -1,6 +1,7 @@ package arm import ( + "context" "errors" "fmt" "net/url" @@ -9,8 +10,8 @@ import ( "github.com/Azure/go-autorest/autorest" "github.com/hashicorp/packer/builder/azure/common" "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepDeployTemplate struct { @@ -58,7 +59,7 @@ func (s *StepDeployTemplate) deployTemplate(resourceGroupName string, deployment return err } -func (s *StepDeployTemplate) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepDeployTemplate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { s.say("Deploying deployment template ...") var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) diff --git a/builder/azure/arm/step_deploy_template_test.go b/builder/azure/arm/step_deploy_template_test.go index 4250e9e0b..be60433f3 100644 --- a/builder/azure/arm/step_deploy_template_test.go +++ b/builder/azure/arm/step_deploy_template_test.go @@ -1,11 +1,12 @@ package arm import ( + "context" "fmt" "testing" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepDeployTemplateShouldFailIfDeployFails(t *testing.T) { @@ -19,7 +20,7 @@ func TestStepDeployTemplateShouldFailIfDeployFails(t *testing.T) { stateBag := createTestStateBagStepDeployTemplate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -38,7 +39,7 @@ func TestStepDeployTemplateShouldPassIfDeployPasses(t *testing.T) { stateBag := createTestStateBagStepDeployTemplate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -65,7 +66,7 @@ func TestStepDeployTemplateShouldTakeStepArgumentsFromStateBag(t *testing.T) { } stateBag := createTestStateBagStepValidateTemplate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) diff --git a/builder/azure/arm/step_get_certificate.go b/builder/azure/arm/step_get_certificate.go index b9126da36..784826771 100644 --- a/builder/azure/arm/step_get_certificate.go +++ b/builder/azure/arm/step_get_certificate.go @@ -1,12 +1,13 @@ package arm import ( + "context" "fmt" "time" "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepGetCertificate struct { @@ -39,7 +40,7 @@ func (s *StepGetCertificate) getCertificateUrl(keyVaultName string, secretName s return *secret.ID, err } -func (s *StepGetCertificate) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepGetCertificate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { s.say("Getting the certificate's URL ...") var keyVaultName = state.Get(constants.ArmKeyVaultName).(string) diff --git a/builder/azure/arm/step_get_certificate_test.go b/builder/azure/arm/step_get_certificate_test.go index 553806c5e..5ce807afe 100644 --- a/builder/azure/arm/step_get_certificate_test.go +++ b/builder/azure/arm/step_get_certificate_test.go @@ -1,11 +1,12 @@ package arm import ( + "context" "fmt" "testing" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepGetCertificateShouldFailIfGetFails(t *testing.T) { @@ -18,7 +19,7 @@ func TestStepGetCertificateShouldFailIfGetFails(t *testing.T) { stateBag := createTestStateBagStepGetCertificate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -38,7 +39,7 @@ func TestStepGetCertificateShouldPassIfGetPasses(t *testing.T) { stateBag := createTestStateBagStepGetCertificate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -65,7 +66,7 @@ func TestStepGetCertificateShouldTakeStepArgumentsFromStateBag(t *testing.T) { } stateBag := createTestStateBagStepGetCertificate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) diff --git a/builder/azure/arm/step_get_ip_address.go b/builder/azure/arm/step_get_ip_address.go index 2c8165b0b..ee28f3054 100644 --- a/builder/azure/arm/step_get_ip_address.go +++ b/builder/azure/arm/step_get_ip_address.go @@ -1,11 +1,12 @@ package arm import ( + "context" "fmt" "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type EndpointType int @@ -76,7 +77,7 @@ func (s *StepGetIPAddress) getPublicIPInPrivateNetwork(resourceGroupName string, return s.getPublicIP(resourceGroupName, ipAddressName, interfaceName) } -func (s *StepGetIPAddress) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepGetIPAddress) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { s.say("Getting the VM's IP address ...") var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) diff --git a/builder/azure/arm/step_get_ip_address_test.go b/builder/azure/arm/step_get_ip_address_test.go index 1403e9a51..e91678c3b 100644 --- a/builder/azure/arm/step_get_ip_address_test.go +++ b/builder/azure/arm/step_get_ip_address_test.go @@ -1,11 +1,12 @@ package arm import ( + "context" "fmt" "testing" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepGetIPAddressShouldFailIfGetFails(t *testing.T) { @@ -21,7 +22,7 @@ func TestStepGetIPAddressShouldFailIfGetFails(t *testing.T) { stateBag := createTestStateBagStepGetIPAddress() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -45,7 +46,7 @@ func TestStepGetIPAddressShouldPassIfGetPasses(t *testing.T) { stateBag := createTestStateBagStepGetIPAddress() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -77,7 +78,7 @@ func TestStepGetIPAddressShouldTakeStepArgumentsFromStateBag(t *testing.T) { } stateBag := createTestStateBagStepGetIPAddress() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) diff --git a/builder/azure/arm/step_get_os_disk.go b/builder/azure/arm/step_get_os_disk.go index 511ab5c51..5e32e0eea 100644 --- a/builder/azure/arm/step_get_os_disk.go +++ b/builder/azure/arm/step_get_os_disk.go @@ -1,14 +1,15 @@ package arm import ( + "context" "fmt" "github.com/Azure/azure-sdk-for-go/arm/compute" "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepGetOSDisk struct { @@ -37,7 +38,7 @@ func (s *StepGetOSDisk) queryCompute(resourceGroupName string, computeName strin return vm, err } -func (s *StepGetOSDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepGetOSDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { s.say("Querying the machine's properties ...") var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) diff --git a/builder/azure/arm/step_get_os_disk_test.go b/builder/azure/arm/step_get_os_disk_test.go index 2b3a4d5d6..070a3ec0a 100644 --- a/builder/azure/arm/step_get_os_disk_test.go +++ b/builder/azure/arm/step_get_os_disk_test.go @@ -1,6 +1,7 @@ package arm import ( + "context" "fmt" "testing" @@ -8,7 +9,7 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepGetOSDiskShouldFailIfGetFails(t *testing.T) { @@ -22,7 +23,7 @@ func TestStepGetOSDiskShouldFailIfGetFails(t *testing.T) { stateBag := createTestStateBagStepGetOSDisk() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -43,7 +44,7 @@ func TestStepGetOSDiskShouldPassIfGetPasses(t *testing.T) { stateBag := createTestStateBagStepGetOSDisk() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -69,7 +70,7 @@ func TestStepGetOSDiskShouldTakeValidateArgumentsFromStateBag(t *testing.T) { } stateBag := createTestStateBagStepGetOSDisk() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) diff --git a/builder/azure/arm/step_power_off_compute.go b/builder/azure/arm/step_power_off_compute.go index 931050e04..693348325 100644 --- a/builder/azure/arm/step_power_off_compute.go +++ b/builder/azure/arm/step_power_off_compute.go @@ -1,12 +1,13 @@ package arm import ( + "context" "fmt" "github.com/hashicorp/packer/builder/azure/common" "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepPowerOffCompute struct { @@ -37,7 +38,7 @@ func (s *StepPowerOffCompute) powerOffCompute(resourceGroupName string, computeN return err } -func (s *StepPowerOffCompute) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepPowerOffCompute) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { s.say("Powering off machine ...") var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) diff --git a/builder/azure/arm/step_power_off_compute_test.go b/builder/azure/arm/step_power_off_compute_test.go index 2dcdac7f6..45c7a1729 100644 --- a/builder/azure/arm/step_power_off_compute_test.go +++ b/builder/azure/arm/step_power_off_compute_test.go @@ -1,11 +1,12 @@ package arm import ( + "context" "fmt" "testing" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepPowerOffComputeShouldFailIfPowerOffFails(t *testing.T) { @@ -17,7 +18,7 @@ func TestStepPowerOffComputeShouldFailIfPowerOffFails(t *testing.T) { stateBag := createTestStateBagStepPowerOffCompute() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -36,7 +37,7 @@ func TestStepPowerOffComputeShouldPassIfPowerOffPasses(t *testing.T) { stateBag := createTestStateBagStepPowerOffCompute() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -62,7 +63,7 @@ func TestStepPowerOffComputeShouldTakeStepArgumentsFromStateBag(t *testing.T) { } stateBag := createTestStateBagStepPowerOffCompute() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) diff --git a/builder/azure/arm/step_set_certificate.go b/builder/azure/arm/step_set_certificate.go index 5e865b882..ef8832074 100644 --- a/builder/azure/arm/step_set_certificate.go +++ b/builder/azure/arm/step_set_certificate.go @@ -1,9 +1,11 @@ package arm import ( + "context" + "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepSetCertificate struct { @@ -22,7 +24,7 @@ func NewStepSetCertificate(config *Config, ui packer.Ui) *StepSetCertificate { return step } -func (s *StepSetCertificate) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepSetCertificate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { s.say("Setting the certificate's URL ...") var winRMCertificateUrl = state.Get(constants.ArmCertificateUrl).(string) diff --git a/builder/azure/arm/step_set_certificate_test.go b/builder/azure/arm/step_set_certificate_test.go index 1ad9b7dbe..387d620a9 100644 --- a/builder/azure/arm/step_set_certificate_test.go +++ b/builder/azure/arm/step_set_certificate_test.go @@ -1,10 +1,11 @@ package arm import ( + "context" "testing" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepSetCertificateShouldPassIfGetPasses(t *testing.T) { @@ -16,7 +17,7 @@ func TestStepSetCertificateShouldPassIfGetPasses(t *testing.T) { stateBag := createTestStateBagStepSetCertificate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -35,7 +36,7 @@ func TestStepSetCertificateShouldTakeStepArgumentsFromStateBag(t *testing.T) { } stateBag := createTestStateBagStepSetCertificate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) diff --git a/builder/azure/arm/step_test.go b/builder/azure/arm/step_test.go index cf89021c3..aa46455e0 100644 --- a/builder/azure/arm/step_test.go +++ b/builder/azure/arm/step_test.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/packer/builder/azure/common" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestProcessStepResultShouldContinueForNonErrors(t *testing.T) { diff --git a/builder/azure/arm/step_validate_template.go b/builder/azure/arm/step_validate_template.go index d2b98638b..92927de5a 100644 --- a/builder/azure/arm/step_validate_template.go +++ b/builder/azure/arm/step_validate_template.go @@ -1,11 +1,12 @@ package arm import ( + "context" "fmt" "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepValidateTemplate struct { @@ -43,7 +44,7 @@ func (s *StepValidateTemplate) validateTemplate(resourceGroupName string, deploy return err } -func (s *StepValidateTemplate) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepValidateTemplate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { s.say("Validating deployment template ...") var resourceGroupName = state.Get(constants.ArmResourceGroupName).(string) diff --git a/builder/azure/arm/step_validate_template_test.go b/builder/azure/arm/step_validate_template_test.go index a56030787..7e32625d1 100644 --- a/builder/azure/arm/step_validate_template_test.go +++ b/builder/azure/arm/step_validate_template_test.go @@ -1,11 +1,12 @@ package arm import ( + "context" "fmt" "testing" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepValidateTemplateShouldFailIfValidateFails(t *testing.T) { @@ -17,7 +18,7 @@ func TestStepValidateTemplateShouldFailIfValidateFails(t *testing.T) { stateBag := createTestStateBagStepValidateTemplate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionHalt { t.Fatalf("Expected the step to return 'ActionHalt', but got '%d'.", result) } @@ -36,7 +37,7 @@ func TestStepValidateTemplateShouldPassIfValidatePasses(t *testing.T) { stateBag := createTestStateBagStepValidateTemplate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) } @@ -62,7 +63,7 @@ func TestStepValidateTemplateShouldTakeStepArgumentsFromStateBag(t *testing.T) { } stateBag := createTestStateBagStepValidateTemplate() - var result = testSubject.Run(stateBag) + var result = testSubject.Run(context.Background(), stateBag) if result != multistep.ActionContinue { t.Fatalf("Expected the step to return 'ActionContinue', but got '%d'.", result) diff --git a/builder/azure/common/lin/ssh.go b/builder/azure/common/lin/ssh.go index 1600c2f4f..0987a04ea 100644 --- a/builder/azure/common/lin/ssh.go +++ b/builder/azure/common/lin/ssh.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/packer/builder/azure/common/constants" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "golang.org/x/crypto/ssh" ) diff --git a/builder/azure/common/lin/step_create_cert.go b/builder/azure/common/lin/step_create_cert.go index 6f6a685d3..da2cb5bf5 100644 --- a/builder/azure/common/lin/step_create_cert.go +++ b/builder/azure/common/lin/step_create_cert.go @@ -1,6 +1,7 @@ package lin import ( + "context" "crypto/rand" "crypto/rsa" "crypto/sha1" @@ -14,15 +15,15 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepCreateCert struct { TmpServiceName string } -func (s *StepCreateCert) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateCert) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) ui.Say("Creating temporary certificate...") diff --git a/builder/azure/common/lin/step_generalize_os.go b/builder/azure/common/lin/step_generalize_os.go index ba11a9def..cc62f4eec 100644 --- a/builder/azure/common/lin/step_generalize_os.go +++ b/builder/azure/common/lin/step_generalize_os.go @@ -2,18 +2,19 @@ package lin import ( "bytes" + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepGeneralizeOS struct { Command string } -func (s *StepGeneralizeOS) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepGeneralizeOS) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) comm := state.Get("communicator").(packer.Communicator) diff --git a/builder/azure/common/state_bag.go b/builder/azure/common/state_bag.go index a402518a1..57889c03f 100644 --- a/builder/azure/common/state_bag.go +++ b/builder/azure/common/state_bag.go @@ -1,6 +1,6 @@ package common -import "github.com/mitchellh/multistep" +import "github.com/hashicorp/packer/helper/multistep" func IsStateCancelled(stateBag multistep.StateBag) bool { _, ok := stateBag.GetOk(multistep.StateCancelled) diff --git a/builder/cloudstack/builder.go b/builder/cloudstack/builder.go index 27af37d17..6726b29f9 100644 --- a/builder/cloudstack/builder.go +++ b/builder/cloudstack/builder.go @@ -5,8 +5,8 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/xanzy/go-cloudstack/cloudstack" ) diff --git a/builder/cloudstack/ssh.go b/builder/cloudstack/ssh.go index 7a4c2fcba..e1c2ef846 100644 --- a/builder/cloudstack/ssh.go +++ b/builder/cloudstack/ssh.go @@ -6,7 +6,7 @@ import ( "os" packerssh "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" ) diff --git a/builder/cloudstack/step_configure_networking.go b/builder/cloudstack/step_configure_networking.go index d9a6a365c..ff37a540a 100644 --- a/builder/cloudstack/step_configure_networking.go +++ b/builder/cloudstack/step_configure_networking.go @@ -1,13 +1,14 @@ package cloudstack import ( + "context" "fmt" "math/rand" "strings" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -16,7 +17,7 @@ type stepSetupNetworking struct { publicPort int } -func (s *stepSetupNetworking) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepSetupNetworking) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/cloudstack/step_create_instance.go b/builder/cloudstack/step_create_instance.go index 3e37fad14..19f6a3c28 100644 --- a/builder/cloudstack/step_create_instance.go +++ b/builder/cloudstack/step_create_instance.go @@ -1,6 +1,7 @@ package cloudstack import ( + "context" "encoding/base64" "errors" "fmt" @@ -8,9 +9,9 @@ import ( "strings" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -27,7 +28,7 @@ type stepCreateInstance struct { } // Run executes the Packer build step that creates a CloudStack instance. -func (s *stepCreateInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/cloudstack/step_create_security_group.go b/builder/cloudstack/step_create_security_group.go index 1bf23100b..c42eec5d5 100644 --- a/builder/cloudstack/step_create_security_group.go +++ b/builder/cloudstack/step_create_security_group.go @@ -1,11 +1,12 @@ package cloudstack import ( + "context" "fmt" "github.com/hashicorp/packer/common/uuid" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -13,7 +14,7 @@ type stepCreateSecurityGroup struct { tempSG string } -func (s *stepCreateSecurityGroup) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateSecurityGroup) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/cloudstack/step_create_template.go b/builder/cloudstack/step_create_template.go index 18d6c1fb0..4afba8699 100644 --- a/builder/cloudstack/step_create_template.go +++ b/builder/cloudstack/step_create_template.go @@ -1,17 +1,18 @@ package cloudstack import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/xanzy/go-cloudstack/cloudstack" ) type stepCreateTemplate struct{} -func (s *stepCreateTemplate) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateTemplate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/cloudstack/step_keypair.go b/builder/cloudstack/step_keypair.go index 675994fc1..e1f002b76 100644 --- a/builder/cloudstack/step_keypair.go +++ b/builder/cloudstack/step_keypair.go @@ -1,13 +1,14 @@ package cloudstack import ( + "context" "fmt" "io/ioutil" "os" "runtime" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/xanzy/go-cloudstack/cloudstack" ) @@ -20,7 +21,7 @@ type stepKeypair struct { TemporaryKeyPairName string } -func (s *stepKeypair) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepKeypair) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if s.PrivateKeyFile != "" { diff --git a/builder/cloudstack/step_prepare_config.go b/builder/cloudstack/step_prepare_config.go index 4d6353c6a..644547018 100644 --- a/builder/cloudstack/step_prepare_config.go +++ b/builder/cloudstack/step_prepare_config.go @@ -1,18 +1,19 @@ package cloudstack import ( + "context" "fmt" "io/ioutil" "regexp" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/xanzy/go-cloudstack/cloudstack" ) type stepPrepareConfig struct{} -func (s *stepPrepareConfig) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepPrepareConfig) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/cloudstack/step_shutdown_instance.go b/builder/cloudstack/step_shutdown_instance.go index b090a5836..a7f07e8b2 100644 --- a/builder/cloudstack/step_shutdown_instance.go +++ b/builder/cloudstack/step_shutdown_instance.go @@ -1,16 +1,17 @@ package cloudstack import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/xanzy/go-cloudstack/cloudstack" ) type stepShutdownInstance struct{} -func (s *stepShutdownInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepShutdownInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*cloudstack.CloudStackClient) config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/digitalocean/builder.go b/builder/digitalocean/builder.go index 16d11ba29..d5e674d63 100644 --- a/builder/digitalocean/builder.go +++ b/builder/digitalocean/builder.go @@ -12,8 +12,8 @@ import ( "github.com/digitalocean/godo" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "golang.org/x/oauth2" ) diff --git a/builder/digitalocean/ssh.go b/builder/digitalocean/ssh.go index ebccb938a..2b5c4ef8d 100644 --- a/builder/digitalocean/ssh.go +++ b/builder/digitalocean/ssh.go @@ -5,7 +5,7 @@ import ( "golang.org/x/crypto/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func commHost(state multistep.StateBag) (string, error) { diff --git a/builder/digitalocean/step_create_droplet.go b/builder/digitalocean/step_create_droplet.go index ed2c7390d..d9c8976bf 100644 --- a/builder/digitalocean/step_create_droplet.go +++ b/builder/digitalocean/step_create_droplet.go @@ -7,15 +7,15 @@ import ( "io/ioutil" "github.com/digitalocean/godo" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepCreateDroplet struct { dropletId int } -func (s *stepCreateDroplet) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateDroplet) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) ui := state.Get("ui").(packer.Ui) c := state.Get("config").(Config) diff --git a/builder/digitalocean/step_create_ssh_key.go b/builder/digitalocean/step_create_ssh_key.go index d255ffde0..c03809ba2 100644 --- a/builder/digitalocean/step_create_ssh_key.go +++ b/builder/digitalocean/step_create_ssh_key.go @@ -13,8 +13,8 @@ import ( "github.com/digitalocean/godo" "github.com/hashicorp/packer/common/uuid" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "golang.org/x/crypto/ssh" ) @@ -25,7 +25,7 @@ type stepCreateSSHKey struct { keyId int } -func (s *stepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) ui := state.Get("ui").(packer.Ui) diff --git a/builder/digitalocean/step_droplet_info.go b/builder/digitalocean/step_droplet_info.go index 4d24bb899..5c4439749 100644 --- a/builder/digitalocean/step_droplet_info.go +++ b/builder/digitalocean/step_droplet_info.go @@ -5,13 +5,13 @@ import ( "fmt" "github.com/digitalocean/godo" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepDropletInfo struct{} -func (s *stepDropletInfo) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepDropletInfo) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) ui := state.Get("ui").(packer.Ui) c := state.Get("config").(Config) diff --git a/builder/digitalocean/step_power_off.go b/builder/digitalocean/step_power_off.go index aeded228a..3b7e8bdd0 100644 --- a/builder/digitalocean/step_power_off.go +++ b/builder/digitalocean/step_power_off.go @@ -6,13 +6,13 @@ import ( "log" "github.com/digitalocean/godo" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepPowerOff struct{} -func (s *stepPowerOff) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepPowerOff) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) c := state.Get("config").(Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/digitalocean/step_shutdown.go b/builder/digitalocean/step_shutdown.go index dfa47dc4a..98d6c0c75 100644 --- a/builder/digitalocean/step_shutdown.go +++ b/builder/digitalocean/step_shutdown.go @@ -7,13 +7,13 @@ import ( "time" "github.com/digitalocean/godo" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepShutdown struct{} -func (s *stepShutdown) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepShutdown) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) c := state.Get("config").(Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/digitalocean/step_snapshot.go b/builder/digitalocean/step_snapshot.go index eb91fdead..ec978c8bc 100644 --- a/builder/digitalocean/step_snapshot.go +++ b/builder/digitalocean/step_snapshot.go @@ -8,13 +8,13 @@ import ( "time" "github.com/digitalocean/godo" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepSnapshot struct{} -func (s *stepSnapshot) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepSnapshot) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*godo.Client) ui := state.Get("ui").(packer.Ui) c := state.Get("config").(Config) diff --git a/builder/docker/builder.go b/builder/docker/builder.go index c59456e80..ba58f61bb 100644 --- a/builder/docker/builder.go +++ b/builder/docker/builder.go @@ -5,8 +5,8 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const ( diff --git a/builder/docker/comm.go b/builder/docker/comm.go index 8af3d57ca..bda53e0a1 100644 --- a/builder/docker/comm.go +++ b/builder/docker/comm.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/packer/communicator/ssh" "github.com/hashicorp/packer/helper/communicator" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" gossh "golang.org/x/crypto/ssh" ) diff --git a/builder/docker/step_commit.go b/builder/docker/step_commit.go index 26455670c..d248ee64c 100644 --- a/builder/docker/step_commit.go +++ b/builder/docker/step_commit.go @@ -1,10 +1,11 @@ package docker import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCommit commits the container to a image. @@ -12,7 +13,7 @@ type StepCommit struct { imageId string } -func (s *StepCommit) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCommit) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) containerId := state.Get("container_id").(string) config := state.Get("config").(*Config) diff --git a/builder/docker/step_commit_test.go b/builder/docker/step_commit_test.go index dce1b1208..16548b069 100644 --- a/builder/docker/step_commit_test.go +++ b/builder/docker/step_commit_test.go @@ -1,10 +1,11 @@ package docker import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func testStepCommitState(t *testing.T) multistep.StateBag { @@ -26,7 +27,7 @@ func TestStepCommit(t *testing.T) { driver.CommitImageId = "bar" // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -56,7 +57,7 @@ func TestStepCommit_error(t *testing.T) { driver.CommitErr = errors.New("foo") // run the step - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/docker/step_connect_docker.go b/builder/docker/step_connect_docker.go index ecbe55c35..ef0222a91 100644 --- a/builder/docker/step_connect_docker.go +++ b/builder/docker/step_connect_docker.go @@ -1,16 +1,17 @@ package docker import ( + "context" "fmt" "os/exec" "strings" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) type StepConnectDocker struct{} -func (s *StepConnectDocker) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepConnectDocker) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) containerId := state.Get("container_id").(string) driver := state.Get("driver").(Driver) diff --git a/builder/docker/step_export.go b/builder/docker/step_export.go index 428055a48..138e0f00c 100644 --- a/builder/docker/step_export.go +++ b/builder/docker/step_export.go @@ -1,18 +1,19 @@ package docker import ( + "context" "fmt" "os" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepExport exports the container to a flat tar file. type StepExport struct{} -func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepExport) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) diff --git a/builder/docker/step_export_test.go b/builder/docker/step_export_test.go index f2d1a069c..aa3fd124b 100644 --- a/builder/docker/step_export_test.go +++ b/builder/docker/step_export_test.go @@ -2,12 +2,13 @@ package docker import ( "bytes" + "context" "errors" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func testStepExportState(t *testing.T) multistep.StateBag { @@ -39,7 +40,7 @@ func TestStepExport(t *testing.T) { driver.ExportReader = bytes.NewReader([]byte("data!")) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -84,7 +85,7 @@ func TestStepExport_error(t *testing.T) { driver.ExportError = errors.New("foo") // run the step - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/docker/step_pull.go b/builder/docker/step_pull.go index 6b1ac8935..fd011680e 100644 --- a/builder/docker/step_pull.go +++ b/builder/docker/step_pull.go @@ -1,16 +1,17 @@ package docker import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepPull struct{} -func (s *StepPull) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepPull) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/docker/step_pull_test.go b/builder/docker/step_pull_test.go index aaeff2b2a..b01b42107 100644 --- a/builder/docker/step_pull_test.go +++ b/builder/docker/step_pull_test.go @@ -1,10 +1,11 @@ package docker import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepPull_impl(t *testing.T) { @@ -20,7 +21,7 @@ func TestStepPull(t *testing.T) { driver := state.Get("driver").(*MockDriver) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -42,7 +43,7 @@ func TestStepPull_error(t *testing.T) { driver.PullError = errors.New("foo") // run the step - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -63,7 +64,7 @@ func TestStepPull_login(t *testing.T) { config.Login = true // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -92,7 +93,7 @@ func TestStepPull_noPull(t *testing.T) { driver := state.Get("driver").(*MockDriver) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } diff --git a/builder/docker/step_run.go b/builder/docker/step_run.go index 101788682..1d2ba6862 100644 --- a/builder/docker/step_run.go +++ b/builder/docker/step_run.go @@ -1,17 +1,18 @@ package docker import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepRun struct { containerId string } -func (s *StepRun) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRun) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) tempDir := state.Get("temp_dir").(string) diff --git a/builder/docker/step_run_test.go b/builder/docker/step_run_test.go index 8c5b08ea3..bc6639319 100644 --- a/builder/docker/step_run_test.go +++ b/builder/docker/step_run_test.go @@ -1,10 +1,11 @@ package docker import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func testStepRunState(t *testing.T) multistep.StateBag { @@ -27,7 +28,7 @@ func TestStepRun(t *testing.T) { driver.StartID = "foo" // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -74,7 +75,7 @@ func TestStepRun_error(t *testing.T) { driver.StartError = errors.New("foo") // run the step - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/docker/step_temp_dir.go b/builder/docker/step_temp_dir.go index c7312ce49..a5b1d6ade 100644 --- a/builder/docker/step_temp_dir.go +++ b/builder/docker/step_temp_dir.go @@ -1,12 +1,13 @@ package docker import ( + "context" "fmt" "io/ioutil" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepTempDir creates a temporary directory that we use in order to @@ -15,7 +16,7 @@ type StepTempDir struct { tempDir string } -func (s *StepTempDir) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepTempDir) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) ui.Say("Creating a temporary directory for sharing data...") diff --git a/builder/docker/step_temp_dir_test.go b/builder/docker/step_temp_dir_test.go index cc12932f3..e36d4fcff 100644 --- a/builder/docker/step_temp_dir_test.go +++ b/builder/docker/step_temp_dir_test.go @@ -1,12 +1,13 @@ package docker import ( + "context" "os" "path/filepath" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func TestStepTempDir_impl(t *testing.T) { @@ -24,7 +25,7 @@ func testStepTempDir_impl(t *testing.T) string { } // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } diff --git a/builder/docker/step_test.go b/builder/docker/step_test.go index 9eec9a5d8..0c7d56649 100644 --- a/builder/docker/step_test.go +++ b/builder/docker/step_test.go @@ -4,8 +4,8 @@ import ( "bytes" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testState(t *testing.T) multistep.StateBag { diff --git a/builder/file/builder.go b/builder/file/builder.go index 1ac87331c..f8b52e609 100644 --- a/builder/file/builder.go +++ b/builder/file/builder.go @@ -11,8 +11,8 @@ import ( "io/ioutil" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const BuilderId = "packer.file" diff --git a/builder/googlecompute/builder.go b/builder/googlecompute/builder.go index 589108348..c60117075 100644 --- a/builder/googlecompute/builder.go +++ b/builder/googlecompute/builder.go @@ -8,8 +8,8 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // The unique ID for this builder. diff --git a/builder/googlecompute/ssh.go b/builder/googlecompute/ssh.go index 5c224f0c6..bf704b13e 100644 --- a/builder/googlecompute/ssh.go +++ b/builder/googlecompute/ssh.go @@ -3,7 +3,7 @@ package googlecompute import ( "fmt" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "golang.org/x/crypto/ssh" ) diff --git a/builder/googlecompute/step_check_existing_image.go b/builder/googlecompute/step_check_existing_image.go index d5f2f5e73..ac11600e1 100644 --- a/builder/googlecompute/step_check_existing_image.go +++ b/builder/googlecompute/step_check_existing_image.go @@ -1,10 +1,11 @@ package googlecompute import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCheckExistingImage represents a Packer build step that checks if the @@ -12,7 +13,7 @@ import ( type StepCheckExistingImage int // Run executes the Packer build step that checks if the image already exists. -func (s *StepCheckExistingImage) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCheckExistingImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { c := state.Get("config").(*Config) d := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/googlecompute/step_check_existing_image_test.go b/builder/googlecompute/step_check_existing_image_test.go index 21f4ee6c2..d4b9a9541 100644 --- a/builder/googlecompute/step_check_existing_image_test.go +++ b/builder/googlecompute/step_check_existing_image_test.go @@ -1,9 +1,10 @@ package googlecompute import ( + "context" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepCheckExistingImage_impl(t *testing.T) { @@ -22,7 +23,7 @@ func TestStepCheckExistingImage(t *testing.T) { driver.ImageExistsResult = true // run the step - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/googlecompute/step_create_image.go b/builder/googlecompute/step_create_image.go index bcb840e78..72e6a06eb 100644 --- a/builder/googlecompute/step_create_image.go +++ b/builder/googlecompute/step_create_image.go @@ -1,12 +1,13 @@ package googlecompute import ( + "context" "errors" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCreateImage represents a Packer build step that creates GCE machine @@ -17,7 +18,7 @@ type StepCreateImage int // // The image is created from the persistent disk used by the instance. The // instance must be deleted and the disk retained before doing this step. -func (s *StepCreateImage) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/googlecompute/step_create_image_test.go b/builder/googlecompute/step_create_image_test.go index 639b25255..6f1121a9f 100644 --- a/builder/googlecompute/step_create_image_test.go +++ b/builder/googlecompute/step_create_image_test.go @@ -1,10 +1,11 @@ package googlecompute import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "github.com/stretchr/testify/assert" ) @@ -26,7 +27,7 @@ func TestStepCreateImage(t *testing.T) { d.CreateImageResultSizeGb = 100 // run the step - action := step.Run(state) + action := step.Run(context.Background(), state) assert.Equal(t, action, multistep.ActionContinue, "Step did not pass.") uncastImage, ok := state.GetOk("image") @@ -61,7 +62,7 @@ func TestStepCreateImage_errorOnChannel(t *testing.T) { driver.CreateImageErrCh = errCh // run the step - action := step.Run(state) + action := step.Run(context.Background(), state) assert.Equal(t, action, multistep.ActionHalt, "Step should not have passed.") _, ok := state.GetOk("error") assert.True(t, ok, "State should have an error.") diff --git a/builder/googlecompute/step_create_instance.go b/builder/googlecompute/step_create_instance.go index a4509354e..ee3b6643b 100644 --- a/builder/googlecompute/step_create_instance.go +++ b/builder/googlecompute/step_create_instance.go @@ -1,13 +1,14 @@ package googlecompute import ( + "context" "errors" "fmt" "io/ioutil" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCreateInstance represents a Packer build step that creates GCE instances. @@ -72,7 +73,7 @@ func getImage(c *Config, d Driver) (*Image, error) { } // Run executes the Packer build step that creates a GCE instance. -func (s *StepCreateInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { c := state.Get("config").(*Config) d := state.Get("driver").(Driver) sshPublicKey := state.Get("ssh_public_key").(string) diff --git a/builder/googlecompute/step_create_instance_test.go b/builder/googlecompute/step_create_instance_test.go index a9a91d692..f8196e3d0 100644 --- a/builder/googlecompute/step_create_instance_test.go +++ b/builder/googlecompute/step_create_instance_test.go @@ -1,12 +1,13 @@ package googlecompute import ( + "context" "errors" "strings" "testing" "time" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "github.com/stretchr/testify/assert" ) @@ -26,7 +27,7 @@ func TestStepCreateInstance(t *testing.T) { d.GetImageResult = StubImage("test-image", "test-project", []string{}, 100) // run the step - assert.Equal(t, step.Run(state), multistep.ActionContinue, "Step should have passed and continued.") + assert.Equal(t, step.Run(context.Background(), state), multistep.ActionContinue, "Step should have passed and continued.") // Verify state nameRaw, ok := state.GetOk("instance_name") @@ -67,7 +68,7 @@ func TestStepCreateInstance_fromFamily(t *testing.T) { d.GetImageResult = StubImage("test-image", "test-project", []string{}, 100) // run the step - assert.Equal(t, step.Run(state), multistep.ActionContinue, "Step should have passed and continued.") + assert.Equal(t, step.Run(context.Background(), state), multistep.ActionContinue, "Step should have passed and continued.") // cleanup step.Cleanup(state) @@ -93,7 +94,7 @@ func TestStepCreateInstance_windowsNeedsPassword(t *testing.T) { d.GetImageResult = StubImage("test-image", "test-project", []string{"windows"}, 100) c.Comm.Type = "winrm" // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -142,7 +143,7 @@ func TestStepCreateInstance_windowsPasswordSet(t *testing.T) { config.Comm.WinRMPassword = "password" // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -188,7 +189,7 @@ func TestStepCreateInstance_error(t *testing.T) { d.GetImageResult = StubImage("test-image", "test-project", []string{}, 100) // run the step - assert.Equal(t, step.Run(state), multistep.ActionHalt, "Step should have failed and halted.") + assert.Equal(t, step.Run(context.Background(), state), multistep.ActionHalt, "Step should have failed and halted.") // Verify state _, ok := state.GetOk("error") @@ -212,7 +213,7 @@ func TestStepCreateInstance_errorOnChannel(t *testing.T) { d.GetImageResult = StubImage("test-image", "test-project", []string{}, 100) // run the step - assert.Equal(t, step.Run(state), multistep.ActionHalt, "Step should have failed and halted.") + assert.Equal(t, step.Run(context.Background(), state), multistep.ActionHalt, "Step should have failed and halted.") // Verify state _, ok := state.GetOk("error") @@ -238,7 +239,7 @@ func TestStepCreateInstance_errorTimeout(t *testing.T) { d.GetImageResult = StubImage("test-image", "test-project", []string{}, 100) // run the step - assert.Equal(t, step.Run(state), multistep.ActionHalt, "Step should have failed and halted.") + assert.Equal(t, step.Run(context.Background(), state), multistep.ActionHalt, "Step should have failed and halted.") // Verify state _, ok := state.GetOk("error") diff --git a/builder/googlecompute/step_create_ssh_key.go b/builder/googlecompute/step_create_ssh_key.go index fd6d7f55a..7d5a24555 100644 --- a/builder/googlecompute/step_create_ssh_key.go +++ b/builder/googlecompute/step_create_ssh_key.go @@ -1,6 +1,7 @@ package googlecompute import ( + "context" "crypto/rand" "crypto/rsa" "crypto/x509" @@ -9,8 +10,8 @@ import ( "io/ioutil" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "golang.org/x/crypto/ssh" ) @@ -24,7 +25,7 @@ type StepCreateSSHKey struct { // Run executes the Packer build step that generates SSH key pairs. // The key pairs are added to the multistep state as "ssh_private_key" and // "ssh_public_key". -func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if s.PrivateKeyFile != "" { diff --git a/builder/googlecompute/step_create_ssh_key_test.go b/builder/googlecompute/step_create_ssh_key_test.go index 94504ac7f..bc1b2e6b5 100644 --- a/builder/googlecompute/step_create_ssh_key_test.go +++ b/builder/googlecompute/step_create_ssh_key_test.go @@ -1,7 +1,9 @@ package googlecompute import ( - "github.com/mitchellh/multistep" + "context" + + "github.com/hashicorp/packer/helper/multistep" "io/ioutil" "os" @@ -19,7 +21,7 @@ func TestStepCreateSSHKey_privateKey(t *testing.T) { defer step.Cleanup(state) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -35,7 +37,7 @@ func TestStepCreateSSHKey(t *testing.T) { defer step.Cleanup(state) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -63,7 +65,7 @@ func TestStepCreateSSHKey_debug(t *testing.T) { defer step.Cleanup(state) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } diff --git a/builder/googlecompute/step_create_windows_password.go b/builder/googlecompute/step_create_windows_password.go index 312e54512..3386f6fbc 100644 --- a/builder/googlecompute/step_create_windows_password.go +++ b/builder/googlecompute/step_create_windows_password.go @@ -1,6 +1,7 @@ package googlecompute import ( + "context" "crypto/rand" "crypto/rsa" "crypto/x509" @@ -12,8 +13,8 @@ import ( "os" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCreateWindowsPassword represents a Packer build step that sets the windows password on a Windows GCE instance. @@ -23,7 +24,7 @@ type StepCreateWindowsPassword struct { } // Run executes the Packer build step that sets the windows password on a Windows GCE instance. -func (s *StepCreateWindowsPassword) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateWindowsPassword) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) d := state.Get("driver").(Driver) c := state.Get("config").(*Config) diff --git a/builder/googlecompute/step_create_windows_password_test.go b/builder/googlecompute/step_create_windows_password_test.go index 58fc8ee83..3a58d4816 100644 --- a/builder/googlecompute/step_create_windows_password_test.go +++ b/builder/googlecompute/step_create_windows_password_test.go @@ -1,11 +1,12 @@ package googlecompute import ( + "context" "errors" "io/ioutil" "os" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "testing" ) @@ -21,7 +22,7 @@ func TestStepCreateOrResetWindowsPassword(t *testing.T) { defer step.Cleanup(state) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -44,7 +45,7 @@ func TestStepCreateOrResetWindowsPassword_passwordSet(t *testing.T) { defer step.Cleanup(state) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -63,7 +64,7 @@ func TestStepCreateOrResetWindowsPassword_dontNeedPassword(t *testing.T) { defer step.Cleanup(state) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -89,7 +90,7 @@ func TestStepCreateOrResetWindowsPassword_debug(t *testing.T) { defer step.Cleanup(state) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -116,7 +117,7 @@ func TestStepCreateOrResetWindowsPassword_error(t *testing.T) { driver.CreateOrResetWindowsPasswordErr = errors.New("error") // run the step - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -148,7 +149,7 @@ func TestStepCreateOrResetWindowsPassword_errorOnChannel(t *testing.T) { driver.CreateOrResetWindowsPasswordErrCh = errCh // run the step - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/googlecompute/step_instance_info.go b/builder/googlecompute/step_instance_info.go index d5ece22e7..d67984b75 100644 --- a/builder/googlecompute/step_instance_info.go +++ b/builder/googlecompute/step_instance_info.go @@ -1,12 +1,13 @@ package googlecompute import ( + "context" "errors" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // stepInstanceInfo represents a Packer build step that gathers GCE instance info. @@ -16,7 +17,7 @@ type StepInstanceInfo struct { // Run executes the Packer build step that gathers GCE instance info. // This adds "instance_ip" to the multistep state. -func (s *StepInstanceInfo) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepInstanceInfo) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/googlecompute/step_instance_info_test.go b/builder/googlecompute/step_instance_info_test.go index b8547f2ff..86f718369 100644 --- a/builder/googlecompute/step_instance_info_test.go +++ b/builder/googlecompute/step_instance_info_test.go @@ -1,11 +1,12 @@ package googlecompute import ( + "context" "errors" "testing" "time" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepInstanceInfo_impl(t *testing.T) { @@ -24,7 +25,7 @@ func TestStepInstanceInfo(t *testing.T) { driver.GetNatIPResult = "1.2.3.4" // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -64,7 +65,7 @@ func TestStepInstanceInfo_InternalIP(t *testing.T) { driver.GetInternalIPResult = "5.6.7.8" // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -101,7 +102,7 @@ func TestStepInstanceInfo_getNatIPError(t *testing.T) { driver.GetNatIPErr = errors.New("error") // run the step - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -128,7 +129,7 @@ func TestStepInstanceInfo_waitError(t *testing.T) { driver.WaitForInstanceErrCh = errCh // run the step - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -161,7 +162,7 @@ func TestStepInstanceInfo_errorTimeout(t *testing.T) { driver.WaitForInstanceErrCh = errCh // run the step - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/googlecompute/step_teardown_instance.go b/builder/googlecompute/step_teardown_instance.go index 58585d78f..27f9fee35 100644 --- a/builder/googlecompute/step_teardown_instance.go +++ b/builder/googlecompute/step_teardown_instance.go @@ -1,12 +1,13 @@ package googlecompute import ( + "context" "errors" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepTeardownInstance represents a Packer build step that tears down GCE @@ -16,7 +17,7 @@ type StepTeardownInstance struct { } // Run executes the Packer build step that tears down a GCE instance. -func (s *StepTeardownInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepTeardownInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/googlecompute/step_teardown_instance_test.go b/builder/googlecompute/step_teardown_instance_test.go index 28c6480de..129c4e596 100644 --- a/builder/googlecompute/step_teardown_instance_test.go +++ b/builder/googlecompute/step_teardown_instance_test.go @@ -1,9 +1,10 @@ package googlecompute import ( + "context" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepTeardownInstance_impl(t *testing.T) { @@ -19,7 +20,7 @@ func TestStepTeardownInstance(t *testing.T) { driver := state.Get("driver").(*DriverMock) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } diff --git a/builder/googlecompute/step_test.go b/builder/googlecompute/step_test.go index 3e9b843f4..a50bde49f 100644 --- a/builder/googlecompute/step_test.go +++ b/builder/googlecompute/step_test.go @@ -4,8 +4,8 @@ import ( "bytes" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testState(t *testing.T) multistep.StateBag { diff --git a/builder/googlecompute/step_wait_startup_script.go b/builder/googlecompute/step_wait_startup_script.go index f2e1e523f..efc2a78f7 100644 --- a/builder/googlecompute/step_wait_startup_script.go +++ b/builder/googlecompute/step_wait_startup_script.go @@ -1,19 +1,20 @@ package googlecompute import ( + "context" "errors" "fmt" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepWaitStartupScript int // Run reads the instance metadata and looks for the log entry // indicating the startup script finished. -func (s *StepWaitStartupScript) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepWaitStartupScript) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/googlecompute/step_wait_startup_script_test.go b/builder/googlecompute/step_wait_startup_script_test.go index d157c761f..a970dc48d 100644 --- a/builder/googlecompute/step_wait_startup_script_test.go +++ b/builder/googlecompute/step_wait_startup_script_test.go @@ -1,9 +1,10 @@ package googlecompute import ( + "context" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "github.com/stretchr/testify/assert" ) @@ -23,7 +24,7 @@ func TestStepWaitStartupScript(t *testing.T) { d.GetInstanceMetadataResult = StartupScriptStatusDone // Run the step. - assert.Equal(t, step.Run(state), multistep.ActionContinue, "Step should have passed and continued.") + assert.Equal(t, step.Run(context.Background(), state), multistep.ActionContinue, "Step should have passed and continued.") // Check that GetInstanceMetadata was called properly. assert.Equal(t, d.GetInstanceMetadataZone, testZone, "Incorrect zone passed to GetInstanceMetadata.") diff --git a/builder/googlecompute/winrm.go b/builder/googlecompute/winrm.go index ec617cba5..767787401 100644 --- a/builder/googlecompute/winrm.go +++ b/builder/googlecompute/winrm.go @@ -2,7 +2,7 @@ package googlecompute import ( "github.com/hashicorp/packer/helper/communicator" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) // winrmConfig returns the WinRM configuration. diff --git a/builder/hyperv/common/ssh.go b/builder/hyperv/common/ssh.go index 182d154ff..f8a059bb0 100644 --- a/builder/hyperv/common/ssh.go +++ b/builder/hyperv/common/ssh.go @@ -3,7 +3,7 @@ package common import ( commonssh "github.com/hashicorp/packer/common/ssh" "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" gossh "golang.org/x/crypto/ssh" ) diff --git a/builder/hyperv/common/step_clone_vm.go b/builder/hyperv/common/step_clone_vm.go index 4a5b55566..f6dc9e390 100644 --- a/builder/hyperv/common/step_clone_vm.go +++ b/builder/hyperv/common/step_clone_vm.go @@ -1,13 +1,14 @@ package common import ( + "context" "fmt" "log" "path/filepath" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step clones an existing virtual machine. @@ -29,7 +30,7 @@ type StepCloneVM struct { EnableVirtualizationExtensions bool } -func (s *StepCloneVM) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCloneVM) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) ui.Say("Cloning virtual machine...") diff --git a/builder/hyperv/common/step_configure_ip.go b/builder/hyperv/common/step_configure_ip.go index deac917f8..41d945a0d 100644 --- a/builder/hyperv/common/step_configure_ip.go +++ b/builder/hyperv/common/step_configure_ip.go @@ -1,19 +1,20 @@ package common import ( + "context" "fmt" "log" "strings" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepConfigureIp struct { } -func (s *StepConfigureIp) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepConfigureIp) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_configure_vlan.go b/builder/hyperv/common/step_configure_vlan.go index 5d713ac99..a167b9ed1 100644 --- a/builder/hyperv/common/step_configure_vlan.go +++ b/builder/hyperv/common/step_configure_vlan.go @@ -1,10 +1,11 @@ package common import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepConfigureVlan struct { @@ -12,7 +13,7 @@ type StepConfigureVlan struct { SwitchVlanId string } -func (s *StepConfigureVlan) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepConfigureVlan) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_create_external_switch.go b/builder/hyperv/common/step_create_external_switch.go index 8443202b3..56e6fa6e8 100644 --- a/builder/hyperv/common/step_create_external_switch.go +++ b/builder/hyperv/common/step_create_external_switch.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "github.com/hashicorp/packer/common/uuid" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step creates switch for VM. @@ -17,7 +18,7 @@ type StepCreateExternalSwitch struct { oldSwitchName string } -func (s *StepCreateExternalSwitch) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateExternalSwitch) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_create_switch.go b/builder/hyperv/common/step_create_switch.go index 1904c9dbd..4b5ef48e2 100644 --- a/builder/hyperv/common/step_create_switch.go +++ b/builder/hyperv/common/step_create_switch.go @@ -1,10 +1,11 @@ package common import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const ( @@ -32,7 +33,7 @@ type StepCreateSwitch struct { createdSwitch bool } -func (s *StepCreateSwitch) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateSwitch) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_create_tempdir.go b/builder/hyperv/common/step_create_tempdir.go index c2ac9f719..1a9767fe5 100644 --- a/builder/hyperv/common/step_create_tempdir.go +++ b/builder/hyperv/common/step_create_tempdir.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "io/ioutil" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepCreateTempDir struct { @@ -18,7 +19,7 @@ type StepCreateTempDir struct { vhdDirPath string } -func (s *StepCreateTempDir) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateTempDir) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) ui.Say("Creating temporary directory...") diff --git a/builder/hyperv/common/step_create_vm.go b/builder/hyperv/common/step_create_vm.go index 02171d9c6..291fdc5dc 100644 --- a/builder/hyperv/common/step_create_vm.go +++ b/builder/hyperv/common/step_create_vm.go @@ -1,13 +1,14 @@ package common import ( + "context" "fmt" "log" "path/filepath" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step creates the actual virtual machine. @@ -30,7 +31,7 @@ type StepCreateVM struct { DifferencingDisk bool } -func (s *StepCreateVM) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateVM) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) ui.Say("Creating virtual machine...") diff --git a/builder/hyperv/common/step_disable_vlan.go b/builder/hyperv/common/step_disable_vlan.go index fb1454af3..0d4882ec1 100644 --- a/builder/hyperv/common/step_disable_vlan.go +++ b/builder/hyperv/common/step_disable_vlan.go @@ -1,16 +1,17 @@ package common import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepDisableVlan struct { } -func (s *StepDisableVlan) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepDisableVlan) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_enable_integration_service.go b/builder/hyperv/common/step_enable_integration_service.go index 852e3d804..e3f8fd70a 100644 --- a/builder/hyperv/common/step_enable_integration_service.go +++ b/builder/hyperv/common/step_enable_integration_service.go @@ -1,17 +1,18 @@ package common import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepEnableIntegrationService struct { name string } -func (s *StepEnableIntegrationService) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepEnableIntegrationService) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) ui.Say("Enabling Integration Service...") diff --git a/builder/hyperv/common/step_export_vm.go b/builder/hyperv/common/step_export_vm.go index 8c32052a3..6de5dbb70 100644 --- a/builder/hyperv/common/step_export_vm.go +++ b/builder/hyperv/common/step_export_vm.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "io/ioutil" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const ( @@ -19,7 +20,7 @@ type StepExportVm struct { SkipCompaction bool } -func (s *StepExportVm) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepExportVm) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_mount_dvddrive.go b/builder/hyperv/common/step_mount_dvddrive.go index 2f800a79c..945c6a86d 100644 --- a/builder/hyperv/common/step_mount_dvddrive.go +++ b/builder/hyperv/common/step_mount_dvddrive.go @@ -1,20 +1,21 @@ package common import ( + "context" "fmt" "log" "path/filepath" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepMountDvdDrive struct { Generation uint } -func (s *StepMountDvdDrive) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepMountDvdDrive) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_mount_floppydrive.go b/builder/hyperv/common/step_mount_floppydrive.go index d49b155b5..1ae03d1db 100644 --- a/builder/hyperv/common/step_mount_floppydrive.go +++ b/builder/hyperv/common/step_mount_floppydrive.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "io" "io/ioutil" @@ -8,8 +9,8 @@ import ( "os" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const ( @@ -21,7 +22,7 @@ type StepMountFloppydrive struct { floppyPath string } -func (s *StepMountFloppydrive) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepMountFloppydrive) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { if s.Generation > 1 { return multistep.ActionContinue } diff --git a/builder/hyperv/common/step_mount_guest_additions.go b/builder/hyperv/common/step_mount_guest_additions.go index fafa92971..71b6c3eec 100644 --- a/builder/hyperv/common/step_mount_guest_additions.go +++ b/builder/hyperv/common/step_mount_guest_additions.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepMountGuestAdditions struct { @@ -14,7 +15,7 @@ type StepMountGuestAdditions struct { Generation uint } -func (s *StepMountGuestAdditions) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepMountGuestAdditions) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if s.GuestAdditionsMode != "attach" { diff --git a/builder/hyperv/common/step_mount_secondary_dvd_images.go b/builder/hyperv/common/step_mount_secondary_dvd_images.go index 2b7934a5e..c23e39fac 100644 --- a/builder/hyperv/common/step_mount_secondary_dvd_images.go +++ b/builder/hyperv/common/step_mount_secondary_dvd_images.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepMountSecondaryDvdImages struct { @@ -19,7 +20,7 @@ type DvdControllerProperties struct { Existing bool } -func (s *StepMountSecondaryDvdImages) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepMountSecondaryDvdImages) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) ui.Say("Mounting secondary DVD images...") diff --git a/builder/hyperv/common/step_output_dir.go b/builder/hyperv/common/step_output_dir.go index 0054d1994..fc39d08b2 100644 --- a/builder/hyperv/common/step_output_dir.go +++ b/builder/hyperv/common/step_output_dir.go @@ -1,14 +1,15 @@ package common import ( + "context" "fmt" "log" "os" "path/filepath" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepOutputDir sets up the output directory by creating it if it does @@ -21,7 +22,7 @@ type StepOutputDir struct { cleanup bool } -func (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepOutputDir) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if _, err := os.Stat(s.Path); err == nil { diff --git a/builder/hyperv/common/step_polling_installation.go b/builder/hyperv/common/step_polling_installation.go index 8586940b1..b9d2984f6 100644 --- a/builder/hyperv/common/step_polling_installation.go +++ b/builder/hyperv/common/step_polling_installation.go @@ -2,14 +2,15 @@ package common import ( "bytes" + "context" "fmt" "log" "os/exec" "strings" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const port string = "13000" @@ -17,7 +18,7 @@ const port string = "13000" type StepPollingInstalation struct { } -func (s *StepPollingInstalation) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepPollingInstalation) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) errorMsg := "Error polling VM: %s" diff --git a/builder/hyperv/common/step_reboot_vm.go b/builder/hyperv/common/step_reboot_vm.go index 0ba777e6f..8e2bec1b8 100644 --- a/builder/hyperv/common/step_reboot_vm.go +++ b/builder/hyperv/common/step_reboot_vm.go @@ -1,17 +1,18 @@ package common import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepRebootVm struct { } -func (s *StepRebootVm) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRebootVm) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_run.go b/builder/hyperv/common/step_run.go index 050c76f50..cd8213c5e 100644 --- a/builder/hyperv/common/step_run.go +++ b/builder/hyperv/common/step_run.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepRun struct { @@ -14,7 +15,7 @@ type StepRun struct { vmName string } -func (s *StepRun) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRun) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/hyperv/common/step_shutdown.go b/builder/hyperv/common/step_shutdown.go index 9b341b395..b37716f60 100644 --- a/builder/hyperv/common/step_shutdown.go +++ b/builder/hyperv/common/step_shutdown.go @@ -2,13 +2,14 @@ package common import ( "bytes" + "context" "errors" "fmt" "log" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step shuts down the machine. It first attempts to do so gracefully, @@ -28,7 +29,7 @@ type StepShutdown struct { Timeout time.Duration } -func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepShutdown) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) diff --git a/builder/hyperv/common/step_sleep.go b/builder/hyperv/common/step_sleep.go index ea262d010..e65bcf0b1 100644 --- a/builder/hyperv/common/step_sleep.go +++ b/builder/hyperv/common/step_sleep.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepSleep struct { @@ -13,7 +14,7 @@ type StepSleep struct { ActionName string } -func (s *StepSleep) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepSleep) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if len(s.ActionName) > 0 { diff --git a/builder/hyperv/common/step_type_boot_command.go b/builder/hyperv/common/step_type_boot_command.go index dfeca6196..43deee1fd 100644 --- a/builder/hyperv/common/step_type_boot_command.go +++ b/builder/hyperv/common/step_type_boot_command.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "log" "strings" @@ -8,9 +9,9 @@ import ( "unicode/utf8" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type bootCommandTemplateData struct { @@ -26,7 +27,7 @@ type StepTypeBootCommand struct { Ctx interpolate.Context } -func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepTypeBootCommand) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { httpPort := state.Get("http_port").(uint) ui := state.Get("ui").(packer.Ui) driver := state.Get("driver").(Driver) diff --git a/builder/hyperv/common/step_unmount_dvddrive.go b/builder/hyperv/common/step_unmount_dvddrive.go index d8ba2033b..010e8b067 100644 --- a/builder/hyperv/common/step_unmount_dvddrive.go +++ b/builder/hyperv/common/step_unmount_dvddrive.go @@ -1,16 +1,17 @@ package common import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepUnmountDvdDrive struct { } -func (s *StepUnmountDvdDrive) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepUnmountDvdDrive) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_unmount_floppydrive.go b/builder/hyperv/common/step_unmount_floppydrive.go index e67279a5f..34f09aaa0 100644 --- a/builder/hyperv/common/step_unmount_floppydrive.go +++ b/builder/hyperv/common/step_unmount_floppydrive.go @@ -1,17 +1,18 @@ package common import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepUnmountFloppyDrive struct { Generation uint } -func (s *StepUnmountFloppyDrive) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepUnmountFloppyDrive) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_unmount_guest_additions.go b/builder/hyperv/common/step_unmount_guest_additions.go index da35a06e2..06600ddaa 100644 --- a/builder/hyperv/common/step_unmount_guest_additions.go +++ b/builder/hyperv/common/step_unmount_guest_additions.go @@ -1,16 +1,17 @@ package common import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepUnmountGuestAdditions struct { } -func (s *StepUnmountGuestAdditions) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepUnmountGuestAdditions) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) ui := state.Get("ui").(packer.Ui) diff --git a/builder/hyperv/common/step_unmount_secondary_dvd_images.go b/builder/hyperv/common/step_unmount_secondary_dvd_images.go index ec42923f6..0f74d2789 100644 --- a/builder/hyperv/common/step_unmount_secondary_dvd_images.go +++ b/builder/hyperv/common/step_unmount_secondary_dvd_images.go @@ -1,16 +1,17 @@ package common import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepUnmountSecondaryDvdImages struct { } -func (s *StepUnmountSecondaryDvdImages) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepUnmountSecondaryDvdImages) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/hyperv/common/step_wait_for_install_to_complete.go b/builder/hyperv/common/step_wait_for_install_to_complete.go index c002f57ae..0a40730b3 100644 --- a/builder/hyperv/common/step_wait_for_install_to_complete.go +++ b/builder/hyperv/common/step_wait_for_install_to_complete.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const ( @@ -15,7 +16,7 @@ const ( type StepWaitForPowerOff struct { } -func (s *StepWaitForPowerOff) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepWaitForPowerOff) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) @@ -49,7 +50,7 @@ type StepWaitForInstallToComplete struct { ActionName string } -func (s *StepWaitForInstallToComplete) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepWaitForInstallToComplete) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index 849cbcacf..c905d21e6 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -14,9 +14,9 @@ import ( "github.com/hashicorp/packer/common/powershell/hyperv" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) const ( diff --git a/builder/hyperv/iso/builder_test.go b/builder/hyperv/iso/builder_test.go index 7315b4950..b08a683f9 100644 --- a/builder/hyperv/iso/builder_test.go +++ b/builder/hyperv/iso/builder_test.go @@ -1,6 +1,7 @@ package iso import ( + "context" "fmt" "reflect" "strconv" @@ -9,8 +10,8 @@ import ( "os" hypervcommon "github.com/hashicorp/packer/builder/hyperv/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testConfig() map[string]interface{} { @@ -513,7 +514,7 @@ func TestUserVariablesInBootCommand(t *testing.T) { Ctx: b.config.ctx, } - ret := step.Run(state) + ret := step.Run(context.Background(), state) if ret != multistep.ActionContinue { t.Fatalf("should not have error: %#v", ret) } diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index 6a976b3df..a0238ede1 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -13,9 +13,9 @@ import ( "github.com/hashicorp/packer/common/powershell/hyperv" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) const ( diff --git a/builder/hyperv/vmcx/builder_test.go b/builder/hyperv/vmcx/builder_test.go index aef12c055..08444c26d 100644 --- a/builder/hyperv/vmcx/builder_test.go +++ b/builder/hyperv/vmcx/builder_test.go @@ -1,6 +1,7 @@ package vmcx import ( + "context" "fmt" "reflect" "testing" @@ -9,8 +10,8 @@ import ( "os" hypervcommon "github.com/hashicorp/packer/builder/hyperv/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testConfig() map[string]interface{} { @@ -534,7 +535,7 @@ func TestUserVariablesInBootCommand(t *testing.T) { Ctx: b.config.ctx, } - ret := step.Run(state) + ret := step.Run(context.Background(), state) if ret != multistep.ActionContinue { t.Fatalf("should not have error: %#v", ret) } diff --git a/builder/lxc/builder.go b/builder/lxc/builder.go index b45bd3511..8c239cd9b 100644 --- a/builder/lxc/builder.go +++ b/builder/lxc/builder.go @@ -6,9 +6,9 @@ import ( "path/filepath" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) // The unique ID for this builder diff --git a/builder/lxc/step_export.go b/builder/lxc/step_export.go index 7a0e1ec95..f01b30074 100644 --- a/builder/lxc/step_export.go +++ b/builder/lxc/step_export.go @@ -2,6 +2,7 @@ package lxc import ( "bytes" + "context" "fmt" "io" "log" @@ -10,13 +11,13 @@ import ( "path/filepath" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepExport struct{} -func (s *stepExport) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepExport) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/lxc/step_lxc_create.go b/builder/lxc/step_lxc_create.go index 131fc958b..98dce3a7c 100644 --- a/builder/lxc/step_lxc_create.go +++ b/builder/lxc/step_lxc_create.go @@ -2,19 +2,20 @@ package lxc import ( "bytes" + "context" "fmt" "log" "os/exec" "path/filepath" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepLxcCreate struct{} -func (s *stepLxcCreate) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepLxcCreate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/lxc/step_prepare_output_dir.go b/builder/lxc/step_prepare_output_dir.go index 835bbf5a3..25479fd8a 100644 --- a/builder/lxc/step_prepare_output_dir.go +++ b/builder/lxc/step_prepare_output_dir.go @@ -1,17 +1,18 @@ package lxc import ( + "context" "log" "os" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepPrepareOutputDir struct{} -func (stepPrepareOutputDir) Run(state multistep.StateBag) multistep.StepAction { +func (stepPrepareOutputDir) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/lxc/step_provision.go b/builder/lxc/step_provision.go index 9c54b9603..ac33eb301 100644 --- a/builder/lxc/step_provision.go +++ b/builder/lxc/step_provision.go @@ -1,16 +1,17 @@ package lxc import ( + "context" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepProvision provisions the instance within a chroot. type StepProvision struct{} -func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepProvision) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { hook := state.Get("hook").(packer.Hook) config := state.Get("config").(*Config) mountPath := state.Get("mount_path").(string) diff --git a/builder/lxc/step_wait_init.go b/builder/lxc/step_wait_init.go index 69ce8a5af..4e055a690 100644 --- a/builder/lxc/step_wait_init.go +++ b/builder/lxc/step_wait_init.go @@ -1,21 +1,22 @@ package lxc import ( + "context" "errors" "fmt" "log" "strings" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepWaitInit struct { WaitTimeout time.Duration } -func (s *StepWaitInit) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepWaitInit) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) var err error diff --git a/builder/lxd/builder.go b/builder/lxd/builder.go index 48a879543..290b8a631 100644 --- a/builder/lxd/builder.go +++ b/builder/lxd/builder.go @@ -4,9 +4,9 @@ import ( "log" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) // The unique ID for this builder diff --git a/builder/lxd/step_lxd_launch.go b/builder/lxd/step_lxd_launch.go index d8ad17734..de34a5cb4 100644 --- a/builder/lxd/step_lxd_launch.go +++ b/builder/lxd/step_lxd_launch.go @@ -1,16 +1,17 @@ package lxd import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepLxdLaunch struct{} -func (s *stepLxdLaunch) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepLxdLaunch) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/lxd/step_provision.go b/builder/lxd/step_provision.go index 5fbc9d034..509006d77 100644 --- a/builder/lxd/step_provision.go +++ b/builder/lxd/step_provision.go @@ -1,16 +1,17 @@ package lxd import ( + "context" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepProvision provisions the container type StepProvision struct{} -func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepProvision) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { hook := state.Get("hook").(packer.Hook) config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/lxd/step_publish.go b/builder/lxd/step_publish.go index 19a8c22af..4dc21880f 100644 --- a/builder/lxd/step_publish.go +++ b/builder/lxd/step_publish.go @@ -1,16 +1,17 @@ package lxd import ( + "context" "fmt" "regexp" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepPublish struct{} -func (s *stepPublish) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepPublish) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/null/builder.go b/builder/null/builder.go index 3e587ebd0..f4d4764d6 100644 --- a/builder/null/builder.go +++ b/builder/null/builder.go @@ -5,8 +5,8 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const BuilderId = "fnoeding.null" diff --git a/builder/null/ssh.go b/builder/null/ssh.go index b8dea896e..8e18bb6ac 100644 --- a/builder/null/ssh.go +++ b/builder/null/ssh.go @@ -7,7 +7,7 @@ import ( "os" "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" gossh "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" ) diff --git a/builder/oneandone/builder.go b/builder/oneandone/builder.go index 673e35264..4b84b3938 100644 --- a/builder/oneandone/builder.go +++ b/builder/oneandone/builder.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const BuilderId = "packer.oneandone" diff --git a/builder/oneandone/ssh.go b/builder/oneandone/ssh.go index 69fb435e1..9fdb128a9 100644 --- a/builder/oneandone/ssh.go +++ b/builder/oneandone/ssh.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" gossh "golang.org/x/crypto/ssh" ) diff --git a/builder/oneandone/step_create_server.go b/builder/oneandone/step_create_server.go index 7f38311a6..cffd8c440 100644 --- a/builder/oneandone/step_create_server.go +++ b/builder/oneandone/step_create_server.go @@ -1,18 +1,19 @@ package oneandone import ( + "context" "fmt" "strings" "time" "github.com/1and1/oneandone-cloudserver-sdk-go" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepCreateServer struct{} -func (s *stepCreateServer) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateServer) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) c := state.Get("config").(*Config) diff --git a/builder/oneandone/step_create_sshkey.go b/builder/oneandone/step_create_sshkey.go index e4174ef5d..a27561c1f 100644 --- a/builder/oneandone/step_create_sshkey.go +++ b/builder/oneandone/step_create_sshkey.go @@ -1,13 +1,14 @@ package oneandone import ( + "context" "crypto/x509" "encoding/pem" "fmt" "io/ioutil" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "golang.org/x/crypto/ssh" ) @@ -16,7 +17,7 @@ type StepCreateSSHKey struct { DebugKeyPath string } -func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) c := state.Get("config").(*Config) diff --git a/builder/oneandone/step_take_snapshot.go b/builder/oneandone/step_take_snapshot.go index b19790c7d..65a3f7156 100644 --- a/builder/oneandone/step_take_snapshot.go +++ b/builder/oneandone/step_take_snapshot.go @@ -1,14 +1,16 @@ package oneandone import ( + "context" + "github.com/1and1/oneandone-cloudserver-sdk-go" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepTakeSnapshot struct{} -func (s *stepTakeSnapshot) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepTakeSnapshot) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) c := state.Get("config").(*Config) diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index 46d0e4e67..f3c6fd13b 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -10,9 +10,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) // The unique ID for this builder diff --git a/builder/openstack/server.go b/builder/openstack/server.go index 2c2dd8f2a..f509452d6 100644 --- a/builder/openstack/server.go +++ b/builder/openstack/server.go @@ -8,7 +8,7 @@ import ( "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) // StateRefreshFunc is a function type used for StateChangeConf that is diff --git a/builder/openstack/ssh.go b/builder/openstack/ssh.go index 9957c6163..1dd6672c4 100644 --- a/builder/openstack/ssh.go +++ b/builder/openstack/ssh.go @@ -12,7 +12,7 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" packerssh "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" ) diff --git a/builder/openstack/step_add_image_members.go b/builder/openstack/step_add_image_members.go index 642ed3d46..e23e54588 100644 --- a/builder/openstack/step_add_image_members.go +++ b/builder/openstack/step_add_image_members.go @@ -1,16 +1,17 @@ package openstack import ( + "context" "fmt" "github.com/gophercloud/gophercloud/openstack/imageservice/v2/members" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepAddImageMembers struct{} -func (s *stepAddImageMembers) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepAddImageMembers) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { imageId := state.Get("image").(string) ui := state.Get("ui").(packer.Ui) config := state.Get("config").(Config) diff --git a/builder/openstack/step_allocate_ip.go b/builder/openstack/step_allocate_ip.go index 521e42634..fb53ce434 100644 --- a/builder/openstack/step_allocate_ip.go +++ b/builder/openstack/step_allocate_ip.go @@ -1,13 +1,14 @@ package openstack import ( + "context" "fmt" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/floatingips" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" "github.com/gophercloud/gophercloud/pagination" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepAllocateIp struct { @@ -16,7 +17,7 @@ type StepAllocateIp struct { ReuseIps bool } -func (s *StepAllocateIp) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepAllocateIp) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) config := state.Get("config").(Config) server := state.Get("server").(*servers.Server) diff --git a/builder/openstack/step_create_image.go b/builder/openstack/step_create_image.go index 126bd4971..de8a6f4f6 100644 --- a/builder/openstack/step_create_image.go +++ b/builder/openstack/step_create_image.go @@ -1,6 +1,7 @@ package openstack import ( + "context" "fmt" "log" "time" @@ -8,13 +9,13 @@ import ( "github.com/gophercloud/gophercloud" "github.com/gophercloud/gophercloud/openstack/compute/v2/images" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepCreateImage struct{} -func (s *stepCreateImage) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(Config) server := state.Get("server").(*servers.Server) ui := state.Get("ui").(packer.Ui) diff --git a/builder/openstack/step_get_password.go b/builder/openstack/step_get_password.go index 10800d5be..4b962db4b 100644 --- a/builder/openstack/step_get_password.go +++ b/builder/openstack/step_get_password.go @@ -1,6 +1,7 @@ package openstack import ( + "context" "crypto/rsa" "fmt" "log" @@ -8,8 +9,8 @@ import ( "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "golang.org/x/crypto/ssh" ) @@ -20,7 +21,7 @@ type StepGetPassword struct { Comm *communicator.Config } -func (s *StepGetPassword) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepGetPassword) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/openstack/step_key_pair.go b/builder/openstack/step_key_pair.go index 2d1500a5c..c4eba5804 100644 --- a/builder/openstack/step_key_pair.go +++ b/builder/openstack/step_key_pair.go @@ -1,6 +1,7 @@ package openstack import ( + "context" "fmt" "io/ioutil" "log" @@ -9,8 +10,8 @@ import ( "runtime" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "golang.org/x/crypto/ssh" ) @@ -25,7 +26,7 @@ type StepKeyPair struct { doCleanup bool } -func (s *StepKeyPair) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if s.PrivateKeyFile != "" { diff --git a/builder/openstack/step_load_extensions.go b/builder/openstack/step_load_extensions.go index 84ab0c8d2..b11cf5527 100644 --- a/builder/openstack/step_load_extensions.go +++ b/builder/openstack/step_load_extensions.go @@ -1,13 +1,14 @@ package openstack import ( + "context" "fmt" "log" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions" "github.com/gophercloud/gophercloud/pagination" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepLoadExtensions gets the FlavorRef from a Flavor. It first assumes @@ -15,7 +16,7 @@ import ( // the flavor by name. type StepLoadExtensions struct{} -func (s *StepLoadExtensions) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepLoadExtensions) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/openstack/step_load_flavor.go b/builder/openstack/step_load_flavor.go index 816e0d8f4..8c331aa6a 100644 --- a/builder/openstack/step_load_flavor.go +++ b/builder/openstack/step_load_flavor.go @@ -1,12 +1,13 @@ package openstack import ( + "context" "fmt" "log" "github.com/gophercloud/gophercloud/openstack/compute/v2/flavors" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepLoadFlavor gets the FlavorRef from a Flavor. It first assumes @@ -16,7 +17,7 @@ type StepLoadFlavor struct { Flavor string } -func (s *StepLoadFlavor) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepLoadFlavor) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/openstack/step_run_source_server.go b/builder/openstack/step_run_source_server.go index 427f507dc..bb09f85b7 100644 --- a/builder/openstack/step_run_source_server.go +++ b/builder/openstack/step_run_source_server.go @@ -1,14 +1,15 @@ package openstack import ( + "context" "fmt" "io/ioutil" "log" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/keypairs" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepRunSourceServer struct { @@ -25,7 +26,7 @@ type StepRunSourceServer struct { server *servers.Server } -func (s *StepRunSourceServer) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRunSourceServer) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(Config) flavor := state.Get("flavor_id").(string) ui := state.Get("ui").(packer.Ui) diff --git a/builder/openstack/step_stop_server.go b/builder/openstack/step_stop_server.go index e0f240fbd..1c864eef0 100644 --- a/builder/openstack/step_stop_server.go +++ b/builder/openstack/step_stop_server.go @@ -1,17 +1,18 @@ package openstack import ( + "context" "fmt" "github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/startstop" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepStopServer struct{} -func (s *StepStopServer) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepStopServer) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) config := state.Get("config").(Config) extensions := state.Get("extensions").(map[string]struct{}) diff --git a/builder/openstack/step_update_image_visibility.go b/builder/openstack/step_update_image_visibility.go index fb83134bd..8d9a3bc7c 100644 --- a/builder/openstack/step_update_image_visibility.go +++ b/builder/openstack/step_update_image_visibility.go @@ -1,16 +1,17 @@ package openstack import ( + "context" "fmt" imageservice "github.com/gophercloud/gophercloud/openstack/imageservice/v2/images" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepUpdateImageVisibility struct{} -func (s *stepUpdateImageVisibility) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepUpdateImageVisibility) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { imageId := state.Get("image").(string) ui := state.Get("ui").(packer.Ui) config := state.Get("config").(Config) diff --git a/builder/openstack/step_wait_for_rackconnect.go b/builder/openstack/step_wait_for_rackconnect.go index d791e9db0..6cbe2ed0e 100644 --- a/builder/openstack/step_wait_for_rackconnect.go +++ b/builder/openstack/step_wait_for_rackconnect.go @@ -1,19 +1,20 @@ package openstack import ( + "context" "fmt" "time" "github.com/gophercloud/gophercloud/openstack/compute/v2/servers" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepWaitForRackConnect struct { Wait bool } -func (s *StepWaitForRackConnect) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepWaitForRackConnect) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { if !s.Wait { return multistep.ActionContinue } diff --git a/builder/oracle/oci/builder.go b/builder/oracle/oci/builder.go index 5eedaa0b1..6a2f6efef 100644 --- a/builder/oracle/oci/builder.go +++ b/builder/oracle/oci/builder.go @@ -9,8 +9,8 @@ import ( client "github.com/hashicorp/packer/builder/oracle/oci/client" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // BuilderId uniquely identifies the builder diff --git a/builder/oracle/oci/ssh.go b/builder/oracle/oci/ssh.go index a9d62f4a4..5424b94b4 100644 --- a/builder/oracle/oci/ssh.go +++ b/builder/oracle/oci/ssh.go @@ -4,7 +4,7 @@ import ( "fmt" packerssh "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "golang.org/x/crypto/ssh" ) diff --git a/builder/oracle/oci/step_create_instance.go b/builder/oracle/oci/step_create_instance.go index 8650f7314..375b92b1b 100644 --- a/builder/oracle/oci/step_create_instance.go +++ b/builder/oracle/oci/step_create_instance.go @@ -1,15 +1,16 @@ package oci import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepCreateInstance struct{} -func (s *stepCreateInstance) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateInstance) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { var ( driver = state.Get("driver").(Driver) ui = state.Get("ui").(packer.Ui) diff --git a/builder/oracle/oci/step_create_instance_test.go b/builder/oracle/oci/step_create_instance_test.go index 558a17cb6..6ab2ceb67 100644 --- a/builder/oracle/oci/step_create_instance_test.go +++ b/builder/oracle/oci/step_create_instance_test.go @@ -1,10 +1,11 @@ package oci import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepCreateInstance(t *testing.T) { @@ -16,7 +17,7 @@ func TestStepCreateInstance(t *testing.T) { driver := state.Get("driver").(*driverMock) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -44,7 +45,7 @@ func TestStepCreateInstance_CreateInstanceErr(t *testing.T) { driver := state.Get("driver").(*driverMock) driver.CreateInstanceErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -73,7 +74,7 @@ func TestStepCreateInstance_WaitForInstanceStateErr(t *testing.T) { driver := state.Get("driver").(*driverMock) driver.WaitForInstanceStateErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -91,7 +92,7 @@ func TestStepCreateInstance_TerminateInstanceErr(t *testing.T) { driver := state.Get("driver").(*driverMock) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -117,7 +118,7 @@ func TestStepCreateInstanceCleanup_WaitForInstanceStateErr(t *testing.T) { driver := state.Get("driver").(*driverMock) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } diff --git a/builder/oracle/oci/step_image.go b/builder/oracle/oci/step_image.go index 07c9ddb4b..ff767f709 100644 --- a/builder/oracle/oci/step_image.go +++ b/builder/oracle/oci/step_image.go @@ -1,15 +1,16 @@ package oci import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepImage struct{} -func (s *stepImage) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepImage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { var ( driver = state.Get("driver").(Driver) ui = state.Get("ui").(packer.Ui) diff --git a/builder/oracle/oci/step_image_test.go b/builder/oracle/oci/step_image_test.go index 72399278c..955d557a9 100644 --- a/builder/oracle/oci/step_image_test.go +++ b/builder/oracle/oci/step_image_test.go @@ -1,10 +1,11 @@ package oci import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepImage(t *testing.T) { @@ -14,7 +15,7 @@ func TestStepImage(t *testing.T) { step := new(stepImage) defer step.Cleanup(state) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -33,7 +34,7 @@ func TestStepImage_CreateImageErr(t *testing.T) { driver := state.Get("driver").(*driverMock) driver.CreateImageErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -56,7 +57,7 @@ func TestStepImage_WaitForImageCreationErr(t *testing.T) { driver := state.Get("driver").(*driverMock) driver.WaitForImageCreationErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/oracle/oci/step_instance_info.go b/builder/oracle/oci/step_instance_info.go index 310d8699c..d3e024978 100644 --- a/builder/oracle/oci/step_instance_info.go +++ b/builder/oracle/oci/step_instance_info.go @@ -1,15 +1,16 @@ package oci import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepInstanceInfo struct{} -func (s *stepInstanceInfo) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepInstanceInfo) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { var ( driver = state.Get("driver").(Driver) ui = state.Get("ui").(packer.Ui) diff --git a/builder/oracle/oci/step_instance_info_test.go b/builder/oracle/oci/step_instance_info_test.go index fdae8a0ef..7117ec44a 100644 --- a/builder/oracle/oci/step_instance_info_test.go +++ b/builder/oracle/oci/step_instance_info_test.go @@ -1,10 +1,11 @@ package oci import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestInstanceInfo(t *testing.T) { @@ -14,7 +15,7 @@ func TestInstanceInfo(t *testing.T) { step := new(stepInstanceInfo) defer step.Cleanup(state) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -38,7 +39,7 @@ func TestInstanceInfo_GetInstanceIPErr(t *testing.T) { driver := state.Get("driver").(*driverMock) driver.GetInstanceIPErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/oracle/oci/step_ssh_key_pair.go b/builder/oracle/oci/step_ssh_key_pair.go index cc9d0358f..9fa83c17d 100644 --- a/builder/oracle/oci/step_ssh_key_pair.go +++ b/builder/oracle/oci/step_ssh_key_pair.go @@ -1,6 +1,7 @@ package oci import ( + "context" "crypto/rand" "crypto/rsa" "crypto/x509" @@ -10,8 +11,8 @@ import ( "os" "runtime" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "golang.org/x/crypto/ssh" ) @@ -21,7 +22,7 @@ type stepKeyPair struct { PrivateKeyFile string } -func (s *stepKeyPair) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepKeyPair) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if s.PrivateKeyFile != "" { diff --git a/builder/oracle/oci/step_test.go b/builder/oracle/oci/step_test.go index d4436e304..f46ffa1e4 100644 --- a/builder/oracle/oci/step_test.go +++ b/builder/oracle/oci/step_test.go @@ -4,8 +4,8 @@ import ( "bytes" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" client "github.com/hashicorp/packer/builder/oracle/oci/client" ) diff --git a/builder/parallels/common/ssh.go b/builder/parallels/common/ssh.go index 8c2c8706f..6673698b5 100644 --- a/builder/parallels/common/ssh.go +++ b/builder/parallels/common/ssh.go @@ -3,7 +3,7 @@ package common import ( commonssh "github.com/hashicorp/packer/common/ssh" packerssh "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "golang.org/x/crypto/ssh" ) diff --git a/builder/parallels/common/step_attach_floppy.go b/builder/parallels/common/step_attach_floppy.go index 8b970fef2..fa9566011 100644 --- a/builder/parallels/common/step_attach_floppy.go +++ b/builder/parallels/common/step_attach_floppy.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepAttachFloppy is a step that attaches a floppy to the virtual machine. @@ -22,7 +23,7 @@ type StepAttachFloppy struct { // Run adds a virtual FDD device to the VM and attaches the image. // If the image is not specified, then this step will be skipped. -func (s *StepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepAttachFloppy) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { // Determine if we even have a floppy disk to attach var floppyPath string if floppyPathRaw, ok := state.GetOk("floppy_path"); ok { diff --git a/builder/parallels/common/step_attach_floppy_test.go b/builder/parallels/common/step_attach_floppy_test.go index f854fd23c..2d951cf05 100644 --- a/builder/parallels/common/step_attach_floppy_test.go +++ b/builder/parallels/common/step_attach_floppy_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepAttachFloppy_impl(t *testing.T) { @@ -30,7 +31,7 @@ func TestStepAttachFloppy(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -72,7 +73,7 @@ func TestStepAttachFloppy_noFloppy(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/parallels/common/step_attach_parallels_tools.go b/builder/parallels/common/step_attach_parallels_tools.go index 87d602df7..1c1ea31b4 100644 --- a/builder/parallels/common/step_attach_parallels_tools.go +++ b/builder/parallels/common/step_attach_parallels_tools.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepAttachParallelsTools is a step that attaches Parallels Tools ISO image @@ -25,7 +26,7 @@ type StepAttachParallelsTools struct { // Run adds a virtual CD-ROM device to the VM and attaches Parallels Tools ISO image. // If ISO image is not specified, then this step will be skipped. -func (s *StepAttachParallelsTools) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepAttachParallelsTools) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/parallels/common/step_compact_disk.go b/builder/parallels/common/step_compact_disk.go index 2e88e7bd5..85688de51 100644 --- a/builder/parallels/common/step_compact_disk.go +++ b/builder/parallels/common/step_compact_disk.go @@ -1,10 +1,11 @@ package common import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCompactDisk is a step that removes all empty blocks from expanding @@ -22,7 +23,7 @@ type StepCompactDisk struct { } // Run runs the compaction of the virtual disk attached to the VM. -func (s *StepCompactDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCompactDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) vmName := state.Get("vmName").(string) ui := state.Get("ui").(packer.Ui) diff --git a/builder/parallels/common/step_compact_disk_test.go b/builder/parallels/common/step_compact_disk_test.go index ace932a2d..e32ef217b 100644 --- a/builder/parallels/common/step_compact_disk_test.go +++ b/builder/parallels/common/step_compact_disk_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepCompactDisk_impl(t *testing.T) { @@ -31,7 +32,7 @@ func TestStepCompactDisk(t *testing.T) { driver.DiskPathResult = tf.Name() // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -59,7 +60,7 @@ func TestStepCompactDisk_skip(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/parallels/common/step_output_dir.go b/builder/parallels/common/step_output_dir.go index 3accd2cbb..f6f092c4a 100644 --- a/builder/parallels/common/step_output_dir.go +++ b/builder/parallels/common/step_output_dir.go @@ -1,14 +1,15 @@ package common import ( + "context" "fmt" "log" "os" "path/filepath" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepOutputDir sets up the output directory by creating it if it does @@ -21,7 +22,7 @@ type StepOutputDir struct { } // Run sets up the output directory. -func (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepOutputDir) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if _, err := os.Stat(s.Path); err == nil && s.Force { diff --git a/builder/parallels/common/step_output_dir_test.go b/builder/parallels/common/step_output_dir_test.go index 04f5a7339..17d441457 100644 --- a/builder/parallels/common/step_output_dir_test.go +++ b/builder/parallels/common/step_output_dir_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func testStepOutputDir(t *testing.T) *StepOutputDir { @@ -29,7 +30,7 @@ func TestStepOutputDir(t *testing.T) { step := testStepOutputDir(t) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -51,7 +52,7 @@ func TestStepOutputDir_cancelled(t *testing.T) { step := testStepOutputDir(t) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -76,7 +77,7 @@ func TestStepOutputDir_halted(t *testing.T) { step := testStepOutputDir(t) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/parallels/common/step_prepare_parallels_tools.go b/builder/parallels/common/step_prepare_parallels_tools.go index 99e8722dc..5da892782 100644 --- a/builder/parallels/common/step_prepare_parallels_tools.go +++ b/builder/parallels/common/step_prepare_parallels_tools.go @@ -1,10 +1,11 @@ package common import ( + "context" "fmt" "os" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) // StepPrepareParallelsTools is a step that prepares parameters related @@ -21,7 +22,7 @@ type StepPrepareParallelsTools struct { } // Run sets the value of "parallels_tools_path". -func (s *StepPrepareParallelsTools) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepPrepareParallelsTools) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) if s.ParallelsToolsMode == ParallelsToolsModeDisable { diff --git a/builder/parallels/common/step_prepare_parallels_tools_test.go b/builder/parallels/common/step_prepare_parallels_tools_test.go index 0647149e5..4f46fc642 100644 --- a/builder/parallels/common/step_prepare_parallels_tools_test.go +++ b/builder/parallels/common/step_prepare_parallels_tools_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepPrepareParallelsTools_impl(t *testing.T) { @@ -32,7 +33,7 @@ func TestStepPrepareParallelsTools(t *testing.T) { driver.ToolsISOPathResult = tf.Name() // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -67,7 +68,7 @@ func TestStepPrepareParallelsTools_disabled(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -93,7 +94,7 @@ func TestStepPrepareParallelsTools_nonExist(t *testing.T) { driver.ToolsISOPathResult = "foo" // Test the run - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); !ok { diff --git a/builder/parallels/common/step_prlctl.go b/builder/parallels/common/step_prlctl.go index a38d8b7fe..9ae6ec7e9 100644 --- a/builder/parallels/common/step_prlctl.go +++ b/builder/parallels/common/step_prlctl.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type commandTemplate struct { @@ -28,7 +29,7 @@ type StepPrlctl struct { } // Run executes `prlctl` commands. -func (s *StepPrlctl) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepPrlctl) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/parallels/common/step_run.go b/builder/parallels/common/step_run.go index 8f86e089b..073ad0550 100644 --- a/builder/parallels/common/step_run.go +++ b/builder/parallels/common/step_run.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepRun is a step that starts the virtual machine. @@ -23,7 +24,7 @@ type StepRun struct { } // Run starts the VM. -func (s *StepRun) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRun) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/parallels/common/step_shutdown.go b/builder/parallels/common/step_shutdown.go index f8ec90009..7f9d3b663 100644 --- a/builder/parallels/common/step_shutdown.go +++ b/builder/parallels/common/step_shutdown.go @@ -2,13 +2,14 @@ package common import ( "bytes" + "context" "errors" "fmt" "log" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepShutdown is a step that shuts down the machine. It first attempts to do @@ -28,7 +29,7 @@ type StepShutdown struct { } // Run shuts down the VM. -func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepShutdown) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/parallels/common/step_shutdown_test.go b/builder/parallels/common/step_shutdown_test.go index de3baabda..0d137431f 100644 --- a/builder/parallels/common/step_shutdown_test.go +++ b/builder/parallels/common/step_shutdown_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "testing" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func TestStepShutdown_impl(t *testing.T) { @@ -23,7 +24,7 @@ func TestStepShutdown_noShutdownCommand(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -60,7 +61,7 @@ func TestStepShutdown_shutdownCommand(t *testing.T) { }() // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -97,7 +98,7 @@ func TestStepShutdown_shutdownTimeout(t *testing.T) { }() // Test the run - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); !ok { diff --git a/builder/parallels/common/step_test.go b/builder/parallels/common/step_test.go index cdaab7922..0964784f7 100644 --- a/builder/parallels/common/step_test.go +++ b/builder/parallels/common/step_test.go @@ -4,8 +4,8 @@ import ( "bytes" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testState(t *testing.T) multistep.StateBag { diff --git a/builder/parallels/common/step_type_boot_command.go b/builder/parallels/common/step_type_boot_command.go index c3076b82c..e39a90b6c 100644 --- a/builder/parallels/common/step_type_boot_command.go +++ b/builder/parallels/common/step_type_boot_command.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "log" "strings" @@ -9,9 +10,9 @@ import ( "unicode/utf8" packer_common "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type bootCommandTemplateData struct { @@ -39,7 +40,7 @@ type StepTypeBootCommand struct { } // Run types the boot command by sending key scancodes into the VM. -func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepTypeBootCommand) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { debug := state.Get("debug").(bool) httpPort := state.Get("http_port").(uint) ui := state.Get("ui").(packer.Ui) diff --git a/builder/parallels/common/step_type_boot_command_test.go b/builder/parallels/common/step_type_boot_command_test.go index ea33b9369..72b5056b4 100644 --- a/builder/parallels/common/step_type_boot_command_test.go +++ b/builder/parallels/common/step_type_boot_command_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "strings" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func TestStepTypeBootCommand(t *testing.T) { @@ -38,7 +39,7 @@ func TestStepTypeBootCommand(t *testing.T) { state.Put("http_port", uint(0)) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/parallels/common/step_upload_parallels_tools.go b/builder/parallels/common/step_upload_parallels_tools.go index 5769f1be5..0da0b26e0 100644 --- a/builder/parallels/common/step_upload_parallels_tools.go +++ b/builder/parallels/common/step_upload_parallels_tools.go @@ -1,13 +1,14 @@ package common import ( + "context" "fmt" "log" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) // This step uploads the Parallels Tools ISO to the virtual machine. @@ -37,7 +38,7 @@ type StepUploadParallelsTools struct { } // Run uploads the Parallels Tools ISO to the VM. -func (s *StepUploadParallelsTools) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepUploadParallelsTools) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) ui := state.Get("ui").(packer.Ui) diff --git a/builder/parallels/common/step_upload_parallels_tools_test.go b/builder/parallels/common/step_upload_parallels_tools_test.go index 263571ff6..aeff516d3 100644 --- a/builder/parallels/common/step_upload_parallels_tools_test.go +++ b/builder/parallels/common/step_upload_parallels_tools_test.go @@ -1,10 +1,11 @@ package common import ( + "context" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func TestStepUploadParallelsTools_impl(t *testing.T) { @@ -23,7 +24,7 @@ func TestStepUploadParallelsTools(t *testing.T) { state.Put("communicator", comm) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -48,7 +49,7 @@ func TestStepUploadParallelsTools_interpolate(t *testing.T) { state.Put("communicator", comm) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -73,7 +74,7 @@ func TestStepUploadParallelsTools_attach(t *testing.T) { state.Put("communicator", comm) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/parallels/common/step_upload_version.go b/builder/parallels/common/step_upload_version.go index 6824b035e..1a1bfcf0c 100644 --- a/builder/parallels/common/step_upload_version.go +++ b/builder/parallels/common/step_upload_version.go @@ -2,11 +2,12 @@ package common import ( "bytes" + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepUploadVersion is a step that uploads a file containing the version of @@ -21,7 +22,7 @@ type StepUploadVersion struct { } // Run uploads a file containing the version of Parallels Desktop. -func (s *StepUploadVersion) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepUploadVersion) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/parallels/common/step_upload_version_test.go b/builder/parallels/common/step_upload_version_test.go index 8aaf9cc90..998d35f0e 100644 --- a/builder/parallels/common/step_upload_version_test.go +++ b/builder/parallels/common/step_upload_version_test.go @@ -1,10 +1,11 @@ package common import ( + "context" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func TestStepUploadVersion_impl(t *testing.T) { @@ -23,7 +24,7 @@ func TestStepUploadVersion(t *testing.T) { driver.VersionResult = "foo" // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -48,7 +49,7 @@ func TestStepUploadVersion_noPath(t *testing.T) { state.Put("communicator", comm) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index 14ae2991d..cf8159f6b 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -9,9 +9,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) const BuilderId = "rickard-von-essen.parallels" diff --git a/builder/parallels/iso/step_attach_iso.go b/builder/parallels/iso/step_attach_iso.go index 4dead4705..a4cf634a8 100644 --- a/builder/parallels/iso/step_attach_iso.go +++ b/builder/parallels/iso/step_attach_iso.go @@ -1,12 +1,13 @@ package iso import ( + "context" "fmt" "log" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step attaches the ISO to the virtual machine. @@ -21,7 +22,7 @@ import ( // attachedIso bool type stepAttachISO struct{} -func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepAttachISO) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(parallelscommon.Driver) isoPath := state.Get("iso_path").(string) ui := state.Get("ui").(packer.Ui) diff --git a/builder/parallels/iso/step_create_disk.go b/builder/parallels/iso/step_create_disk.go index 0333472be..42640f5a8 100644 --- a/builder/parallels/iso/step_create_disk.go +++ b/builder/parallels/iso/step_create_disk.go @@ -1,19 +1,20 @@ package iso import ( + "context" "fmt" "strconv" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step creates the virtual disk that will be used as the // hard drive for the virtual machine. type stepCreateDisk struct{} -func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(parallelscommon.Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/parallels/iso/step_create_vm.go b/builder/parallels/iso/step_create_vm.go index b085e4485..8a4e22517 100644 --- a/builder/parallels/iso/step_create_vm.go +++ b/builder/parallels/iso/step_create_vm.go @@ -1,11 +1,12 @@ package iso import ( + "context" "fmt" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step creates the actual virtual machine. @@ -16,7 +17,7 @@ type stepCreateVM struct { vmName string } -func (s *stepCreateVM) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateVM) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(parallelscommon.Driver) diff --git a/builder/parallels/iso/step_set_boot_order.go b/builder/parallels/iso/step_set_boot_order.go index a32249173..cfcda6080 100644 --- a/builder/parallels/iso/step_set_boot_order.go +++ b/builder/parallels/iso/step_set_boot_order.go @@ -1,11 +1,12 @@ package iso import ( + "context" "fmt" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step sets the device boot order for the virtual machine. @@ -18,7 +19,7 @@ import ( // Produces: type stepSetBootOrder struct{} -func (s *stepSetBootOrder) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepSetBootOrder) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(parallelscommon.Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/parallels/pvm/builder.go b/builder/parallels/pvm/builder.go index 5db72bbaa..1e0d3c49a 100644 --- a/builder/parallels/pvm/builder.go +++ b/builder/parallels/pvm/builder.go @@ -8,8 +8,8 @@ import ( parallelscommon "github.com/hashicorp/packer/builder/parallels/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // Builder implements packer.Builder and builds the actual Parallels diff --git a/builder/parallels/pvm/step_import.go b/builder/parallels/pvm/step_import.go index 91b8878af..0907c6b44 100644 --- a/builder/parallels/pvm/step_import.go +++ b/builder/parallels/pvm/step_import.go @@ -1,11 +1,12 @@ package pvm import ( + "context" "fmt" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step imports an PVM VM into Parallels. @@ -15,7 +16,7 @@ type StepImport struct { vmName string } -func (s *StepImport) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepImport) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(parallelscommon.Driver) ui := state.Get("ui").(packer.Ui) config := state.Get("config").(*Config) diff --git a/builder/parallels/pvm/step_test.go b/builder/parallels/pvm/step_test.go index 827850a35..9d891c637 100644 --- a/builder/parallels/pvm/step_test.go +++ b/builder/parallels/pvm/step_test.go @@ -5,8 +5,8 @@ import ( "testing" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testState(t *testing.T) multistep.StateBag { diff --git a/builder/profitbricks/builder.go b/builder/profitbricks/builder.go index 42dc148d3..6a1428075 100644 --- a/builder/profitbricks/builder.go +++ b/builder/profitbricks/builder.go @@ -6,8 +6,8 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const BuilderId = "packer.profitbricks" diff --git a/builder/profitbricks/ssh.go b/builder/profitbricks/ssh.go index 3b0c93f31..d56696330 100644 --- a/builder/profitbricks/ssh.go +++ b/builder/profitbricks/ssh.go @@ -4,7 +4,7 @@ import ( "fmt" "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" gossh "golang.org/x/crypto/ssh" ) diff --git a/builder/profitbricks/step_create_server.go b/builder/profitbricks/step_create_server.go index a4de3cb19..00742762a 100644 --- a/builder/profitbricks/step_create_server.go +++ b/builder/profitbricks/step_create_server.go @@ -1,6 +1,7 @@ package profitbricks import ( + "context" "encoding/json" "errors" "fmt" @@ -8,14 +9,14 @@ import ( "strings" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/profitbricks/profitbricks-sdk-go" ) type stepCreateServer struct{} -func (s *stepCreateServer) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateServer) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) c := state.Get("config").(*Config) diff --git a/builder/profitbricks/step_create_ssh_key.go b/builder/profitbricks/step_create_ssh_key.go index 963afdf8c..be0b973a8 100644 --- a/builder/profitbricks/step_create_ssh_key.go +++ b/builder/profitbricks/step_create_ssh_key.go @@ -1,13 +1,14 @@ package profitbricks import ( + "context" "crypto/x509" "encoding/pem" "fmt" "io/ioutil" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "golang.org/x/crypto/ssh" ) @@ -16,7 +17,7 @@ type StepCreateSSHKey struct { DebugKeyPath string } -func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateSSHKey) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) c := state.Get("config").(*Config) diff --git a/builder/profitbricks/step_take_snapshot.go b/builder/profitbricks/step_take_snapshot.go index 822ea8699..a3bfe2d7d 100644 --- a/builder/profitbricks/step_take_snapshot.go +++ b/builder/profitbricks/step_take_snapshot.go @@ -1,17 +1,18 @@ package profitbricks import ( + "context" "encoding/json" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/profitbricks/profitbricks-sdk-go" ) type stepTakeSnapshot struct{} -func (s *stepTakeSnapshot) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepTakeSnapshot) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) c := state.Get("config").(*Config) diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 43ec6b4c3..e926e3a17 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -13,9 +13,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) const BuilderId = "transcend.qemu" diff --git a/builder/qemu/driver.go b/builder/qemu/driver.go index 632490114..eb1992ba6 100644 --- a/builder/qemu/driver.go +++ b/builder/qemu/driver.go @@ -14,7 +14,7 @@ import ( "time" "unicode" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) type DriverCancelCallback func(state multistep.StateBag) bool diff --git a/builder/qemu/ssh.go b/builder/qemu/ssh.go index 1881613fd..9c565eb32 100644 --- a/builder/qemu/ssh.go +++ b/builder/qemu/ssh.go @@ -3,7 +3,7 @@ package qemu import ( commonssh "github.com/hashicorp/packer/common/ssh" "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" gossh "golang.org/x/crypto/ssh" ) diff --git a/builder/qemu/step_boot_wait.go b/builder/qemu/step_boot_wait.go index 36625b8df..0c3935004 100644 --- a/builder/qemu/step_boot_wait.go +++ b/builder/qemu/step_boot_wait.go @@ -1,17 +1,18 @@ package qemu import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // stepBootWait waits the configured time period. type stepBootWait struct{} -func (s *stepBootWait) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepBootWait) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/qemu/step_configure_vnc.go b/builder/qemu/step_configure_vnc.go index 2cbfd6820..1f1cd088d 100644 --- a/builder/qemu/step_configure_vnc.go +++ b/builder/qemu/step_configure_vnc.go @@ -1,13 +1,14 @@ package qemu import ( + "context" "fmt" "log" "math/rand" "net" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step configures the VM to enable the VNC server. @@ -20,7 +21,7 @@ import ( // vnc_port uint - The port that VNC is configured to listen on. type stepConfigureVNC struct{} -func (stepConfigureVNC) Run(state multistep.StateBag) multistep.StepAction { +func (stepConfigureVNC) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/qemu/step_convert_disk.go b/builder/qemu/step_convert_disk.go index db7fe52c3..bc5c3f3b1 100644 --- a/builder/qemu/step_convert_disk.go +++ b/builder/qemu/step_convert_disk.go @@ -1,11 +1,12 @@ package qemu import ( + "context" "fmt" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "os" ) @@ -14,7 +15,7 @@ import ( // hard drive for the virtual machine. type stepConvertDisk struct{} -func (s *stepConvertDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepConvertDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) diskName := state.Get("disk_filename").(string) diff --git a/builder/qemu/step_copy_disk.go b/builder/qemu/step_copy_disk.go index 633d8d6b8..51ca47a1d 100644 --- a/builder/qemu/step_copy_disk.go +++ b/builder/qemu/step_copy_disk.go @@ -1,18 +1,19 @@ package qemu import ( + "context" "fmt" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step copies the virtual disk that will be used as the // hard drive for the virtual machine. type stepCopyDisk struct{} -func (s *stepCopyDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCopyDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) isoPath := state.Get("iso_path").(string) diff --git a/builder/qemu/step_create_disk.go b/builder/qemu/step_create_disk.go index 5d844e2a0..4472903f1 100644 --- a/builder/qemu/step_create_disk.go +++ b/builder/qemu/step_create_disk.go @@ -1,18 +1,19 @@ package qemu import ( + "context" "fmt" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step creates the virtual disk that will be used as the // hard drive for the virtual machine. type stepCreateDisk struct{} -func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/qemu/step_forward_ssh.go b/builder/qemu/step_forward_ssh.go index 7737fcbd8..6e9efaca1 100644 --- a/builder/qemu/step_forward_ssh.go +++ b/builder/qemu/step_forward_ssh.go @@ -1,13 +1,14 @@ package qemu import ( + "context" "fmt" "log" "math/rand" "net" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step adds a NAT port forwarding definition so that SSH is available @@ -18,7 +19,7 @@ import ( // Produces: type stepForwardSSH struct{} -func (s *stepForwardSSH) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepForwardSSH) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/qemu/step_prepare_output_dir.go b/builder/qemu/step_prepare_output_dir.go index b5f96c5ca..8eeebb4e1 100644 --- a/builder/qemu/step_prepare_output_dir.go +++ b/builder/qemu/step_prepare_output_dir.go @@ -1,17 +1,18 @@ package qemu import ( + "context" "log" "os" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepPrepareOutputDir struct{} -func (stepPrepareOutputDir) Run(state multistep.StateBag) multistep.StepAction { +func (stepPrepareOutputDir) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/qemu/step_resize_disk.go b/builder/qemu/step_resize_disk.go index fbbd8d572..8ffab5931 100644 --- a/builder/qemu/step_resize_disk.go +++ b/builder/qemu/step_resize_disk.go @@ -1,18 +1,19 @@ package qemu import ( + "context" "fmt" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step resizes the virtual disk that will be used as the // hard drive for the virtual machine. type stepResizeDisk struct{} -func (s *stepResizeDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepResizeDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/qemu/step_run.go b/builder/qemu/step_run.go index dc9dd2faa..c524d5514 100644 --- a/builder/qemu/step_run.go +++ b/builder/qemu/step_run.go @@ -1,15 +1,16 @@ package qemu import ( + "context" "fmt" "log" "path/filepath" "strconv" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) // stepRun runs the virtual machine @@ -27,7 +28,7 @@ type qemuArgsTemplateData struct { SSHHostPort uint } -func (s *stepRun) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepRun) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/qemu/step_set_iso.go b/builder/qemu/step_set_iso.go index f32a2687b..dba34777f 100644 --- a/builder/qemu/step_set_iso.go +++ b/builder/qemu/step_set_iso.go @@ -1,11 +1,12 @@ package qemu import ( + "context" "fmt" "net/http" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step set iso_patch to available url @@ -14,7 +15,7 @@ type stepSetISO struct { Url []string } -func (s *stepSetISO) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepSetISO) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) iso_path := "" diff --git a/builder/qemu/step_shutdown.go b/builder/qemu/step_shutdown.go index 88fa42c34..9c5f89f6c 100644 --- a/builder/qemu/step_shutdown.go +++ b/builder/qemu/step_shutdown.go @@ -1,13 +1,14 @@ package qemu import ( + "context" "errors" "fmt" "log" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step shuts down the machine. It first attempts to do so gracefully, @@ -23,7 +24,7 @@ import ( // type stepShutdown struct{} -func (s *stepShutdown) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepShutdown) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/qemu/step_type_boot_command.go b/builder/qemu/step_type_boot_command.go index 97e05b7ea..f1dc895e9 100644 --- a/builder/qemu/step_type_boot_command.go +++ b/builder/qemu/step_type_boot_command.go @@ -1,6 +1,7 @@ package qemu import ( + "context" "fmt" "log" "net" @@ -13,10 +14,10 @@ import ( "os" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" "github.com/mitchellh/go-vnc" - "github.com/mitchellh/multistep" ) const KeyLeftShift uint32 = 0xFFE1 @@ -39,7 +40,7 @@ type bootCommandTemplateData struct { // type stepTypeBootCommand struct{} -func (s *stepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepTypeBootCommand) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) debug := state.Get("debug").(bool) httpPort := state.Get("http_port").(uint) diff --git a/builder/triton/builder.go b/builder/triton/builder.go index 3e572e0a4..f2937a702 100644 --- a/builder/triton/builder.go +++ b/builder/triton/builder.go @@ -7,8 +7,8 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const ( diff --git a/builder/triton/ssh.go b/builder/triton/ssh.go index 14fd26e31..179b94215 100644 --- a/builder/triton/ssh.go +++ b/builder/triton/ssh.go @@ -9,7 +9,7 @@ import ( "os" packerssh "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" ) diff --git a/builder/triton/step_create_image_from_machine.go b/builder/triton/step_create_image_from_machine.go index 76c46a768..425a6690b 100644 --- a/builder/triton/step_create_image_from_machine.go +++ b/builder/triton/step_create_image_from_machine.go @@ -1,11 +1,12 @@ package triton import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCreateImageFromMachine creates an image with the specified attributes @@ -13,7 +14,7 @@ import ( // The machine must be in the "stopped" state prior to this step being run. type StepCreateImageFromMachine struct{} -func (s *StepCreateImageFromMachine) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateImageFromMachine) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/triton/step_create_image_from_machine_test.go b/builder/triton/step_create_image_from_machine_test.go index 36ee43f82..34eb95c8c 100644 --- a/builder/triton/step_create_image_from_machine_test.go +++ b/builder/triton/step_create_image_from_machine_test.go @@ -1,10 +1,11 @@ package triton import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepCreateImageFromMachine(t *testing.T) { @@ -14,7 +15,7 @@ func TestStepCreateImageFromMachine(t *testing.T) { state.Put("machine", "test-machine-id") - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -36,7 +37,7 @@ func TestStepCreateImageFromMachine_CreateImageFromMachineError(t *testing.T) { driver.CreateImageFromMachineErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -59,7 +60,7 @@ func TestStepCreateImageFromMachine_WaitForImageCreationError(t *testing.T) { driver.WaitForImageCreationErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/triton/step_create_source_machine.go b/builder/triton/step_create_source_machine.go index ae51fc60e..c3097fae2 100644 --- a/builder/triton/step_create_source_machine.go +++ b/builder/triton/step_create_source_machine.go @@ -1,18 +1,19 @@ package triton import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCreateSourceMachine creates an machine with the specified attributes // and waits for it to become available for provisioners. type StepCreateSourceMachine struct{} -func (s *StepCreateSourceMachine) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateSourceMachine) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(Config) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/triton/step_create_source_machine_test.go b/builder/triton/step_create_source_machine_test.go index 56f5d5940..78d97ad5e 100644 --- a/builder/triton/step_create_source_machine_test.go +++ b/builder/triton/step_create_source_machine_test.go @@ -1,10 +1,11 @@ package triton import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepCreateSourceMachine(t *testing.T) { @@ -14,7 +15,7 @@ func TestStepCreateSourceMachine(t *testing.T) { driver := state.Get("driver").(*DriverMock) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -39,7 +40,7 @@ func TestStepCreateSourceMachine_CreateMachineError(t *testing.T) { driver.CreateMachineErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -61,7 +62,7 @@ func TestStepCreateSourceMachine_WaitForMachineStateError(t *testing.T) { driver.WaitForMachineStateErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -81,7 +82,7 @@ func TestStepCreateSourceMachine_StopMachineError(t *testing.T) { driver := state.Get("driver").(*DriverMock) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -109,7 +110,7 @@ func TestStepCreateSourceMachine_WaitForMachineStoppedError(t *testing.T) { driver := state.Get("driver").(*DriverMock) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -137,7 +138,7 @@ func TestStepCreateSourceMachine_DeleteMachineError(t *testing.T) { driver := state.Get("driver").(*DriverMock) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } diff --git a/builder/triton/step_delete_machine.go b/builder/triton/step_delete_machine.go index d766f9833..8f9e1bc1f 100644 --- a/builder/triton/step_delete_machine.go +++ b/builder/triton/step_delete_machine.go @@ -1,17 +1,18 @@ package triton import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepDeleteMachine deletes the machine with the ID specified in state["machine"] type StepDeleteMachine struct{} -func (s *StepDeleteMachine) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepDeleteMachine) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/triton/step_delete_machine_test.go b/builder/triton/step_delete_machine_test.go index bca82b89a..421024d58 100644 --- a/builder/triton/step_delete_machine_test.go +++ b/builder/triton/step_delete_machine_test.go @@ -1,10 +1,11 @@ package triton import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepDeleteMachine(t *testing.T) { @@ -17,7 +18,7 @@ func TestStepDeleteMachine(t *testing.T) { machineId := "test-machine-id" state.Put("machine", machineId) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -40,7 +41,7 @@ func TestStepDeleteMachine_DeleteMachineError(t *testing.T) { driver.DeleteMachineErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -65,7 +66,7 @@ func TestStepDeleteMachine_WaitForMachineDeletionError(t *testing.T) { driver.WaitForMachineDeletionErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/triton/step_stop_machine.go b/builder/triton/step_stop_machine.go index 00eb75958..73fa3f4d6 100644 --- a/builder/triton/step_stop_machine.go +++ b/builder/triton/step_stop_machine.go @@ -1,18 +1,19 @@ package triton import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepStopMachine stops the machine with the given Machine ID, and waits // for it to reach the stopped state. type StepStopMachine struct{} -func (s *StepStopMachine) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepStopMachine) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/triton/step_stop_machine_test.go b/builder/triton/step_stop_machine_test.go index 4609343e0..8f0f39d2d 100644 --- a/builder/triton/step_stop_machine_test.go +++ b/builder/triton/step_stop_machine_test.go @@ -1,10 +1,11 @@ package triton import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepStopMachine(t *testing.T) { @@ -17,7 +18,7 @@ func TestStepStopMachine(t *testing.T) { machineId := "test-machine-id" state.Put("machine", machineId) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } @@ -40,7 +41,7 @@ func TestStepStopMachine_StopMachineError(t *testing.T) { driver.StopMachineErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } @@ -61,7 +62,7 @@ func TestStepStopMachine_WaitForMachineStoppedError(t *testing.T) { driver.WaitForMachineStateErr = errors.New("error") - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } diff --git a/builder/triton/step_test.go b/builder/triton/step_test.go index fe647b42f..bccc398c7 100644 --- a/builder/triton/step_test.go +++ b/builder/triton/step_test.go @@ -4,8 +4,8 @@ import ( "bytes" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testState(t *testing.T) multistep.StateBag { diff --git a/builder/triton/step_wait_for_stop_to_not_fail.go b/builder/triton/step_wait_for_stop_to_not_fail.go index cd4df4704..de0a7cc84 100644 --- a/builder/triton/step_wait_for_stop_to_not_fail.go +++ b/builder/triton/step_wait_for_stop_to_not_fail.go @@ -1,10 +1,11 @@ package triton import ( + "context" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepWaitForStopNotToFail waits for 10 seconds before returning with continue @@ -12,7 +13,7 @@ import ( // they are started never actually stop. type StepWaitForStopNotToFail struct{} -func (s *StepWaitForStopNotToFail) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepWaitForStopNotToFail) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) ui.Say("Waiting 10 seconds to avoid potential SDC bug...") time.Sleep(10 * time.Second) diff --git a/builder/virtualbox/common/ssh.go b/builder/virtualbox/common/ssh.go index b09c0cc47..45a99fb29 100644 --- a/builder/virtualbox/common/ssh.go +++ b/builder/virtualbox/common/ssh.go @@ -3,7 +3,7 @@ package common import ( commonssh "github.com/hashicorp/packer/common/ssh" "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" gossh "golang.org/x/crypto/ssh" ) diff --git a/builder/virtualbox/common/step_attach_floppy.go b/builder/virtualbox/common/step_attach_floppy.go index 35c8d1822..6c73aa4b4 100644 --- a/builder/virtualbox/common/step_attach_floppy.go +++ b/builder/virtualbox/common/step_attach_floppy.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "io" "io/ioutil" @@ -8,8 +9,8 @@ import ( "os" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step attaches the ISO to the virtual machine. @@ -24,7 +25,7 @@ type StepAttachFloppy struct { floppyPath string } -func (s *StepAttachFloppy) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepAttachFloppy) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { // Determine if we even have a floppy disk to attach var floppyPath string if floppyPathRaw, ok := state.GetOk("floppy_path"); ok { diff --git a/builder/virtualbox/common/step_attach_floppy_test.go b/builder/virtualbox/common/step_attach_floppy_test.go index 93d62b6d8..32ad4a962 100644 --- a/builder/virtualbox/common/step_attach_floppy_test.go +++ b/builder/virtualbox/common/step_attach_floppy_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepAttachFloppy_impl(t *testing.T) { @@ -30,7 +31,7 @@ func TestStepAttachFloppy(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -61,7 +62,7 @@ func TestStepAttachFloppy_noFloppy(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/virtualbox/common/step_attach_guest_additions.go b/builder/virtualbox/common/step_attach_guest_additions.go index 0d883f817..d5698c372 100644 --- a/builder/virtualbox/common/step_attach_guest_additions.go +++ b/builder/virtualbox/common/step_attach_guest_additions.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step attaches the VirtualBox guest additions as a inserted CD onto @@ -24,7 +25,7 @@ type StepAttachGuestAdditions struct { GuestAdditionsMode string } -func (s *StepAttachGuestAdditions) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepAttachGuestAdditions) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/virtualbox/common/step_configure_vrdp.go b/builder/virtualbox/common/step_configure_vrdp.go index 9a966c508..6cc960ad3 100644 --- a/builder/virtualbox/common/step_configure_vrdp.go +++ b/builder/virtualbox/common/step_configure_vrdp.go @@ -1,13 +1,14 @@ package common import ( + "context" "fmt" "log" "math/rand" "net" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step configures the VM to enable the VRDP server @@ -26,7 +27,7 @@ type StepConfigureVRDP struct { VRDPPortMax uint } -func (s *StepConfigureVRDP) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepConfigureVRDP) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/virtualbox/common/step_download_guest_additions.go b/builder/virtualbox/common/step_download_guest_additions.go index 93f3952c2..facc60b6a 100644 --- a/builder/virtualbox/common/step_download_guest_additions.go +++ b/builder/virtualbox/common/step_download_guest_additions.go @@ -2,6 +2,7 @@ package common import ( "bytes" + "context" "fmt" "io" "io/ioutil" @@ -10,9 +11,9 @@ import ( "strings" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) var additionsVersionMap = map[string]string{ @@ -36,7 +37,7 @@ type StepDownloadGuestAdditions struct { Ctx interpolate.Context } -func (s *StepDownloadGuestAdditions) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepDownloadGuestAdditions) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { var action multistep.StepAction driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) @@ -113,7 +114,7 @@ func (s *StepDownloadGuestAdditions) Run(state multistep.StateBag) multistep.Ste if s.GuestAdditionsSHA256 != "" { checksum = s.GuestAdditionsSHA256 } else { - checksum, action = s.downloadAdditionsSHA256(state, version, additionsName) + checksum, action = s.downloadAdditionsSHA256(ctx, state, version, additionsName) if action != multistep.ActionContinue { return action } @@ -140,12 +141,12 @@ func (s *StepDownloadGuestAdditions) Run(state multistep.StateBag) multistep.Ste Url: []string{url}, } - return downStep.Run(state) + return downStep.Run(ctx, state) } func (s *StepDownloadGuestAdditions) Cleanup(state multistep.StateBag) {} -func (s *StepDownloadGuestAdditions) downloadAdditionsSHA256(state multistep.StateBag, additionsVersion string, additionsName string) (string, multistep.StepAction) { +func (s *StepDownloadGuestAdditions) downloadAdditionsSHA256(ctx context.Context, state multistep.StateBag, additionsVersion string, additionsName string) (string, multistep.StepAction) { // First things first, we get the list of checksums for the files available // for this version. checksumsUrl := fmt.Sprintf( @@ -169,7 +170,7 @@ func (s *StepDownloadGuestAdditions) downloadAdditionsSHA256(state multistep.Sta Url: []string{checksumsUrl}, } - action := downStep.Run(state) + action := downStep.Run(ctx, state) if action == multistep.ActionHalt { return "", action } diff --git a/builder/virtualbox/common/step_export.go b/builder/virtualbox/common/step_export.go index dab7d9ac3..03b02e8e4 100644 --- a/builder/virtualbox/common/step_export.go +++ b/builder/virtualbox/common/step_export.go @@ -1,14 +1,15 @@ package common import ( + "context" "fmt" "log" "path/filepath" "strings" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step cleans up forwarded ports and exports the VM to an OVF. @@ -25,7 +26,7 @@ type StepExport struct { SkipExport bool } -func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepExport) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/virtualbox/common/step_export_test.go b/builder/virtualbox/common/step_export_test.go index 30723bae7..6d37b3150 100644 --- a/builder/virtualbox/common/step_export_test.go +++ b/builder/virtualbox/common/step_export_test.go @@ -1,9 +1,10 @@ package common import ( + "context" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepExport_impl(t *testing.T) { @@ -19,7 +20,7 @@ func TestStepExport(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/virtualbox/common/step_forward_ssh.go b/builder/virtualbox/common/step_forward_ssh.go index 391573ced..b4e3b2f25 100644 --- a/builder/virtualbox/common/step_forward_ssh.go +++ b/builder/virtualbox/common/step_forward_ssh.go @@ -1,14 +1,15 @@ package common import ( + "context" "fmt" "log" "math/rand" "net" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step adds a NAT port forwarding definition so that SSH is available @@ -27,7 +28,7 @@ type StepForwardSSH struct { SkipNatMapping bool } -func (s *StepForwardSSH) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepForwardSSH) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/virtualbox/common/step_output_dir.go b/builder/virtualbox/common/step_output_dir.go index 0054d1994..fc39d08b2 100644 --- a/builder/virtualbox/common/step_output_dir.go +++ b/builder/virtualbox/common/step_output_dir.go @@ -1,14 +1,15 @@ package common import ( + "context" "fmt" "log" "os" "path/filepath" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepOutputDir sets up the output directory by creating it if it does @@ -21,7 +22,7 @@ type StepOutputDir struct { cleanup bool } -func (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepOutputDir) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) if _, err := os.Stat(s.Path); err == nil { diff --git a/builder/virtualbox/common/step_output_dir_test.go b/builder/virtualbox/common/step_output_dir_test.go index c742b5ddd..1e2f05c84 100644 --- a/builder/virtualbox/common/step_output_dir_test.go +++ b/builder/virtualbox/common/step_output_dir_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func testStepOutputDir(t *testing.T) *StepOutputDir { @@ -29,7 +30,7 @@ func TestStepOutputDir(t *testing.T) { step := testStepOutputDir(t) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -56,7 +57,7 @@ func TestStepOutputDir_exists(t *testing.T) { } // Test the run - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); !ok { @@ -75,7 +76,7 @@ func TestStepOutputDir_cancelled(t *testing.T) { step := testStepOutputDir(t) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -100,7 +101,7 @@ func TestStepOutputDir_halted(t *testing.T) { step := testStepOutputDir(t) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/virtualbox/common/step_remove_devices.go b/builder/virtualbox/common/step_remove_devices.go index 7860d53e9..835fd5af8 100644 --- a/builder/virtualbox/common/step_remove_devices.go +++ b/builder/virtualbox/common/step_remove_devices.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "log" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step removes any devices (floppy disks, ISOs, etc.) from the @@ -20,7 +21,7 @@ import ( // Produces: type StepRemoveDevices struct{} -func (s *StepRemoveDevices) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRemoveDevices) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/virtualbox/common/step_remove_devices_test.go b/builder/virtualbox/common/step_remove_devices_test.go index 705648e33..0a548bbd2 100644 --- a/builder/virtualbox/common/step_remove_devices_test.go +++ b/builder/virtualbox/common/step_remove_devices_test.go @@ -1,9 +1,10 @@ package common import ( + "context" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepRemoveDevices_impl(t *testing.T) { @@ -19,7 +20,7 @@ func TestStepRemoveDevices(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -42,7 +43,7 @@ func TestStepRemoveDevices_attachedIso(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -69,7 +70,7 @@ func TestStepRemoveDevices_attachedIsoOnSata(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -95,7 +96,7 @@ func TestStepRemoveDevices_floppyPath(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/virtualbox/common/step_run.go b/builder/virtualbox/common/step_run.go index 3019c57d6..62d98d894 100644 --- a/builder/virtualbox/common/step_run.go +++ b/builder/virtualbox/common/step_run.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step starts the virtual machine. @@ -23,7 +24,7 @@ type StepRun struct { vmName string } -func (s *StepRun) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRun) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/virtualbox/common/step_shutdown.go b/builder/virtualbox/common/step_shutdown.go index 11a7cb3ac..af2539cac 100644 --- a/builder/virtualbox/common/step_shutdown.go +++ b/builder/virtualbox/common/step_shutdown.go @@ -1,13 +1,14 @@ package common import ( + "context" "errors" "fmt" "log" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step shuts down the machine. It first attempts to do so gracefully, @@ -27,7 +28,7 @@ type StepShutdown struct { Delay time.Duration } -func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepShutdown) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/virtualbox/common/step_shutdown_test.go b/builder/virtualbox/common/step_shutdown_test.go index f83c65a8d..44bd1d927 100644 --- a/builder/virtualbox/common/step_shutdown_test.go +++ b/builder/virtualbox/common/step_shutdown_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "testing" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func TestStepShutdown_impl(t *testing.T) { @@ -23,7 +24,7 @@ func TestStepShutdown_noShutdownCommand(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -60,7 +61,7 @@ func TestStepShutdown_shutdownCommand(t *testing.T) { }() // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -97,7 +98,7 @@ func TestStepShutdown_shutdownTimeout(t *testing.T) { }() // Test the run - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); !ok { @@ -129,7 +130,7 @@ func TestStepShutdown_shutdownDelay(t *testing.T) { // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } testDuration := time.Since(start).Seconds() @@ -154,7 +155,7 @@ func TestStepShutdown_shutdownDelay(t *testing.T) { }() // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } testDuration = time.Since(start).Seconds() diff --git a/builder/virtualbox/common/step_suppress_messages.go b/builder/virtualbox/common/step_suppress_messages.go index d6b2dcbbe..369911bdb 100644 --- a/builder/virtualbox/common/step_suppress_messages.go +++ b/builder/virtualbox/common/step_suppress_messages.go @@ -1,18 +1,19 @@ package common import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step sets some variables in VirtualBox so that annoying // pop-up messages don't exist. type StepSuppressMessages struct{} -func (StepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction { +func (StepSuppressMessages) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/virtualbox/common/step_suppress_messages_test.go b/builder/virtualbox/common/step_suppress_messages_test.go index 69c947835..c37af7826 100644 --- a/builder/virtualbox/common/step_suppress_messages_test.go +++ b/builder/virtualbox/common/step_suppress_messages_test.go @@ -1,10 +1,11 @@ package common import ( + "context" "errors" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepSuppressMessages_impl(t *testing.T) { @@ -18,7 +19,7 @@ func TestStepSuppressMessages(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -38,7 +39,7 @@ func TestStepSuppressMessages_error(t *testing.T) { driver.SuppressMessagesErr = errors.New("foo") // Test the run - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); !ok { diff --git a/builder/virtualbox/common/step_test.go b/builder/virtualbox/common/step_test.go index 140f6f619..c8a12abb6 100644 --- a/builder/virtualbox/common/step_test.go +++ b/builder/virtualbox/common/step_test.go @@ -4,8 +4,8 @@ import ( "bytes" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testState(t *testing.T) multistep.StateBag { diff --git a/builder/virtualbox/common/step_type_boot_command.go b/builder/virtualbox/common/step_type_boot_command.go index 3220ca8b8..cb5b43648 100644 --- a/builder/virtualbox/common/step_type_boot_command.go +++ b/builder/virtualbox/common/step_type_boot_command.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "log" "strings" @@ -9,9 +10,9 @@ import ( "unicode/utf8" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) const KeyLeftShift uint32 = 0xFFE1 @@ -38,7 +39,7 @@ type StepTypeBootCommand struct { Ctx interpolate.Context } -func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepTypeBootCommand) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { debug := state.Get("debug").(bool) driver := state.Get("driver").(Driver) httpPort := state.Get("http_port").(uint) diff --git a/builder/virtualbox/common/step_upload_guest_additions.go b/builder/virtualbox/common/step_upload_guest_additions.go index a98676555..c77ef7d22 100644 --- a/builder/virtualbox/common/step_upload_guest_additions.go +++ b/builder/virtualbox/common/step_upload_guest_additions.go @@ -1,13 +1,14 @@ package common import ( + "context" "fmt" "log" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type guestAdditionsPathTemplate struct { @@ -21,7 +22,7 @@ type StepUploadGuestAdditions struct { Ctx interpolate.Context } -func (s *StepUploadGuestAdditions) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepUploadGuestAdditions) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/virtualbox/common/step_upload_version.go b/builder/virtualbox/common/step_upload_version.go index c9481c49b..deaf8824d 100644 --- a/builder/virtualbox/common/step_upload_version.go +++ b/builder/virtualbox/common/step_upload_version.go @@ -2,11 +2,12 @@ package common import ( "bytes" + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step uploads a file containing the VirtualBox version, which @@ -15,7 +16,7 @@ type StepUploadVersion struct { Path string } -func (s *StepUploadVersion) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepUploadVersion) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/virtualbox/common/step_upload_version_test.go b/builder/virtualbox/common/step_upload_version_test.go index 8aaf9cc90..998d35f0e 100644 --- a/builder/virtualbox/common/step_upload_version_test.go +++ b/builder/virtualbox/common/step_upload_version_test.go @@ -1,10 +1,11 @@ package common import ( + "context" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func TestStepUploadVersion_impl(t *testing.T) { @@ -23,7 +24,7 @@ func TestStepUploadVersion(t *testing.T) { driver.VersionResult = "foo" // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -48,7 +49,7 @@ func TestStepUploadVersion_noPath(t *testing.T) { state.Put("communicator", comm) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/virtualbox/common/step_vboxmanage.go b/builder/virtualbox/common/step_vboxmanage.go index 7544dbbce..948cae884 100644 --- a/builder/virtualbox/common/step_vboxmanage.go +++ b/builder/virtualbox/common/step_vboxmanage.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type commandTemplate struct { @@ -27,7 +28,7 @@ type StepVBoxManage struct { Ctx interpolate.Context } -func (s *StepVBoxManage) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepVBoxManage) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmName := state.Get("vmName").(string) diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index 82cf36409..0d1be21dd 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -10,9 +10,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) const BuilderId = "mitchellh.virtualbox" diff --git a/builder/virtualbox/iso/step_attach_iso.go b/builder/virtualbox/iso/step_attach_iso.go index 1eb87ff92..619d61afd 100644 --- a/builder/virtualbox/iso/step_attach_iso.go +++ b/builder/virtualbox/iso/step_attach_iso.go @@ -1,11 +1,12 @@ package iso import ( + "context" "fmt" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step attaches the ISO to the virtual machine. @@ -17,7 +18,7 @@ type stepAttachISO struct { diskPath string } -func (s *stepAttachISO) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepAttachISO) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(vboxcommon.Driver) isoPath := state.Get("iso_path").(string) diff --git a/builder/virtualbox/iso/step_create_disk.go b/builder/virtualbox/iso/step_create_disk.go index 6051768af..7c5b03e4f 100644 --- a/builder/virtualbox/iso/step_create_disk.go +++ b/builder/virtualbox/iso/step_create_disk.go @@ -1,11 +1,12 @@ package iso import ( + "context" "fmt" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "path/filepath" "strconv" @@ -16,7 +17,7 @@ import ( // hard drive for the virtual machine. type stepCreateDisk struct{} -func (s *stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(vboxcommon.Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/virtualbox/iso/step_create_vm.go b/builder/virtualbox/iso/step_create_vm.go index ad1f72eaf..72a556737 100644 --- a/builder/virtualbox/iso/step_create_vm.go +++ b/builder/virtualbox/iso/step_create_vm.go @@ -1,11 +1,12 @@ package iso import ( + "context" "fmt" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step creates the actual virtual machine. @@ -16,7 +17,7 @@ type stepCreateVM struct { vmName string } -func (s *stepCreateVM) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateVM) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(vboxcommon.Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/virtualbox/ovf/builder.go b/builder/virtualbox/ovf/builder.go index 475bbebcf..d9783244f 100644 --- a/builder/virtualbox/ovf/builder.go +++ b/builder/virtualbox/ovf/builder.go @@ -8,8 +8,8 @@ import ( vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // Builder implements packer.Builder and builds the actual VirtualBox diff --git a/builder/virtualbox/ovf/step_import.go b/builder/virtualbox/ovf/step_import.go index 33e71fc24..5e066d83a 100644 --- a/builder/virtualbox/ovf/step_import.go +++ b/builder/virtualbox/ovf/step_import.go @@ -1,11 +1,12 @@ package ovf import ( + "context" "fmt" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step imports an OVF VM into VirtualBox. @@ -16,7 +17,7 @@ type StepImport struct { vmName string } -func (s *StepImport) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepImport) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(vboxcommon.Driver) ui := state.Get("ui").(packer.Ui) vmPath := state.Get("vm_path").(string) diff --git a/builder/virtualbox/ovf/step_import_test.go b/builder/virtualbox/ovf/step_import_test.go index dcaf013b5..ffaecc0ba 100644 --- a/builder/virtualbox/ovf/step_import_test.go +++ b/builder/virtualbox/ovf/step_import_test.go @@ -1,10 +1,11 @@ package ovf import ( + "context" "testing" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepImport_impl(t *testing.T) { @@ -23,7 +24,7 @@ func TestStepImport(t *testing.T) { driver := state.Get("driver").(*vboxcommon.DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/virtualbox/ovf/step_test.go b/builder/virtualbox/ovf/step_test.go index 805d435bc..4f9a0f9d8 100644 --- a/builder/virtualbox/ovf/step_test.go +++ b/builder/virtualbox/ovf/step_test.go @@ -5,8 +5,8 @@ import ( "testing" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testState(t *testing.T) multistep.StateBag { diff --git a/builder/vmware/common/driver.go b/builder/vmware/common/driver.go index 4e4f38e02..99c9f686c 100644 --- a/builder/vmware/common/driver.go +++ b/builder/vmware/common/driver.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) // A driver is able to talk to VMware, control virtual machines, etc. diff --git a/builder/vmware/common/driver_fusion5.go b/builder/vmware/common/driver_fusion5.go index a10f11902..9545d3e81 100644 --- a/builder/vmware/common/driver_fusion5.go +++ b/builder/vmware/common/driver_fusion5.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) // Fusion5Driver is a driver that can run VMware Fusion 5. diff --git a/builder/vmware/common/driver_mock.go b/builder/vmware/common/driver_mock.go index fcd80a51b..9291be976 100644 --- a/builder/vmware/common/driver_mock.go +++ b/builder/vmware/common/driver_mock.go @@ -3,7 +3,7 @@ package common import ( "sync" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) type DriverMock struct { diff --git a/builder/vmware/common/driver_player5.go b/builder/vmware/common/driver_player5.go index 1552e92ea..311e5019c 100644 --- a/builder/vmware/common/driver_player5.go +++ b/builder/vmware/common/driver_player5.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) // Player5Driver is a driver that can run VMware Player 5 on Linux. diff --git a/builder/vmware/common/driver_workstation9.go b/builder/vmware/common/driver_workstation9.go index debcefcbc..d870a4cda 100644 --- a/builder/vmware/common/driver_workstation9.go +++ b/builder/vmware/common/driver_workstation9.go @@ -9,7 +9,7 @@ import ( "path/filepath" "strings" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) // Workstation9Driver is a driver that can run VMware Workstation 9 diff --git a/builder/vmware/common/ssh.go b/builder/vmware/common/ssh.go index 0d94599f8..871ba8df9 100644 --- a/builder/vmware/common/ssh.go +++ b/builder/vmware/common/ssh.go @@ -9,7 +9,7 @@ import ( commonssh "github.com/hashicorp/packer/common/ssh" "github.com/hashicorp/packer/communicator/ssh" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" gossh "golang.org/x/crypto/ssh" ) diff --git a/builder/vmware/common/step_clean_files.go b/builder/vmware/common/step_clean_files.go index b6d81293f..08d14cf63 100644 --- a/builder/vmware/common/step_clean_files.go +++ b/builder/vmware/common/step_clean_files.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "os" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // These are the extensions of files that are important for the function @@ -24,7 +25,7 @@ var KeepFileExtensions = []string{".nvram", ".vmdk", ".vmsd", ".vmx", ".vmxf"} // type StepCleanFiles struct{} -func (StepCleanFiles) Run(state multistep.StateBag) multistep.StepAction { +func (StepCleanFiles) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { dir := state.Get("dir").(OutputDir) ui := state.Get("ui").(packer.Ui) diff --git a/builder/vmware/common/step_clean_vmx.go b/builder/vmware/common/step_clean_vmx.go index 853233e89..f112227f8 100644 --- a/builder/vmware/common/step_clean_vmx.go +++ b/builder/vmware/common/step_clean_vmx.go @@ -1,13 +1,14 @@ package common import ( + "context" "fmt" "log" "regexp" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step cleans up the VMX by removing or changing this prior to @@ -24,7 +25,7 @@ type StepCleanVMX struct { VNCEnabled bool } -func (s StepCleanVMX) Run(state multistep.StateBag) multistep.StepAction { +func (s StepCleanVMX) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) vmxPath := state.Get("vmx_path").(string) diff --git a/builder/vmware/common/step_clean_vmx_test.go b/builder/vmware/common/step_clean_vmx_test.go index aad39e8b0..0f4df3df2 100644 --- a/builder/vmware/common/step_clean_vmx_test.go +++ b/builder/vmware/common/step_clean_vmx_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepCleanVMX_impl(t *testing.T) { @@ -21,7 +22,7 @@ func TestStepCleanVMX(t *testing.T) { state.Put("vmx_path", vmxPath) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -42,7 +43,7 @@ func TestStepCleanVMX_floppyPath(t *testing.T) { state.Put("vmx_path", vmxPath) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -91,7 +92,7 @@ func TestStepCleanVMX_isoPath(t *testing.T) { state.Put("vmx_path", vmxPath) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -143,7 +144,7 @@ func TestStepCleanVMX_ethernet(t *testing.T) { state.Put("vmx_path", vmxPath) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/vmware/common/step_compact_disk.go b/builder/vmware/common/step_compact_disk.go index b53dd14c3..e7823e3ba 100644 --- a/builder/vmware/common/step_compact_disk.go +++ b/builder/vmware/common/step_compact_disk.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step compacts the virtual disk for the VM unless the "skip_compaction" @@ -22,7 +23,7 @@ type StepCompactDisk struct { Skip bool } -func (s StepCompactDisk) Run(state multistep.StateBag) multistep.StepAction { +func (s StepCompactDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) full_disk_path := state.Get("full_disk_path").(string) diff --git a/builder/vmware/common/step_compact_disk_test.go b/builder/vmware/common/step_compact_disk_test.go index e59a99a90..365e9ccb2 100644 --- a/builder/vmware/common/step_compact_disk_test.go +++ b/builder/vmware/common/step_compact_disk_test.go @@ -1,9 +1,10 @@ package common import ( + "context" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepCompactDisk_impl(t *testing.T) { @@ -19,7 +20,7 @@ func TestStepCompactDisk(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -45,7 +46,7 @@ func TestStepCompactDisk_skip(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/vmware/common/step_configure_vmx.go b/builder/vmware/common/step_configure_vmx.go index 854922a2c..155234ac4 100644 --- a/builder/vmware/common/step_configure_vmx.go +++ b/builder/vmware/common/step_configure_vmx.go @@ -1,14 +1,15 @@ package common import ( + "context" "fmt" "io/ioutil" "log" "regexp" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step configures a VMX by setting some default settings as well @@ -21,7 +22,7 @@ type StepConfigureVMX struct { SkipFloppy bool } -func (s *StepConfigureVMX) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepConfigureVMX) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) vmxPath := state.Get("vmx_path").(string) diff --git a/builder/vmware/common/step_configure_vmx_test.go b/builder/vmware/common/step_configure_vmx_test.go index 293269e3f..c5e242a51 100644 --- a/builder/vmware/common/step_configure_vmx_test.go +++ b/builder/vmware/common/step_configure_vmx_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func testVMXFile(t *testing.T) string { @@ -34,7 +35,7 @@ func TestStepConfigureVMX(t *testing.T) { state.Put("vmx_path", vmxPath) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -87,7 +88,7 @@ func TestStepConfigureVMX_floppyPath(t *testing.T) { state.Put("vmx_path", vmxPath) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -144,7 +145,7 @@ func TestStepConfigureVMX_generatedAddresses(t *testing.T) { state.Put("vmx_path", vmxPath) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/vmware/common/step_configure_vnc.go b/builder/vmware/common/step_configure_vnc.go index 4e4798862..90aa4a998 100644 --- a/builder/vmware/common/step_configure_vnc.go +++ b/builder/vmware/common/step_configure_vnc.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "io/ioutil" "log" @@ -8,8 +9,8 @@ import ( "net" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step configures the VM to enable the VNC server. @@ -76,7 +77,7 @@ func VNCPassword(skipPassword bool) string { return string(password) } -func (s *StepConfigureVNC) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepConfigureVNC) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { if !s.Enabled { log.Println("Skipping VNC configuration step...") return multistep.ActionContinue diff --git a/builder/vmware/common/step_output_dir.go b/builder/vmware/common/step_output_dir.go index 2b679f1fc..90c71e18a 100644 --- a/builder/vmware/common/step_output_dir.go +++ b/builder/vmware/common/step_output_dir.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "log" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepOutputDir sets up the output directory by creating it if it does @@ -18,7 +19,7 @@ type StepOutputDir struct { success bool } -func (s *StepOutputDir) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepOutputDir) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { dir := state.Get("dir").(OutputDir) ui := state.Get("ui").(packer.Ui) diff --git a/builder/vmware/common/step_output_dir_test.go b/builder/vmware/common/step_output_dir_test.go index e748578bd..fe71bbea8 100644 --- a/builder/vmware/common/step_output_dir_test.go +++ b/builder/vmware/common/step_output_dir_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func testOutputDir(t *testing.T) *LocalOutputDir { @@ -32,7 +33,7 @@ func TestStepOutputDir(t *testing.T) { state.Put("dir", dir) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -62,7 +63,7 @@ func TestStepOutputDir_existsNoForce(t *testing.T) { } // Test the run - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); !ok { @@ -90,7 +91,7 @@ func TestStepOutputDir_existsForce(t *testing.T) { } // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -109,7 +110,7 @@ func TestStepOutputDir_cancel(t *testing.T) { state.Put("dir", dir) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -135,7 +136,7 @@ func TestStepOutputDir_halt(t *testing.T) { state.Put("dir", dir) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/vmware/common/step_prepare_tools.go b/builder/vmware/common/step_prepare_tools.go index f0566d91e..72f8f1488 100644 --- a/builder/vmware/common/step_prepare_tools.go +++ b/builder/vmware/common/step_prepare_tools.go @@ -1,10 +1,11 @@ package common import ( + "context" "fmt" "os" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) type StepPrepareTools struct { @@ -12,7 +13,7 @@ type StepPrepareTools struct { ToolsUploadFlavor string } -func (c *StepPrepareTools) Run(state multistep.StateBag) multistep.StepAction { +func (c *StepPrepareTools) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) if c.RemoteType == "esx5" { diff --git a/builder/vmware/common/step_prepare_tools_test.go b/builder/vmware/common/step_prepare_tools_test.go index 0326ea0d2..cddf0ffba 100644 --- a/builder/vmware/common/step_prepare_tools_test.go +++ b/builder/vmware/common/step_prepare_tools_test.go @@ -1,11 +1,12 @@ package common import ( + "context" "io/ioutil" "os" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepPrepareTools_impl(t *testing.T) { @@ -32,7 +33,7 @@ func TestStepPrepareTools(t *testing.T) { driver.ToolsIsoPathResult = tf.Name() // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -67,7 +68,7 @@ func TestStepPrepareTools_esx5(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -93,7 +94,7 @@ func TestStepPrepareTools_nonExist(t *testing.T) { driver.ToolsIsoPathResult = "foo" // Test the run - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); !ok { diff --git a/builder/vmware/common/step_run.go b/builder/vmware/common/step_run.go index 2ea61f899..f85d5948f 100644 --- a/builder/vmware/common/step_run.go +++ b/builder/vmware/common/step_run.go @@ -1,11 +1,12 @@ package common import ( + "context" "fmt" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step runs the created virtual machine. @@ -26,7 +27,7 @@ type StepRun struct { vmxPath string } -func (s *StepRun) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRun) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmxPath := state.Get("vmx_path").(string) diff --git a/builder/vmware/common/step_run_test.go b/builder/vmware/common/step_run_test.go index 9888cdf10..e89dcb1cf 100644 --- a/builder/vmware/common/step_run_test.go +++ b/builder/vmware/common/step_run_test.go @@ -1,9 +1,10 @@ package common import ( + "context" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepRun_impl(t *testing.T) { @@ -19,7 +20,7 @@ func TestStepRun(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -53,7 +54,7 @@ func TestStepRun_cleanupRunning(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/vmware/common/step_shutdown.go b/builder/vmware/common/step_shutdown.go index f0cf04aaf..bc8490ff3 100644 --- a/builder/vmware/common/step_shutdown.go +++ b/builder/vmware/common/step_shutdown.go @@ -2,6 +2,7 @@ package common import ( "bytes" + "context" "errors" "fmt" "log" @@ -9,8 +10,8 @@ import ( "strings" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step shuts down the machine. It first attempts to do so gracefully, @@ -33,7 +34,7 @@ type StepShutdown struct { Testing bool } -func (s *StepShutdown) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepShutdown) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := state.Get("communicator").(packer.Communicator) dir := state.Get("dir").(OutputDir) driver := state.Get("driver").(Driver) diff --git a/builder/vmware/common/step_shutdown_test.go b/builder/vmware/common/step_shutdown_test.go index b693527da..ed0eae486 100644 --- a/builder/vmware/common/step_shutdown_test.go +++ b/builder/vmware/common/step_shutdown_test.go @@ -1,14 +1,15 @@ package common import ( + "context" "io/ioutil" "os" "path/filepath" "testing" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testStepShutdownState(t *testing.T) multistep.StateBag { @@ -49,7 +50,7 @@ func TestStepShutdown_command(t *testing.T) { resultCh := make(chan multistep.StepAction, 1) go func() { - resultCh <- step.Run(state) + resultCh <- step.Run(context.Background(), state) }() select { @@ -94,7 +95,7 @@ func TestStepShutdown_noCommand(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -138,7 +139,7 @@ func TestStepShutdown_locks(t *testing.T) { resultCh := make(chan multistep.StepAction, 1) go func() { - resultCh <- step.Run(state) + resultCh <- step.Run(context.Background(), state) }() select { diff --git a/builder/vmware/common/step_suppress_messages.go b/builder/vmware/common/step_suppress_messages.go index a0a77b9ab..02928123a 100644 --- a/builder/vmware/common/step_suppress_messages.go +++ b/builder/vmware/common/step_suppress_messages.go @@ -1,17 +1,18 @@ package common import ( + "context" "fmt" "log" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step suppresses any messages that VMware product might show. type StepSuppressMessages struct{} -func (s *StepSuppressMessages) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepSuppressMessages) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) ui := state.Get("ui").(packer.Ui) vmxPath := state.Get("vmx_path").(string) diff --git a/builder/vmware/common/step_suppress_messages_test.go b/builder/vmware/common/step_suppress_messages_test.go index 998cfdb24..24044d470 100644 --- a/builder/vmware/common/step_suppress_messages_test.go +++ b/builder/vmware/common/step_suppress_messages_test.go @@ -1,9 +1,10 @@ package common import ( + "context" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepSuppressMessages_impl(t *testing.T) { @@ -19,7 +20,7 @@ func TestStepSuppressMessages(t *testing.T) { driver := state.Get("driver").(*DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/vmware/common/step_test.go b/builder/vmware/common/step_test.go index 140f6f619..c8a12abb6 100644 --- a/builder/vmware/common/step_test.go +++ b/builder/vmware/common/step_test.go @@ -4,8 +4,8 @@ import ( "bytes" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testState(t *testing.T) multistep.StateBag { diff --git a/builder/vmware/common/step_type_boot_command.go b/builder/vmware/common/step_type_boot_command.go index 28db3c72e..05c66de16 100644 --- a/builder/vmware/common/step_type_boot_command.go +++ b/builder/vmware/common/step_type_boot_command.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "log" "net" @@ -12,10 +13,10 @@ import ( "unicode/utf8" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" "github.com/mitchellh/go-vnc" - "github.com/mitchellh/multistep" ) const KeyLeftShift uint32 = 0xFFE1 @@ -42,7 +43,7 @@ type StepTypeBootCommand struct { Ctx interpolate.Context } -func (s *StepTypeBootCommand) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepTypeBootCommand) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { if !s.VNCEnabled { log.Println("Skipping boot command step...") return multistep.ActionContinue diff --git a/builder/vmware/common/step_upload_tools.go b/builder/vmware/common/step_upload_tools.go index dfa8fcb88..eed55ab0b 100644 --- a/builder/vmware/common/step_upload_tools.go +++ b/builder/vmware/common/step_upload_tools.go @@ -1,12 +1,13 @@ package common import ( + "context" "fmt" "os" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type toolsUploadPathTemplate struct { @@ -20,7 +21,7 @@ type StepUploadTools struct { Ctx interpolate.Context } -func (c *StepUploadTools) Run(state multistep.StateBag) multistep.StepAction { +func (c *StepUploadTools) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(Driver) if c.ToolsUploadFlavor == "" { diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 5fa15317f..1d2a29ac5 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -13,9 +13,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) const BuilderIdESX = "mitchellh.vmware-esx" diff --git a/builder/vmware/iso/driver_esx5.go b/builder/vmware/iso/driver_esx5.go index 8da66f0d2..f30451c65 100644 --- a/builder/vmware/iso/driver_esx5.go +++ b/builder/vmware/iso/driver_esx5.go @@ -16,8 +16,8 @@ import ( commonssh "github.com/hashicorp/packer/common/ssh" "github.com/hashicorp/packer/communicator/ssh" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" gossh "golang.org/x/crypto/ssh" ) diff --git a/builder/vmware/iso/driver_esx5_test.go b/builder/vmware/iso/driver_esx5_test.go index 6ce714ff1..0c0ef757e 100644 --- a/builder/vmware/iso/driver_esx5_test.go +++ b/builder/vmware/iso/driver_esx5_test.go @@ -6,7 +6,7 @@ import ( "testing" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestESX5Driver_implDriver(t *testing.T) { diff --git a/builder/vmware/iso/step_create_disk.go b/builder/vmware/iso/step_create_disk.go index 0985b70e5..ddee55c7f 100644 --- a/builder/vmware/iso/step_create_disk.go +++ b/builder/vmware/iso/step_create_disk.go @@ -1,12 +1,13 @@ package iso import ( + "context" "fmt" "path/filepath" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step creates the virtual disks for the VM. @@ -20,7 +21,7 @@ import ( // full_disk_path (string) - The full path to the created disk. type stepCreateDisk struct{} -func (stepCreateDisk) Run(state multistep.StateBag) multistep.StepAction { +func (stepCreateDisk) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) driver := state.Get("driver").(vmwcommon.Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/vmware/iso/step_create_vmx.go b/builder/vmware/iso/step_create_vmx.go index 1f4ee812f..029f2a31e 100644 --- a/builder/vmware/iso/step_create_vmx.go +++ b/builder/vmware/iso/step_create_vmx.go @@ -1,15 +1,16 @@ package iso import ( + "context" "fmt" "io/ioutil" "os" "path/filepath" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type vmxTemplateData struct { @@ -38,7 +39,7 @@ type stepCreateVMX struct { tempDir string } -func (s *stepCreateVMX) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateVMX) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) isoPath := state.Get("iso_path").(string) ui := state.Get("ui").(packer.Ui) diff --git a/builder/vmware/iso/step_export.go b/builder/vmware/iso/step_export.go index 91a2ce486..4f6df9ed4 100644 --- a/builder/vmware/iso/step_export.go +++ b/builder/vmware/iso/step_export.go @@ -2,6 +2,7 @@ package iso import ( "bytes" + "context" "fmt" "net/url" "os" @@ -9,8 +10,8 @@ import ( "runtime" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepExport struct { @@ -34,7 +35,7 @@ func (s *StepExport) generateArgs(c *Config, hidePassword bool) []string { return append(c.OVFToolOptions, args...) } -func (s *StepExport) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepExport) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { c := state.Get("config").(*Config) ui := state.Get("ui").(packer.Ui) diff --git a/builder/vmware/iso/step_export_test.go b/builder/vmware/iso/step_export_test.go index 1e5ba606d..27c2a0c36 100644 --- a/builder/vmware/iso/step_export_test.go +++ b/builder/vmware/iso/step_export_test.go @@ -1,9 +1,10 @@ package iso import ( + "context" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepExport_impl(t *testing.T) { @@ -18,7 +19,7 @@ func testStepExport_wrongtype_impl(t *testing.T, remoteType string) { config.RemoteType = "foo" state.Put("config", &config) - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/vmware/iso/step_register.go b/builder/vmware/iso/step_register.go index 509b6e017..c97800910 100644 --- a/builder/vmware/iso/step_register.go +++ b/builder/vmware/iso/step_register.go @@ -1,12 +1,13 @@ package iso import ( + "context" "fmt" "time" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type StepRegister struct { @@ -14,7 +15,7 @@ type StepRegister struct { Format string } -func (s *StepRegister) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepRegister) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(vmwcommon.Driver) ui := state.Get("ui").(packer.Ui) vmxPath := state.Get("vmx_path").(string) diff --git a/builder/vmware/iso/step_register_test.go b/builder/vmware/iso/step_register_test.go index 8bfed06e8..099e067ab 100644 --- a/builder/vmware/iso/step_register_test.go +++ b/builder/vmware/iso/step_register_test.go @@ -1,9 +1,10 @@ package iso import ( + "context" "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepRegister_impl(t *testing.T) { @@ -17,7 +18,7 @@ func TestStepRegister_regularDriver(t *testing.T) { state.Put("vmx_path", "foo") // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -41,7 +42,7 @@ func TestStepRegister_remoteDriver(t *testing.T) { state.Put("vmx_path", "foo") // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { @@ -81,7 +82,7 @@ func TestStepRegister_WithoutUnregister_remoteDriver(t *testing.T) { state.Put("vmx_path", "foo") // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/vmware/iso/step_remote_upload.go b/builder/vmware/iso/step_remote_upload.go index 76b30bfdf..c4dfda8e5 100644 --- a/builder/vmware/iso/step_remote_upload.go +++ b/builder/vmware/iso/step_remote_upload.go @@ -1,12 +1,13 @@ package iso import ( + "context" "fmt" "log" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // stepRemoteUpload uploads some thing from the state bag to a remote driver @@ -16,7 +17,7 @@ type stepRemoteUpload struct { Message string } -func (s *stepRemoteUpload) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepRemoteUpload) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(vmwcommon.Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/vmware/iso/step_test.go b/builder/vmware/iso/step_test.go index 6ac2ba05e..958ab4734 100644 --- a/builder/vmware/iso/step_test.go +++ b/builder/vmware/iso/step_test.go @@ -5,8 +5,8 @@ import ( "testing" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testState(t *testing.T) multistep.StateBag { diff --git a/builder/vmware/iso/step_upload_vmx.go b/builder/vmware/iso/step_upload_vmx.go index 0c9e17c28..f0fec436c 100644 --- a/builder/vmware/iso/step_upload_vmx.go +++ b/builder/vmware/iso/step_upload_vmx.go @@ -1,12 +1,13 @@ package iso import ( + "context" "fmt" "path/filepath" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step upload the VMX to the remote host @@ -22,7 +23,7 @@ type StepUploadVMX struct { RemoteType string } -func (c *StepUploadVMX) Run(state multistep.StateBag) multistep.StepAction { +func (c *StepUploadVMX) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(vmwcommon.Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index b7c70d548..97852b534 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -9,8 +9,8 @@ import ( vmwcommon "github.com/hashicorp/packer/builder/vmware/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/communicator" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // Builder implements packer.Builder and builds the actual VMware diff --git a/builder/vmware/vmx/step_clone_vmx.go b/builder/vmware/vmx/step_clone_vmx.go index eaa6607c5..f7874067c 100644 --- a/builder/vmware/vmx/step_clone_vmx.go +++ b/builder/vmware/vmx/step_clone_vmx.go @@ -1,13 +1,14 @@ package vmx import ( + "context" "fmt" "log" "path/filepath" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepCloneVMX takes a VMX file and clones the VM into the output directory. @@ -17,7 +18,7 @@ type StepCloneVMX struct { VMName string } -func (s *StepCloneVMX) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCloneVMX) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { driver := state.Get("driver").(vmwcommon.Driver) ui := state.Get("ui").(packer.Ui) diff --git a/builder/vmware/vmx/step_clone_vmx_test.go b/builder/vmware/vmx/step_clone_vmx_test.go index 3b4cea1d5..e086f0ce5 100644 --- a/builder/vmware/vmx/step_clone_vmx_test.go +++ b/builder/vmware/vmx/step_clone_vmx_test.go @@ -1,13 +1,14 @@ package vmx import ( + "context" "io/ioutil" "os" "path/filepath" "testing" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepCloneVMX_impl(t *testing.T) { @@ -43,7 +44,7 @@ func TestStepCloneVMX(t *testing.T) { driver := state.Get("driver").(*vmwcommon.DriverMock) // Test the run - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } if _, ok := state.GetOk("error"); ok { diff --git a/builder/vmware/vmx/step_test.go b/builder/vmware/vmx/step_test.go index 60e2f890c..81439b3c4 100644 --- a/builder/vmware/vmx/step_test.go +++ b/builder/vmware/vmx/step_test.go @@ -5,8 +5,8 @@ import ( "testing" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func testState(t *testing.T) multistep.StateBag { diff --git a/command/build.go b/command/build.go index de9da51ee..6f7659821 100644 --- a/command/build.go +++ b/command/build.go @@ -138,9 +138,11 @@ func (c BuildCommand) Run(args []string) int { m map[string][]packer.Artifact }{m: make(map[string][]packer.Artifact)} errors := make(map[string]error) + // ctx := context.Background() for _, b := range builds { // Increment the waitgroup so we wait for this item to finish properly wg.Add(1) + // buildCtx, cancelCtx := ctx.WithCancel() // Handle interrupts for this build sigCh := make(chan os.Signal, 1) @@ -154,6 +156,7 @@ func (c BuildCommand) Run(args []string) int { log.Printf("Stopping build: %s", b.Name()) b.Cancel() + //cancelCtx() log.Printf("Build cancelled: %s", b.Name()) }(b) diff --git a/common/multistep_debug.go b/common/multistep_debug.go index 15ebb7eb0..2d1a58291 100644 --- a/common/multistep_debug.go +++ b/common/multistep_debug.go @@ -5,8 +5,8 @@ import ( "log" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // MultistepDebugFn will return a proper multistep.DebugPauseFn to diff --git a/common/multistep_runner.go b/common/multistep_runner.go index 6f7c0a7cb..e3c16e7cf 100644 --- a/common/multistep_runner.go +++ b/common/multistep_runner.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "log" "os" @@ -8,8 +9,8 @@ import ( "strings" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func newRunner(steps []multistep.Step, config PackerConfig, ui packer.Ui) (multistep.Runner, multistep.DebugPauseFn) { @@ -65,8 +66,8 @@ func (s abortStep) InnerStepName() string { return typeName(s.step) } -func (s abortStep) Run(state multistep.StateBag) multistep.StepAction { - return s.step.Run(state) +func (s abortStep) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { + return s.step.Run(ctx, state) } func (s abortStep) Cleanup(state multistep.StateBag) { @@ -90,9 +91,9 @@ func (s askStep) InnerStepName() string { return typeName(s.step) } -func (s askStep) Run(state multistep.StateBag) (action multistep.StepAction) { +func (s askStep) Run(ctx context.Context, state multistep.StateBag) (action multistep.StepAction) { for { - action = s.step.Run(state) + action = s.step.Run(ctx, state) if action != multistep.ActionHalt { return diff --git a/common/step_create_floppy.go b/common/step_create_floppy.go index d37302d5c..dd4ead840 100644 --- a/common/step_create_floppy.go +++ b/common/step_create_floppy.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "io" "io/ioutil" @@ -10,10 +11,10 @@ import ( "path/filepath" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/mitchellh/go-fs" "github.com/mitchellh/go-fs/fat" - "github.com/mitchellh/multistep" ) // StepCreateFloppy will create a floppy disk with the given files. @@ -26,7 +27,7 @@ type StepCreateFloppy struct { FilesAdded map[string]bool } -func (s *StepCreateFloppy) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepCreateFloppy) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { if len(s.Files) == 0 && len(s.Directories) == 0 { log.Println("No floppy files specified. Floppy disk will not be made.") return multistep.ActionContinue diff --git a/common/step_create_floppy_test.go b/common/step_create_floppy_test.go index 7b5145eaa..4c43a6839 100644 --- a/common/step_create_floppy_test.go +++ b/common/step_create_floppy_test.go @@ -2,6 +2,7 @@ package common import ( "bytes" + "context" "fmt" "io/ioutil" "log" @@ -12,8 +13,8 @@ import ( "strings" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) const TestFixtures = "test-fixtures" @@ -89,7 +90,7 @@ func TestStepCreateFloppy(t *testing.T) { } for _, step.Files = range lists { - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v for %v", action, step.Files) } @@ -140,7 +141,7 @@ func xxxTestStepCreateFloppy_missing(t *testing.T) { } for _, step.Files = range lists { - if action := step.Run(state); action != multistep.ActionHalt { + if action := step.Run(context.Background(), state); action != multistep.ActionHalt { t.Fatalf("bad action: %#v for %v", action, step.Files) } @@ -190,7 +191,7 @@ func xxxTestStepCreateFloppy_notfound(t *testing.T) { } for _, step.Files = range lists { - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v for %v", action, step.Files) } @@ -265,7 +266,7 @@ func TestStepCreateFloppyDirectories(t *testing.T) { log.Println(fmt.Sprintf("Trying against floppy_dirs : %v", step.Directories)) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v for %v : %v", action, step.Directories, state.Get("error")) } diff --git a/common/step_download.go b/common/step_download.go index 765a07d23..ac62fa698 100644 --- a/common/step_download.go +++ b/common/step_download.go @@ -1,14 +1,15 @@ package common import ( + "context" "crypto/sha1" "encoding/hex" "fmt" "log" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepDownload downloads a remote file using the download client within @@ -45,7 +46,7 @@ type StepDownload struct { Extension string } -func (s *StepDownload) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepDownload) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { cache := state.Get("cache").(packer.Cache) ui := state.Get("ui").(packer.Ui) diff --git a/common/step_download_test.go b/common/step_download_test.go index de166ae55..2b6476614 100644 --- a/common/step_download_test.go +++ b/common/step_download_test.go @@ -3,7 +3,7 @@ package common import ( "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepDownload_Impl(t *testing.T) { diff --git a/common/step_http_server.go b/common/step_http_server.go index 3752b51c6..e90c6ef60 100644 --- a/common/step_http_server.go +++ b/common/step_http_server.go @@ -1,6 +1,7 @@ package common import ( + "context" "fmt" "io/ioutil" "log" @@ -10,8 +11,8 @@ import ( "os" "path/filepath" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // This step creates and runs the HTTP server that is serving files from the @@ -31,7 +32,7 @@ type StepHTTPServer struct { l net.Listener } -func (s *StepHTTPServer) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepHTTPServer) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) var httpPort uint = 0 diff --git a/common/step_provision.go b/common/step_provision.go index 15a6fb921..9c842044b 100644 --- a/common/step_provision.go +++ b/common/step_provision.go @@ -1,11 +1,12 @@ package common import ( + "context" "log" "time" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) // StepProvision runs the provisioners. @@ -21,7 +22,7 @@ type StepProvision struct { Comm packer.Communicator } -func (s *StepProvision) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepProvision) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { comm := s.Comm if comm == nil { raw, ok := state.Get("communicator").(packer.Communicator) diff --git a/common/step_provision_test.go b/common/step_provision_test.go index 5347aaee3..a37d7681b 100644 --- a/common/step_provision_test.go +++ b/common/step_provision_test.go @@ -3,7 +3,7 @@ package common import ( "testing" - "github.com/mitchellh/multistep" + "github.com/hashicorp/packer/helper/multistep" ) func TestStepProvision_Impl(t *testing.T) { diff --git a/helper/communicator/step_connect.go b/helper/communicator/step_connect.go index 7d738e4cc..273935710 100644 --- a/helper/communicator/step_connect.go +++ b/helper/communicator/step_connect.go @@ -1,12 +1,13 @@ package communicator import ( + "context" "fmt" "log" "github.com/hashicorp/packer/communicator/none" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" gossh "golang.org/x/crypto/ssh" ) @@ -43,7 +44,7 @@ type StepConnect struct { substep multistep.Step } -func (s *StepConnect) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { typeMap := map[string]multistep.Step{ "none": nil, "ssh": &StepConnectSSH{ @@ -84,7 +85,7 @@ func (s *StepConnect) Run(state multistep.StateBag) multistep.StepAction { } s.substep = step - return s.substep.Run(state) + return s.substep.Run(ctx, state) } func (s *StepConnect) Cleanup(state multistep.StateBag) { diff --git a/helper/communicator/step_connect_ssh.go b/helper/communicator/step_connect_ssh.go index 9179f57e8..680b88a02 100644 --- a/helper/communicator/step_connect_ssh.go +++ b/helper/communicator/step_connect_ssh.go @@ -1,6 +1,7 @@ package communicator import ( + "context" "errors" "fmt" "log" @@ -11,8 +12,8 @@ import ( commonssh "github.com/hashicorp/packer/common/ssh" "github.com/hashicorp/packer/communicator/ssh" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" gossh "golang.org/x/crypto/ssh" "golang.org/x/crypto/ssh/agent" "golang.org/x/net/proxy" @@ -29,7 +30,7 @@ type StepConnectSSH struct { SSHPort func(multistep.StateBag) (int, error) } -func (s *StepConnectSSH) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepConnectSSH) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) var comm packer.Communicator diff --git a/helper/communicator/step_connect_test.go b/helper/communicator/step_connect_test.go index d83625dd2..fb61f6463 100644 --- a/helper/communicator/step_connect_test.go +++ b/helper/communicator/step_connect_test.go @@ -2,10 +2,11 @@ package communicator import ( "bytes" + "context" "testing" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) func TestStepConnect_impl(t *testing.T) { @@ -23,7 +24,7 @@ func TestStepConnect_none(t *testing.T) { defer step.Cleanup(state) // run the step - if action := step.Run(state); action != multistep.ActionContinue { + if action := step.Run(context.Background(), state); action != multistep.ActionContinue { t.Fatalf("bad action: %#v", action) } } diff --git a/helper/communicator/step_connect_winrm.go b/helper/communicator/step_connect_winrm.go index 14f5cfc91..06e6236f8 100644 --- a/helper/communicator/step_connect_winrm.go +++ b/helper/communicator/step_connect_winrm.go @@ -2,6 +2,7 @@ package communicator import ( "bytes" + "context" "errors" "fmt" "io" @@ -10,9 +11,9 @@ import ( "time" "github.com/hashicorp/packer/communicator/winrm" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" winrmcmd "github.com/masterzen/winrm" - "github.com/mitchellh/multistep" ) // StepConnectWinRM is a multistep Step implementation that waits for WinRM @@ -32,7 +33,7 @@ type StepConnectWinRM struct { WinRMPort func(multistep.StateBag) (int, error) } -func (s *StepConnectWinRM) Run(state multistep.StateBag) multistep.StepAction { +func (s *StepConnectWinRM) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) var comm packer.Communicator diff --git a/vendor/github.com/mitchellh/multistep/LICENSE.md b/helper/multistep/LICENSE.md similarity index 100% rename from vendor/github.com/mitchellh/multistep/LICENSE.md rename to helper/multistep/LICENSE.md diff --git a/vendor/github.com/mitchellh/multistep/basic_runner.go b/helper/multistep/basic_runner.go similarity index 87% rename from vendor/github.com/mitchellh/multistep/basic_runner.go rename to helper/multistep/basic_runner.go index 35692a743..00723725d 100644 --- a/vendor/github.com/mitchellh/multistep/basic_runner.go +++ b/helper/multistep/basic_runner.go @@ -1,6 +1,7 @@ package multistep import ( + "context" "sync" "sync/atomic" ) @@ -19,28 +20,29 @@ type BasicRunner struct { // modified. Steps []Step - cancelCh chan struct{} - doneCh chan struct{} - state runState - l sync.Mutex + cancel context.CancelFunc + doneCh chan struct{} + state runState + l sync.Mutex } func (b *BasicRunner) Run(state StateBag) { + ctx, cancel := context.WithCancel(context.Background()) + b.l.Lock() if b.state != stateIdle { panic("already running") } - cancelCh := make(chan struct{}) doneCh := make(chan struct{}) - b.cancelCh = cancelCh + b.cancel = cancel b.doneCh = doneCh b.state = stateRunning b.l.Unlock() defer func() { b.l.Lock() - b.cancelCh = nil + b.cancel = nil b.doneCh = nil b.state = stateIdle close(doneCh) @@ -51,7 +53,7 @@ func (b *BasicRunner) Run(state StateBag) { // as quickly as possible into the state bag to mark it. go func() { select { - case <-cancelCh: + case <-ctx.Done(): // Flag cancel and wait for finish state.Put(StateCancelled, true) <-doneCh @@ -67,7 +69,7 @@ func (b *BasicRunner) Run(state StateBag) { break } - action := step.Run(state) + action := step.Run(ctx, state) defer step.Cleanup(state) if _, ok := state.GetOk(StateCancelled); ok { @@ -90,7 +92,7 @@ func (b *BasicRunner) Cancel() { return case stateRunning: // Running, so mark that we cancelled and set the state - close(b.cancelCh) + b.cancel() b.state = stateCancelling fallthrough case stateCancelling: diff --git a/helper/multistep/basic_runner_test.go b/helper/multistep/basic_runner_test.go new file mode 100644 index 000000000..433f288d2 --- /dev/null +++ b/helper/multistep/basic_runner_test.go @@ -0,0 +1,170 @@ +package multistep + +import ( + "reflect" + "testing" + "time" +) + +func TestBasicRunner_ImplRunner(t *testing.T) { + var raw interface{} + raw = &BasicRunner{} + if _, ok := raw.(Runner); !ok { + t.Fatalf("BasicRunner must be a Runner") + } +} + +func TestBasicRunner_Run(t *testing.T) { + data := new(BasicStateBag) + stepA := &TestStepAcc{Data: "a"} + stepB := &TestStepAcc{Data: "b"} + + r := &BasicRunner{Steps: []Step{stepA, stepB}} + r.Run(data) + + // Test run data + expected := []string{"a", "b"} + results := data.Get("data").([]string) + if !reflect.DeepEqual(results, expected) { + t.Errorf("unexpected result: %#v", results) + } + + // Test cleanup data + expected = []string{"b", "a"} + results = data.Get("cleanup").([]string) + if !reflect.DeepEqual(results, expected) { + t.Errorf("unexpected result: %#v", results) + } + + // Test no halted or cancelled + if _, ok := data.GetOk(StateCancelled); ok { + t.Errorf("cancelled should not be in state bag") + } + + if _, ok := data.GetOk(StateHalted); ok { + t.Errorf("halted should not be in state bag") + } +} + +func TestBasicRunner_Run_Halt(t *testing.T) { + data := new(BasicStateBag) + stepA := &TestStepAcc{Data: "a"} + stepB := &TestStepAcc{Data: "b", Halt: true} + stepC := &TestStepAcc{Data: "c"} + + r := &BasicRunner{Steps: []Step{stepA, stepB, stepC}} + r.Run(data) + + // Test run data + expected := []string{"a", "b"} + results := data.Get("data").([]string) + if !reflect.DeepEqual(results, expected) { + t.Errorf("unexpected result: %#v", results) + } + + // Test cleanup data + expected = []string{"b", "a"} + results = data.Get("cleanup").([]string) + if !reflect.DeepEqual(results, expected) { + t.Errorf("unexpected result: %#v", results) + } + + // Test that it says it is halted + halted := data.Get(StateHalted).(bool) + if !halted { + t.Errorf("not halted") + } +} + +// confirm that can't run twice +func TestBasicRunner_Run_Run(t *testing.T) { + defer func() { + recover() + }() + ch := make(chan chan bool) + stepInt := &TestStepSync{ch} + stepWait := &TestStepWaitForever{} + r := &BasicRunner{Steps: []Step{stepInt, stepWait}} + + go r.Run(new(BasicStateBag)) + // wait until really running + <-ch + + // now try to run aain + r.Run(new(BasicStateBag)) + + // should not get here in nominal codepath + t.Errorf("Was able to run an already running BasicRunner") +} + +func TestBasicRunner_Cancel(t *testing.T) { + ch := make(chan chan bool) + data := new(BasicStateBag) + stepA := &TestStepAcc{Data: "a"} + stepB := &TestStepAcc{Data: "b"} + stepInt := &TestStepSync{ch} + stepC := &TestStepAcc{Data: "c"} + + r := &BasicRunner{Steps: []Step{stepA, stepB, stepInt, stepC}} + + // cancelling an idle Runner is a no-op + r.Cancel() + + go r.Run(data) + + // Wait until we reach the sync point + responseCh := <-ch + + // Cancel then continue chain + cancelCh := make(chan bool) + go func() { + r.Cancel() + cancelCh <- true + }() + + for { + if _, ok := data.GetOk(StateCancelled); ok { + responseCh <- true + break + } + + time.Sleep(10 * time.Millisecond) + } + + <-cancelCh + + // Test run data + expected := []string{"a", "b"} + results := data.Get("data").([]string) + if !reflect.DeepEqual(results, expected) { + t.Errorf("unexpected result: %#v", results) + } + + // Test cleanup data + expected = []string{"b", "a"} + results = data.Get("cleanup").([]string) + if !reflect.DeepEqual(results, expected) { + t.Errorf("unexpected result: %#v", results) + } + + // Test that it says it is cancelled + cancelled := data.Get(StateCancelled).(bool) + if !cancelled { + t.Errorf("not cancelled") + } +} + +func TestBasicRunner_Cancel_Special(t *testing.T) { + stepOne := &TestStepInjectCancel{} + stepTwo := &TestStepInjectCancel{} + r := &BasicRunner{Steps: []Step{stepOne, stepTwo}} + + state := new(BasicStateBag) + state.Put("runner", r) + r.Run(state) + + // test that state contains cancelled + if _, ok := state.GetOk(StateCancelled); !ok { + t.Errorf("cancelled should be in state bag") + } +} diff --git a/vendor/github.com/mitchellh/multistep/debug_runner.go b/helper/multistep/debug_runner.go similarity index 97% rename from vendor/github.com/mitchellh/multistep/debug_runner.go rename to helper/multistep/debug_runner.go index 882009494..88af01c54 100644 --- a/vendor/github.com/mitchellh/multistep/debug_runner.go +++ b/helper/multistep/debug_runner.go @@ -1,6 +1,7 @@ package multistep import ( + "context" "fmt" "reflect" "sync" @@ -113,7 +114,7 @@ type debugStepPause struct { PauseFn DebugPauseFn } -func (s *debugStepPause) Run(state StateBag) StepAction { +func (s *debugStepPause) Run(_ context.Context, state StateBag) StepAction { s.PauseFn(DebugLocationAfterRun, s.StepName, state) return ActionContinue } diff --git a/helper/multistep/debug_runner_test.go b/helper/multistep/debug_runner_test.go new file mode 100644 index 000000000..aae905d43 --- /dev/null +++ b/helper/multistep/debug_runner_test.go @@ -0,0 +1,174 @@ +package multistep + +import ( + "os" + "reflect" + "testing" + "time" +) + +func TestDebugRunner_Impl(t *testing.T) { + var raw interface{} + raw = &DebugRunner{} + if _, ok := raw.(Runner); !ok { + t.Fatal("DebugRunner must be a runner.") + } +} + +func TestDebugRunner_Run(t *testing.T) { + data := new(BasicStateBag) + stepA := &TestStepAcc{Data: "a"} + stepB := &TestStepAcc{Data: "b"} + + pauseFn := func(loc DebugLocation, name string, state StateBag) { + key := "data" + if loc == DebugLocationBeforeCleanup { + key = "cleanup" + } + + if _, ok := state.GetOk(key); !ok { + state.Put(key, make([]string, 0, 5)) + } + + data := state.Get(key).([]string) + state.Put(key, append(data, name)) + } + + r := &DebugRunner{ + Steps: []Step{stepA, stepB}, + PauseFn: pauseFn, + } + + r.Run(data) + + // Test data + expected := []string{"a", "TestStepAcc", "b", "TestStepAcc"} + results := data.Get("data").([]string) + if !reflect.DeepEqual(results, expected) { + t.Errorf("unexpected results: %#v", results) + } + + // Test cleanup + expected = []string{"TestStepAcc", "b", "TestStepAcc", "a"} + results = data.Get("cleanup").([]string) + if !reflect.DeepEqual(results, expected) { + t.Errorf("unexpected results: %#v", results) + } +} + +// confirm that can't run twice +func TestDebugRunner_Run_Run(t *testing.T) { + defer func() { + recover() + }() + ch := make(chan chan bool) + stepInt := &TestStepSync{ch} + stepWait := &TestStepWaitForever{} + r := &DebugRunner{Steps: []Step{stepInt, stepWait}} + + go r.Run(new(BasicStateBag)) + // wait until really running + <-ch + + // now try to run aain + r.Run(new(BasicStateBag)) + + // should not get here in nominal codepath + t.Errorf("Was able to run an already running DebugRunner") +} + +func TestDebugRunner_Cancel(t *testing.T) { + ch := make(chan chan bool) + data := new(BasicStateBag) + stepA := &TestStepAcc{Data: "a"} + stepB := &TestStepAcc{Data: "b"} + stepInt := &TestStepSync{ch} + stepC := &TestStepAcc{Data: "c"} + + r := &DebugRunner{} + r.Steps = []Step{stepA, stepB, stepInt, stepC} + + // cancelling an idle Runner is a no-op + r.Cancel() + + go r.Run(data) + + // Wait until we reach the sync point + responseCh := <-ch + + // Cancel then continue chain + cancelCh := make(chan bool) + go func() { + r.Cancel() + cancelCh <- true + }() + + for { + if _, ok := data.GetOk(StateCancelled); ok { + responseCh <- true + break + } + + time.Sleep(10 * time.Millisecond) + } + + <-cancelCh + + // Test run data + expected := []string{"a", "b"} + results := data.Get("data").([]string) + if !reflect.DeepEqual(results, expected) { + t.Errorf("unexpected result: %#v", results) + } + + // Test cleanup data + expected = []string{"b", "a"} + results = data.Get("cleanup").([]string) + if !reflect.DeepEqual(results, expected) { + t.Errorf("unexpected result: %#v", results) + } + + // Test that it says it is cancelled + cancelled := data.Get(StateCancelled).(bool) + if !cancelled { + t.Errorf("not cancelled") + } +} + +func TestDebugPauseDefault(t *testing.T) { + + // Create a pipe pair so that writes/reads are blocked until we do it + r, w, err := os.Pipe() + if err != nil { + t.Fatalf("err: %s", err) + } + + // Set stdin so we can control it + oldStdin := os.Stdin + os.Stdin = r + defer func() { os.Stdin = oldStdin }() + + // Start pausing + complete := make(chan bool, 1) + go func() { + dr := &DebugRunner{Steps: []Step{ + &TestStepAcc{Data: "a"}, + }} + dr.Run(new(BasicStateBag)) + complete <- true + }() + + select { + case <-complete: + t.Fatal("shouldn't have completed") + case <-time.After(100 * time.Millisecond): + } + + w.Write([]byte("\n\n")) + + select { + case <-complete: + case <-time.After(100 * time.Millisecond): + t.Fatal("didn't complete") + } +} diff --git a/vendor/github.com/mitchellh/multistep/README.md b/helper/multistep/doc.go similarity index 82% rename from vendor/github.com/mitchellh/multistep/README.md rename to helper/multistep/doc.go index 9ceae012a..17570cda9 100644 --- a/vendor/github.com/mitchellh/multistep/README.md +++ b/helper/multistep/doc.go @@ -1,5 +1,4 @@ -# multistep - +/* multistep is a Go library for building up complex actions using discrete, individual "steps." These steps are strung together and run in sequence to achieve a more complex goal. The runner handles cleanup, cancelling, etc. @@ -13,13 +12,13 @@ which is passed between steps by the runner. ```go type stepAdd struct{} -func (s *stepAdd) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepAdd) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { // Read our value and assert that it is they type we want value := state.Get("value").(int) fmt.Printf("Value is %d\n", value) - // Store some state back - state.Put("value", value + 1) + // Store some state back + state.Put("value", value + 1) return multistep.ActionContinue } @@ -35,7 +34,7 @@ Make a runner and call your array of Steps. func main() { // Our "bag of state" that we read the value from state := new(multistep.BasicStateBag) - state.Put("value", 0) + state.Put("value", 0) steps := []multistep.Step{ &stepAdd{}, @@ -46,7 +45,7 @@ func main() { runner := &multistep.BasicRunner{Steps: steps} // Executes the steps - runner.Run(state) + runner.Run(context.Background(), state) } ``` @@ -57,3 +56,6 @@ Value is 0 Value is 1 Value is 2 ``` +*/ + +package multistep diff --git a/vendor/github.com/mitchellh/multistep/multistep.go b/helper/multistep/multistep.go similarity index 79% rename from vendor/github.com/mitchellh/multistep/multistep.go rename to helper/multistep/multistep.go index feef1406f..39c44ed0a 100644 --- a/vendor/github.com/mitchellh/multistep/multistep.go +++ b/helper/multistep/multistep.go @@ -1,7 +1,9 @@ -// multistep is a library for bulding up complex actions using individual, +// multistep is a library for building up complex actions using individual, // discrete steps. package multistep +import "context" + // A StepAction determines the next step to take regarding multi-step actions. type StepAction uint @@ -20,13 +22,14 @@ const StateHalted = "halted" // Step is a single step that is part of a potentially large sequence // of other steps, responsible for performing some specific action. type Step interface { - // Run is called to perform the action. The parameter is a "state bag" - // of untyped things. Please be very careful about type-checking the + // Run is called to perform the action. The passed through context will be + // cancelled when the runner is cancelled. The second parameter is a "state + // bag" of untyped things. Please be very careful about type-checking the // items in this bag. // // The return value determines whether multi-step sequences continue // or should halt. - Run(StateBag) StepAction + Run(context.Context, StateBag) StepAction // Cleanup is called in reverse order of the steps that have run // and allow steps to clean up after themselves. Do not assume if this diff --git a/helper/multistep/multistep_test.go b/helper/multistep/multistep_test.go new file mode 100644 index 000000000..25bbeef9b --- /dev/null +++ b/helper/multistep/multistep_test.go @@ -0,0 +1,75 @@ +package multistep + +import "context" + +// A step for testing that accumuluates data into a string slice in the +// the state bag. It always uses the "data" key in the state bag, and will +// initialize it. +type TestStepAcc struct { + // The data inserted into the state bag. + Data string + + // If true, it will halt at the step when it is run + Halt bool +} + +// A step that syncs by sending a channel and expecting a response. +type TestStepSync struct { + Ch chan chan bool +} + +// A step that sleeps forever +type TestStepWaitForever struct { +} + +// A step that manually flips state to cancelling in run +type TestStepInjectCancel struct { +} + +func (s TestStepAcc) Run(_ context.Context, state StateBag) StepAction { + s.insertData(state, "data") + + if s.Halt { + return ActionHalt + } + + return ActionContinue +} + +func (s TestStepAcc) Cleanup(state StateBag) { + s.insertData(state, "cleanup") +} + +func (s TestStepAcc) insertData(state StateBag, key string) { + if _, ok := state.GetOk(key); !ok { + state.Put(key, make([]string, 0, 5)) + } + + data := state.Get(key).([]string) + data = append(data, s.Data) + state.Put(key, data) +} + +func (s TestStepSync) Run(context.Context, StateBag) StepAction { + ch := make(chan bool) + s.Ch <- ch + <-ch + + return ActionContinue +} + +func (s TestStepSync) Cleanup(StateBag) {} + +func (s TestStepWaitForever) Run(context.Context, StateBag) StepAction { + select {} +} + +func (s TestStepWaitForever) Cleanup(StateBag) {} + +func (s TestStepInjectCancel) Run(_ context.Context, state StateBag) StepAction { + r := state.Get("runner").(*BasicRunner) + r.state = stateCancelling + return ActionContinue +} + +func (s TestStepInjectCancel) Cleanup(StateBag) {} diff --git a/vendor/github.com/mitchellh/multistep/statebag.go b/helper/multistep/statebag.go similarity index 92% rename from vendor/github.com/mitchellh/multistep/statebag.go rename to helper/multistep/statebag.go index dab712316..9efb6d998 100644 --- a/vendor/github.com/mitchellh/multistep/statebag.go +++ b/helper/multistep/statebag.go @@ -1,8 +1,8 @@ package multistep -import ( - "sync" -) +import "sync" + +// Add context to state bag to prevent changing step signature // StateBag holds the state that is used by the Runner and Steps. The // StateBag implementation must be safe for concurrent access. diff --git a/helper/multistep/statebag_test.go b/helper/multistep/statebag_test.go new file mode 100644 index 000000000..1793ee6e2 --- /dev/null +++ b/helper/multistep/statebag_test.go @@ -0,0 +1,30 @@ +package multistep + +import ( + "testing" +) + +func TestBasicStateBag_ImplRunner(t *testing.T) { + var raw interface{} + raw = &BasicStateBag{} + if _, ok := raw.(StateBag); !ok { + t.Fatalf("must be a StateBag") + } +} + +func TestBasicStateBag(t *testing.T) { + b := new(BasicStateBag) + if b.Get("foo") != nil { + t.Fatalf("bad: %#v", b.Get("foo")) + } + + if _, ok := b.GetOk("foo"); ok { + t.Fatal("should not have foo") + } + + b.Put("foo", "bar") + + if b.Get("foo").(string) != "bar" { + t.Fatalf("bad") + } +} diff --git a/post-processor/googlecompute-export/post-processor.go b/post-processor/googlecompute-export/post-processor.go index 8a5befbc8..e96bbb5f8 100644 --- a/post-processor/googlecompute-export/post-processor.go +++ b/post-processor/googlecompute-export/post-processor.go @@ -8,9 +8,9 @@ import ( "github.com/hashicorp/packer/builder/googlecompute" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) type Config struct { diff --git a/post-processor/vagrant-cloud/post-processor.go b/post-processor/vagrant-cloud/post-processor.go index b8eeb7105..f6c7f19d6 100644 --- a/post-processor/vagrant-cloud/post-processor.go +++ b/post-processor/vagrant-cloud/post-processor.go @@ -12,9 +12,9 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" ) const VAGRANT_CLOUD_URL = "https://vagrantcloud.com/api/v1" diff --git a/post-processor/vagrant-cloud/step_create_provider.go b/post-processor/vagrant-cloud/step_create_provider.go index 4cd443577..e664b8b19 100644 --- a/post-processor/vagrant-cloud/step_create_provider.go +++ b/post-processor/vagrant-cloud/step_create_provider.go @@ -1,10 +1,11 @@ package vagrantcloud import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type Provider struct { @@ -18,7 +19,7 @@ type stepCreateProvider struct { name string // the name of the provider } -func (s *stepCreateProvider) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateProvider) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) ui := state.Get("ui").(packer.Ui) box := state.Get("box").(*Box) diff --git a/post-processor/vagrant-cloud/step_create_version.go b/post-processor/vagrant-cloud/step_create_version.go index aba6da020..feb247f0a 100644 --- a/post-processor/vagrant-cloud/step_create_version.go +++ b/post-processor/vagrant-cloud/step_create_version.go @@ -1,10 +1,11 @@ package vagrantcloud import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type Version struct { @@ -15,7 +16,7 @@ type Version struct { type stepCreateVersion struct { } -func (s *stepCreateVersion) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateVersion) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) ui := state.Get("ui").(packer.Ui) config := state.Get("config").(Config) diff --git a/post-processor/vagrant-cloud/step_prepare_upload.go b/post-processor/vagrant-cloud/step_prepare_upload.go index 0723520b9..bdab16d10 100644 --- a/post-processor/vagrant-cloud/step_prepare_upload.go +++ b/post-processor/vagrant-cloud/step_prepare_upload.go @@ -1,10 +1,11 @@ package vagrantcloud import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type Upload struct { @@ -14,7 +15,7 @@ type Upload struct { type stepPrepareUpload struct { } -func (s *stepPrepareUpload) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepPrepareUpload) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) ui := state.Get("ui").(packer.Ui) box := state.Get("box").(*Box) diff --git a/post-processor/vagrant-cloud/step_release_version.go b/post-processor/vagrant-cloud/step_release_version.go index cc4db611f..94e4b90da 100644 --- a/post-processor/vagrant-cloud/step_release_version.go +++ b/post-processor/vagrant-cloud/step_release_version.go @@ -1,17 +1,18 @@ package vagrantcloud import ( + "context" "fmt" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepReleaseVersion struct { } -func (s *stepReleaseVersion) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepReleaseVersion) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) ui := state.Get("ui").(packer.Ui) box := state.Get("box").(*Box) diff --git a/post-processor/vagrant-cloud/step_upload.go b/post-processor/vagrant-cloud/step_upload.go index 7004177fd..cce1e9de2 100644 --- a/post-processor/vagrant-cloud/step_upload.go +++ b/post-processor/vagrant-cloud/step_upload.go @@ -1,18 +1,19 @@ package vagrantcloud import ( + "context" "fmt" "log" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type stepUpload struct { } -func (s *stepUpload) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepUpload) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) ui := state.Get("ui").(packer.Ui) upload := state.Get("upload").(*Upload) diff --git a/post-processor/vagrant-cloud/step_verify_box.go b/post-processor/vagrant-cloud/step_verify_box.go index ab6ac4fe6..f1dafc991 100644 --- a/post-processor/vagrant-cloud/step_verify_box.go +++ b/post-processor/vagrant-cloud/step_verify_box.go @@ -1,10 +1,11 @@ package vagrantcloud import ( + "context" "fmt" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" ) type Box struct { @@ -24,7 +25,7 @@ func (b *Box) HasVersion(version string) (bool, *Version) { type stepVerifyBox struct { } -func (s *stepVerifyBox) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepVerifyBox) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { client := state.Get("client").(*VagrantCloudClient) ui := state.Get("ui").(packer.Ui) config := state.Get("config").(Config) diff --git a/post-processor/vsphere-template/post-processor.go b/post-processor/vsphere-template/post-processor.go index f5fba9c4e..49be4ed7c 100644 --- a/post-processor/vsphere-template/post-processor.go +++ b/post-processor/vsphere-template/post-processor.go @@ -11,9 +11,9 @@ import ( "github.com/hashicorp/packer/builder/vmware/iso" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/config" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/template/interpolate" - "github.com/mitchellh/multistep" "github.com/vmware/govmomi" ) diff --git a/post-processor/vsphere-template/step_choose_datacenter.go b/post-processor/vsphere-template/step_choose_datacenter.go index 51959b6d7..450f2b946 100644 --- a/post-processor/vsphere-template/step_choose_datacenter.go +++ b/post-processor/vsphere-template/step_choose_datacenter.go @@ -3,8 +3,8 @@ package vsphere_template import ( "context" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/vmware/govmomi" "github.com/vmware/govmomi/find" ) @@ -13,7 +13,7 @@ type stepChooseDatacenter struct { Datacenter string } -func (s *stepChooseDatacenter) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepChooseDatacenter) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) cli := state.Get("client").(*govmomi.Client) finder := find.NewFinder(cli.Client, false) diff --git a/post-processor/vsphere-template/step_create_folder.go b/post-processor/vsphere-template/step_create_folder.go index a0e648275..49232c2f2 100644 --- a/post-processor/vsphere-template/step_create_folder.go +++ b/post-processor/vsphere-template/step_create_folder.go @@ -5,8 +5,8 @@ import ( "fmt" "path" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/vmware/govmomi" "github.com/vmware/govmomi/object" ) @@ -15,7 +15,7 @@ type stepCreateFolder struct { Folder string } -func (s *stepCreateFolder) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepCreateFolder) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) cli := state.Get("client").(*govmomi.Client) dcPath := state.Get("dcPath").(string) diff --git a/post-processor/vsphere-template/step_mark_as_template.go b/post-processor/vsphere-template/step_mark_as_template.go index dffc871ca..8117a4940 100644 --- a/post-processor/vsphere-template/step_mark_as_template.go +++ b/post-processor/vsphere-template/step_mark_as_template.go @@ -7,8 +7,8 @@ import ( "regexp" "strings" + "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" - "github.com/mitchellh/multistep" "github.com/vmware/govmomi" "github.com/vmware/govmomi/object" "github.com/vmware/govmomi/vim25/types" @@ -18,7 +18,7 @@ type stepMarkAsTemplate struct { VMName string } -func (s *stepMarkAsTemplate) Run(state multistep.StateBag) multistep.StepAction { +func (s *stepMarkAsTemplate) Run(_ context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) cli := state.Get("client").(*govmomi.Client) folder := state.Get("folder").(*object.Folder) diff --git a/vendor/golang.org/x/net/context/context.go b/vendor/golang.org/x/net/context/context.go index 77b64d0c6..a3c021d3f 100644 --- a/vendor/golang.org/x/net/context/context.go +++ b/vendor/golang.org/x/net/context/context.go @@ -5,9 +5,11 @@ // Package context defines the Context type, which carries deadlines, // cancelation signals, and other request-scoped values across API boundaries // and between processes. +// As of Go 1.7 this package is available in the standard library under the +// name context. https://golang.org/pkg/context. // // Incoming requests to a server should create a Context, and outgoing calls to -// servers should accept a Context. The chain of function calls between must +// servers should accept a Context. The chain of function calls between must // propagate the Context, optionally replacing it with a modified copy created // using WithDeadline, WithTimeout, WithCancel, or WithValue. // @@ -16,14 +18,14 @@ // propagation: // // Do not store Contexts inside a struct type; instead, pass a Context -// explicitly to each function that needs it. The Context should be the first +// explicitly to each function that needs it. The Context should be the first // parameter, typically named ctx: // // func DoSomething(ctx context.Context, arg Arg) error { // // ... use ctx ... // } // -// Do not pass a nil Context, even if a function permits it. Pass context.TODO +// Do not pass a nil Context, even if a function permits it. Pass context.TODO // if you are unsure about which Context to use. // // Use context Values only for request-scoped data that transits processes and @@ -36,159 +38,15 @@ // Contexts. package context // import "golang.org/x/net/context" -import ( - "errors" - "fmt" - "sync" - "time" -) - -// A Context carries a deadline, a cancelation signal, and other values across -// API boundaries. -// -// Context's methods may be called by multiple goroutines simultaneously. -type Context interface { - // Deadline returns the time when work done on behalf of this context - // should be canceled. Deadline returns ok==false when no deadline is - // set. Successive calls to Deadline return the same results. - Deadline() (deadline time.Time, ok bool) - - // Done returns a channel that's closed when work done on behalf of this - // context should be canceled. Done may return nil if this context can - // never be canceled. Successive calls to Done return the same value. - // - // WithCancel arranges for Done to be closed when cancel is called; - // WithDeadline arranges for Done to be closed when the deadline - // expires; WithTimeout arranges for Done to be closed when the timeout - // elapses. - // - // Done is provided for use in select statements: - // - // // Stream generates values with DoSomething and sends them to out - // // until DoSomething returns an error or ctx.Done is closed. - // func Stream(ctx context.Context, out <-chan Value) error { - // for { - // v, err := DoSomething(ctx) - // if err != nil { - // return err - // } - // select { - // case <-ctx.Done(): - // return ctx.Err() - // case out <- v: - // } - // } - // } - // - // See http://blog.golang.org/pipelines for more examples of how to use - // a Done channel for cancelation. - Done() <-chan struct{} - - // Err returns a non-nil error value after Done is closed. Err returns - // Canceled if the context was canceled or DeadlineExceeded if the - // context's deadline passed. No other values for Err are defined. - // After Done is closed, successive calls to Err return the same value. - Err() error - - // Value returns the value associated with this context for key, or nil - // if no value is associated with key. Successive calls to Value with - // the same key returns the same result. - // - // Use context values only for request-scoped data that transits - // processes and API boundaries, not for passing optional parameters to - // functions. - // - // A key identifies a specific value in a Context. Functions that wish - // to store values in Context typically allocate a key in a global - // variable then use that key as the argument to context.WithValue and - // Context.Value. A key can be any type that supports equality; - // packages should define keys as an unexported type to avoid - // collisions. - // - // Packages that define a Context key should provide type-safe accessors - // for the values stores using that key: - // - // // Package user defines a User type that's stored in Contexts. - // package user - // - // import "golang.org/x/net/context" - // - // // User is the type of value stored in the Contexts. - // type User struct {...} - // - // // key is an unexported type for keys defined in this package. - // // This prevents collisions with keys defined in other packages. - // type key int - // - // // userKey is the key for user.User values in Contexts. It is - // // unexported; clients use user.NewContext and user.FromContext - // // instead of using this key directly. - // var userKey key = 0 - // - // // NewContext returns a new Context that carries value u. - // func NewContext(ctx context.Context, u *User) context.Context { - // return context.WithValue(ctx, userKey, u) - // } - // - // // FromContext returns the User value stored in ctx, if any. - // func FromContext(ctx context.Context) (*User, bool) { - // u, ok := ctx.Value(userKey).(*User) - // return u, ok - // } - Value(key interface{}) interface{} -} - -// Canceled is the error returned by Context.Err when the context is canceled. -var Canceled = errors.New("context canceled") - -// DeadlineExceeded is the error returned by Context.Err when the context's -// deadline passes. -var DeadlineExceeded = errors.New("context deadline exceeded") - -// An emptyCtx is never canceled, has no values, and has no deadline. It is not -// struct{}, since vars of this type must have distinct addresses. -type emptyCtx int - -func (*emptyCtx) Deadline() (deadline time.Time, ok bool) { - return -} - -func (*emptyCtx) Done() <-chan struct{} { - return nil -} - -func (*emptyCtx) Err() error { - return nil -} - -func (*emptyCtx) Value(key interface{}) interface{} { - return nil -} - -func (e *emptyCtx) String() string { - switch e { - case background: - return "context.Background" - case todo: - return "context.TODO" - } - return "unknown empty Context" -} - -var ( - background = new(emptyCtx) - todo = new(emptyCtx) -) - // Background returns a non-nil, empty Context. It is never canceled, has no -// values, and has no deadline. It is typically used by the main function, +// values, and has no deadline. It is typically used by the main function, // initialization, and tests, and as the top-level Context for incoming // requests. func Background() Context { return background } -// TODO returns a non-nil, empty Context. Code should use context.TODO when +// TODO returns a non-nil, empty Context. Code should use context.TODO when // it's unclear which Context to use or it is not yet available (because the // surrounding function has not yet been extended to accept a Context // parameter). TODO is recognized by static analysis tools that determine @@ -196,252 +54,3 @@ func Background() Context { func TODO() Context { return todo } - -// A CancelFunc tells an operation to abandon its work. -// A CancelFunc does not wait for the work to stop. -// After the first call, subsequent calls to a CancelFunc do nothing. -type CancelFunc func() - -// WithCancel returns a copy of parent with a new Done channel. The returned -// context's Done channel is closed when the returned cancel function is called -// or when the parent context's Done channel is closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { - c := newCancelCtx(parent) - propagateCancel(parent, &c) - return &c, func() { c.cancel(true, Canceled) } -} - -// newCancelCtx returns an initialized cancelCtx. -func newCancelCtx(parent Context) cancelCtx { - return cancelCtx{ - Context: parent, - done: make(chan struct{}), - } -} - -// propagateCancel arranges for child to be canceled when parent is. -func propagateCancel(parent Context, child canceler) { - if parent.Done() == nil { - return // parent is never canceled - } - if p, ok := parentCancelCtx(parent); ok { - p.mu.Lock() - if p.err != nil { - // parent has already been canceled - child.cancel(false, p.err) - } else { - if p.children == nil { - p.children = make(map[canceler]bool) - } - p.children[child] = true - } - p.mu.Unlock() - } else { - go func() { - select { - case <-parent.Done(): - child.cancel(false, parent.Err()) - case <-child.Done(): - } - }() - } -} - -// parentCancelCtx follows a chain of parent references until it finds a -// *cancelCtx. This function understands how each of the concrete types in this -// package represents its parent. -func parentCancelCtx(parent Context) (*cancelCtx, bool) { - for { - switch c := parent.(type) { - case *cancelCtx: - return c, true - case *timerCtx: - return &c.cancelCtx, true - case *valueCtx: - parent = c.Context - default: - return nil, false - } - } -} - -// removeChild removes a context from its parent. -func removeChild(parent Context, child canceler) { - p, ok := parentCancelCtx(parent) - if !ok { - return - } - p.mu.Lock() - if p.children != nil { - delete(p.children, child) - } - p.mu.Unlock() -} - -// A canceler is a context type that can be canceled directly. The -// implementations are *cancelCtx and *timerCtx. -type canceler interface { - cancel(removeFromParent bool, err error) - Done() <-chan struct{} -} - -// A cancelCtx can be canceled. When canceled, it also cancels any children -// that implement canceler. -type cancelCtx struct { - Context - - done chan struct{} // closed by the first cancel call. - - mu sync.Mutex - children map[canceler]bool // set to nil by the first cancel call - err error // set to non-nil by the first cancel call -} - -func (c *cancelCtx) Done() <-chan struct{} { - return c.done -} - -func (c *cancelCtx) Err() error { - c.mu.Lock() - defer c.mu.Unlock() - return c.err -} - -func (c *cancelCtx) String() string { - return fmt.Sprintf("%v.WithCancel", c.Context) -} - -// cancel closes c.done, cancels each of c's children, and, if -// removeFromParent is true, removes c from its parent's children. -func (c *cancelCtx) cancel(removeFromParent bool, err error) { - if err == nil { - panic("context: internal error: missing cancel error") - } - c.mu.Lock() - if c.err != nil { - c.mu.Unlock() - return // already canceled - } - c.err = err - close(c.done) - for child := range c.children { - // NOTE: acquiring the child's lock while holding parent's lock. - child.cancel(false, err) - } - c.children = nil - c.mu.Unlock() - - if removeFromParent { - removeChild(c.Context, c) - } -} - -// WithDeadline returns a copy of the parent context with the deadline adjusted -// to be no later than d. If the parent's deadline is already earlier than d, -// WithDeadline(parent, d) is semantically equivalent to parent. The returned -// context's Done channel is closed when the deadline expires, when the returned -// cancel function is called, or when the parent context's Done channel is -// closed, whichever happens first. -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete. -func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { - if cur, ok := parent.Deadline(); ok && cur.Before(deadline) { - // The current deadline is already sooner than the new one. - return WithCancel(parent) - } - c := &timerCtx{ - cancelCtx: newCancelCtx(parent), - deadline: deadline, - } - propagateCancel(parent, c) - d := deadline.Sub(time.Now()) - if d <= 0 { - c.cancel(true, DeadlineExceeded) // deadline has already passed - return c, func() { c.cancel(true, Canceled) } - } - c.mu.Lock() - defer c.mu.Unlock() - if c.err == nil { - c.timer = time.AfterFunc(d, func() { - c.cancel(true, DeadlineExceeded) - }) - } - return c, func() { c.cancel(true, Canceled) } -} - -// A timerCtx carries a timer and a deadline. It embeds a cancelCtx to -// implement Done and Err. It implements cancel by stopping its timer then -// delegating to cancelCtx.cancel. -type timerCtx struct { - cancelCtx - timer *time.Timer // Under cancelCtx.mu. - - deadline time.Time -} - -func (c *timerCtx) Deadline() (deadline time.Time, ok bool) { - return c.deadline, true -} - -func (c *timerCtx) String() string { - return fmt.Sprintf("%v.WithDeadline(%s [%s])", c.cancelCtx.Context, c.deadline, c.deadline.Sub(time.Now())) -} - -func (c *timerCtx) cancel(removeFromParent bool, err error) { - c.cancelCtx.cancel(false, err) - if removeFromParent { - // Remove this timerCtx from its parent cancelCtx's children. - removeChild(c.cancelCtx.Context, c) - } - c.mu.Lock() - if c.timer != nil { - c.timer.Stop() - c.timer = nil - } - c.mu.Unlock() -} - -// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). -// -// Canceling this context releases resources associated with it, so code should -// call cancel as soon as the operations running in this Context complete: -// -// func slowOperationWithTimeout(ctx context.Context) (Result, error) { -// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) -// defer cancel() // releases resources if slowOperation completes before timeout elapses -// return slowOperation(ctx) -// } -func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { - return WithDeadline(parent, time.Now().Add(timeout)) -} - -// WithValue returns a copy of parent in which the value associated with key is -// val. -// -// Use context Values only for request-scoped data that transits processes and -// APIs, not for passing optional parameters to functions. -func WithValue(parent Context, key interface{}, val interface{}) Context { - return &valueCtx{parent, key, val} -} - -// A valueCtx carries a key-value pair. It implements Value for that key and -// delegates all other calls to the embedded Context. -type valueCtx struct { - Context - key, val interface{} -} - -func (c *valueCtx) String() string { - return fmt.Sprintf("%v.WithValue(%#v, %#v)", c.Context, c.key, c.val) -} - -func (c *valueCtx) Value(key interface{}) interface{} { - if c.key == key { - return c.val - } - return c.Context.Value(key) -} diff --git a/vendor/golang.org/x/net/context/ctxhttp/cancelreq.go b/vendor/golang.org/x/net/context/ctxhttp/cancelreq.go deleted file mode 100644 index e3170e333..000000000 --- a/vendor/golang.org/x/net/context/ctxhttp/cancelreq.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build go1.5 - -package ctxhttp - -import "net/http" - -func canceler(client *http.Client, req *http.Request) func() { - // TODO(djd): Respect any existing value of req.Cancel. - ch := make(chan struct{}) - req.Cancel = ch - - return func() { - close(ch) - } -} diff --git a/vendor/golang.org/x/net/context/ctxhttp/cancelreq_go14.go b/vendor/golang.org/x/net/context/ctxhttp/cancelreq_go14.go deleted file mode 100644 index 56bcbadb8..000000000 --- a/vendor/golang.org/x/net/context/ctxhttp/cancelreq_go14.go +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2015 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// +build !go1.5 - -package ctxhttp - -import "net/http" - -type requestCanceler interface { - CancelRequest(*http.Request) -} - -func canceler(client *http.Client, req *http.Request) func() { - rc, ok := client.Transport.(requestCanceler) - if !ok { - return func() {} - } - return func() { - rc.CancelRequest(req) - } -} diff --git a/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go b/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go index 62620d4eb..606cf1f97 100644 --- a/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go +++ b/vendor/golang.org/x/net/context/ctxhttp/ctxhttp.go @@ -1,7 +1,9 @@ -// Copyright 2015 The Go Authors. All rights reserved. +// Copyright 2016 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +// +build go1.7 + // Package ctxhttp provides helper functions for performing context-aware HTTP requests. package ctxhttp // import "golang.org/x/net/context/ctxhttp" @@ -14,71 +16,28 @@ import ( "golang.org/x/net/context" ) -func nop() {} - -var ( - testHookContextDoneBeforeHeaders = nop - testHookDoReturned = nop - testHookDidBodyClose = nop -) - -// Do sends an HTTP request with the provided http.Client and returns an HTTP response. +// Do sends an HTTP request with the provided http.Client and returns +// an HTTP response. +// // If the client is nil, http.DefaultClient is used. -// If the context is canceled or times out, ctx.Err() will be returned. +// +// The provided ctx must be non-nil. If it is canceled or times out, +// ctx.Err() will be returned. func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { if client == nil { client = http.DefaultClient } - - // Request cancelation changed in Go 1.5, see cancelreq.go and cancelreq_go14.go. - cancel := canceler(client, req) - - type responseAndError struct { - resp *http.Response - err error - } - result := make(chan responseAndError, 1) - - go func() { - resp, err := client.Do(req) - testHookDoReturned() - result <- responseAndError{resp, err} - }() - - var resp *http.Response - - select { - case <-ctx.Done(): - testHookContextDoneBeforeHeaders() - cancel() - // Clean up after the goroutine calling client.Do: - go func() { - if r := <-result; r.resp != nil { - testHookDidBodyClose() - r.resp.Body.Close() - } - }() - return nil, ctx.Err() - case r := <-result: - var err error - resp, err = r.resp, r.err - if err != nil { - return resp, err - } - } - - c := make(chan struct{}) - go func() { + resp, err := client.Do(req.WithContext(ctx)) + // If we got an error, and the context has been canceled, + // the context's error is probably more useful. + if err != nil { select { case <-ctx.Done(): - cancel() - case <-c: - // The response's Body is closed. + err = ctx.Err() + default: } - }() - resp.Body = ¬ifyingReader{resp.Body, c} - - return resp, nil + } + return resp, err } // Get issues a GET request via the Do function. @@ -113,28 +72,3 @@ func Post(ctx context.Context, client *http.Client, url string, bodyType string, func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) } - -// notifyingReader is an io.ReadCloser that closes the notify channel after -// Close is called or a Read fails on the underlying ReadCloser. -type notifyingReader struct { - io.ReadCloser - notify chan<- struct{} -} - -func (r *notifyingReader) Read(p []byte) (int, error) { - n, err := r.ReadCloser.Read(p) - if err != nil && r.notify != nil { - close(r.notify) - r.notify = nil - } - return n, err -} - -func (r *notifyingReader) Close() error { - err := r.ReadCloser.Close() - if r.notify != nil { - close(r.notify) - r.notify = nil - } - return err -} diff --git a/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go b/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go new file mode 100644 index 000000000..926870cc2 --- /dev/null +++ b/vendor/golang.org/x/net/context/ctxhttp/ctxhttp_pre17.go @@ -0,0 +1,147 @@ +// Copyright 2015 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.7 + +package ctxhttp // import "golang.org/x/net/context/ctxhttp" + +import ( + "io" + "net/http" + "net/url" + "strings" + + "golang.org/x/net/context" +) + +func nop() {} + +var ( + testHookContextDoneBeforeHeaders = nop + testHookDoReturned = nop + testHookDidBodyClose = nop +) + +// Do sends an HTTP request with the provided http.Client and returns an HTTP response. +// If the client is nil, http.DefaultClient is used. +// If the context is canceled or times out, ctx.Err() will be returned. +func Do(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) { + if client == nil { + client = http.DefaultClient + } + + // TODO(djd): Respect any existing value of req.Cancel. + cancel := make(chan struct{}) + req.Cancel = cancel + + type responseAndError struct { + resp *http.Response + err error + } + result := make(chan responseAndError, 1) + + // Make local copies of test hooks closed over by goroutines below. + // Prevents data races in tests. + testHookDoReturned := testHookDoReturned + testHookDidBodyClose := testHookDidBodyClose + + go func() { + resp, err := client.Do(req) + testHookDoReturned() + result <- responseAndError{resp, err} + }() + + var resp *http.Response + + select { + case <-ctx.Done(): + testHookContextDoneBeforeHeaders() + close(cancel) + // Clean up after the goroutine calling client.Do: + go func() { + if r := <-result; r.resp != nil { + testHookDidBodyClose() + r.resp.Body.Close() + } + }() + return nil, ctx.Err() + case r := <-result: + var err error + resp, err = r.resp, r.err + if err != nil { + return resp, err + } + } + + c := make(chan struct{}) + go func() { + select { + case <-ctx.Done(): + close(cancel) + case <-c: + // The response's Body is closed. + } + }() + resp.Body = ¬ifyingReader{resp.Body, c} + + return resp, nil +} + +// Get issues a GET request via the Do function. +func Get(ctx context.Context, client *http.Client, url string) (*http.Response, error) { + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return nil, err + } + return Do(ctx, client, req) +} + +// Head issues a HEAD request via the Do function. +func Head(ctx context.Context, client *http.Client, url string) (*http.Response, error) { + req, err := http.NewRequest("HEAD", url, nil) + if err != nil { + return nil, err + } + return Do(ctx, client, req) +} + +// Post issues a POST request via the Do function. +func Post(ctx context.Context, client *http.Client, url string, bodyType string, body io.Reader) (*http.Response, error) { + req, err := http.NewRequest("POST", url, body) + if err != nil { + return nil, err + } + req.Header.Set("Content-Type", bodyType) + return Do(ctx, client, req) +} + +// PostForm issues a POST request via the Do function. +func PostForm(ctx context.Context, client *http.Client, url string, data url.Values) (*http.Response, error) { + return Post(ctx, client, url, "application/x-www-form-urlencoded", strings.NewReader(data.Encode())) +} + +// notifyingReader is an io.ReadCloser that closes the notify channel after +// Close is called or a Read fails on the underlying ReadCloser. +type notifyingReader struct { + io.ReadCloser + notify chan<- struct{} +} + +func (r *notifyingReader) Read(p []byte) (int, error) { + n, err := r.ReadCloser.Read(p) + if err != nil && r.notify != nil { + close(r.notify) + r.notify = nil + } + return n, err +} + +func (r *notifyingReader) Close() error { + err := r.ReadCloser.Close() + if r.notify != nil { + close(r.notify) + r.notify = nil + } + return err +} diff --git a/vendor/golang.org/x/net/context/go17.go b/vendor/golang.org/x/net/context/go17.go new file mode 100644 index 000000000..d20f52b7d --- /dev/null +++ b/vendor/golang.org/x/net/context/go17.go @@ -0,0 +1,72 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.7 + +package context + +import ( + "context" // standard library's context, as of Go 1.7 + "time" +) + +var ( + todo = context.TODO() + background = context.Background() +) + +// Canceled is the error returned by Context.Err when the context is canceled. +var Canceled = context.Canceled + +// DeadlineExceeded is the error returned by Context.Err when the context's +// deadline passes. +var DeadlineExceeded = context.DeadlineExceeded + +// WithCancel returns a copy of parent with a new Done channel. The returned +// context's Done channel is closed when the returned cancel function is called +// or when the parent context's Done channel is closed, whichever happens first. +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this Context complete. +func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { + ctx, f := context.WithCancel(parent) + return ctx, CancelFunc(f) +} + +// WithDeadline returns a copy of the parent context with the deadline adjusted +// to be no later than d. If the parent's deadline is already earlier than d, +// WithDeadline(parent, d) is semantically equivalent to parent. The returned +// context's Done channel is closed when the deadline expires, when the returned +// cancel function is called, or when the parent context's Done channel is +// closed, whichever happens first. +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this Context complete. +func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { + ctx, f := context.WithDeadline(parent, deadline) + return ctx, CancelFunc(f) +} + +// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this Context complete: +// +// func slowOperationWithTimeout(ctx context.Context) (Result, error) { +// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) +// defer cancel() // releases resources if slowOperation completes before timeout elapses +// return slowOperation(ctx) +// } +func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { + return WithDeadline(parent, time.Now().Add(timeout)) +} + +// WithValue returns a copy of parent in which the value associated with key is +// val. +// +// Use context Values only for request-scoped data that transits processes and +// APIs, not for passing optional parameters to functions. +func WithValue(parent Context, key interface{}, val interface{}) Context { + return context.WithValue(parent, key, val) +} diff --git a/vendor/golang.org/x/net/context/go19.go b/vendor/golang.org/x/net/context/go19.go new file mode 100644 index 000000000..d88bd1db1 --- /dev/null +++ b/vendor/golang.org/x/net/context/go19.go @@ -0,0 +1,20 @@ +// Copyright 2017 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build go1.9 + +package context + +import "context" // standard library's context, as of Go 1.7 + +// A Context carries a deadline, a cancelation signal, and other values across +// API boundaries. +// +// Context's methods may be called by multiple goroutines simultaneously. +type Context = context.Context + +// A CancelFunc tells an operation to abandon its work. +// A CancelFunc does not wait for the work to stop. +// After the first call, subsequent calls to a CancelFunc do nothing. +type CancelFunc = context.CancelFunc diff --git a/vendor/golang.org/x/net/context/pre_go17.go b/vendor/golang.org/x/net/context/pre_go17.go new file mode 100644 index 000000000..0f35592df --- /dev/null +++ b/vendor/golang.org/x/net/context/pre_go17.go @@ -0,0 +1,300 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.7 + +package context + +import ( + "errors" + "fmt" + "sync" + "time" +) + +// An emptyCtx is never canceled, has no values, and has no deadline. It is not +// struct{}, since vars of this type must have distinct addresses. +type emptyCtx int + +func (*emptyCtx) Deadline() (deadline time.Time, ok bool) { + return +} + +func (*emptyCtx) Done() <-chan struct{} { + return nil +} + +func (*emptyCtx) Err() error { + return nil +} + +func (*emptyCtx) Value(key interface{}) interface{} { + return nil +} + +func (e *emptyCtx) String() string { + switch e { + case background: + return "context.Background" + case todo: + return "context.TODO" + } + return "unknown empty Context" +} + +var ( + background = new(emptyCtx) + todo = new(emptyCtx) +) + +// Canceled is the error returned by Context.Err when the context is canceled. +var Canceled = errors.New("context canceled") + +// DeadlineExceeded is the error returned by Context.Err when the context's +// deadline passes. +var DeadlineExceeded = errors.New("context deadline exceeded") + +// WithCancel returns a copy of parent with a new Done channel. The returned +// context's Done channel is closed when the returned cancel function is called +// or when the parent context's Done channel is closed, whichever happens first. +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this Context complete. +func WithCancel(parent Context) (ctx Context, cancel CancelFunc) { + c := newCancelCtx(parent) + propagateCancel(parent, c) + return c, func() { c.cancel(true, Canceled) } +} + +// newCancelCtx returns an initialized cancelCtx. +func newCancelCtx(parent Context) *cancelCtx { + return &cancelCtx{ + Context: parent, + done: make(chan struct{}), + } +} + +// propagateCancel arranges for child to be canceled when parent is. +func propagateCancel(parent Context, child canceler) { + if parent.Done() == nil { + return // parent is never canceled + } + if p, ok := parentCancelCtx(parent); ok { + p.mu.Lock() + if p.err != nil { + // parent has already been canceled + child.cancel(false, p.err) + } else { + if p.children == nil { + p.children = make(map[canceler]bool) + } + p.children[child] = true + } + p.mu.Unlock() + } else { + go func() { + select { + case <-parent.Done(): + child.cancel(false, parent.Err()) + case <-child.Done(): + } + }() + } +} + +// parentCancelCtx follows a chain of parent references until it finds a +// *cancelCtx. This function understands how each of the concrete types in this +// package represents its parent. +func parentCancelCtx(parent Context) (*cancelCtx, bool) { + for { + switch c := parent.(type) { + case *cancelCtx: + return c, true + case *timerCtx: + return c.cancelCtx, true + case *valueCtx: + parent = c.Context + default: + return nil, false + } + } +} + +// removeChild removes a context from its parent. +func removeChild(parent Context, child canceler) { + p, ok := parentCancelCtx(parent) + if !ok { + return + } + p.mu.Lock() + if p.children != nil { + delete(p.children, child) + } + p.mu.Unlock() +} + +// A canceler is a context type that can be canceled directly. The +// implementations are *cancelCtx and *timerCtx. +type canceler interface { + cancel(removeFromParent bool, err error) + Done() <-chan struct{} +} + +// A cancelCtx can be canceled. When canceled, it also cancels any children +// that implement canceler. +type cancelCtx struct { + Context + + done chan struct{} // closed by the first cancel call. + + mu sync.Mutex + children map[canceler]bool // set to nil by the first cancel call + err error // set to non-nil by the first cancel call +} + +func (c *cancelCtx) Done() <-chan struct{} { + return c.done +} + +func (c *cancelCtx) Err() error { + c.mu.Lock() + defer c.mu.Unlock() + return c.err +} + +func (c *cancelCtx) String() string { + return fmt.Sprintf("%v.WithCancel", c.Context) +} + +// cancel closes c.done, cancels each of c's children, and, if +// removeFromParent is true, removes c from its parent's children. +func (c *cancelCtx) cancel(removeFromParent bool, err error) { + if err == nil { + panic("context: internal error: missing cancel error") + } + c.mu.Lock() + if c.err != nil { + c.mu.Unlock() + return // already canceled + } + c.err = err + close(c.done) + for child := range c.children { + // NOTE: acquiring the child's lock while holding parent's lock. + child.cancel(false, err) + } + c.children = nil + c.mu.Unlock() + + if removeFromParent { + removeChild(c.Context, c) + } +} + +// WithDeadline returns a copy of the parent context with the deadline adjusted +// to be no later than d. If the parent's deadline is already earlier than d, +// WithDeadline(parent, d) is semantically equivalent to parent. The returned +// context's Done channel is closed when the deadline expires, when the returned +// cancel function is called, or when the parent context's Done channel is +// closed, whichever happens first. +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this Context complete. +func WithDeadline(parent Context, deadline time.Time) (Context, CancelFunc) { + if cur, ok := parent.Deadline(); ok && cur.Before(deadline) { + // The current deadline is already sooner than the new one. + return WithCancel(parent) + } + c := &timerCtx{ + cancelCtx: newCancelCtx(parent), + deadline: deadline, + } + propagateCancel(parent, c) + d := deadline.Sub(time.Now()) + if d <= 0 { + c.cancel(true, DeadlineExceeded) // deadline has already passed + return c, func() { c.cancel(true, Canceled) } + } + c.mu.Lock() + defer c.mu.Unlock() + if c.err == nil { + c.timer = time.AfterFunc(d, func() { + c.cancel(true, DeadlineExceeded) + }) + } + return c, func() { c.cancel(true, Canceled) } +} + +// A timerCtx carries a timer and a deadline. It embeds a cancelCtx to +// implement Done and Err. It implements cancel by stopping its timer then +// delegating to cancelCtx.cancel. +type timerCtx struct { + *cancelCtx + timer *time.Timer // Under cancelCtx.mu. + + deadline time.Time +} + +func (c *timerCtx) Deadline() (deadline time.Time, ok bool) { + return c.deadline, true +} + +func (c *timerCtx) String() string { + return fmt.Sprintf("%v.WithDeadline(%s [%s])", c.cancelCtx.Context, c.deadline, c.deadline.Sub(time.Now())) +} + +func (c *timerCtx) cancel(removeFromParent bool, err error) { + c.cancelCtx.cancel(false, err) + if removeFromParent { + // Remove this timerCtx from its parent cancelCtx's children. + removeChild(c.cancelCtx.Context, c) + } + c.mu.Lock() + if c.timer != nil { + c.timer.Stop() + c.timer = nil + } + c.mu.Unlock() +} + +// WithTimeout returns WithDeadline(parent, time.Now().Add(timeout)). +// +// Canceling this context releases resources associated with it, so code should +// call cancel as soon as the operations running in this Context complete: +// +// func slowOperationWithTimeout(ctx context.Context) (Result, error) { +// ctx, cancel := context.WithTimeout(ctx, 100*time.Millisecond) +// defer cancel() // releases resources if slowOperation completes before timeout elapses +// return slowOperation(ctx) +// } +func WithTimeout(parent Context, timeout time.Duration) (Context, CancelFunc) { + return WithDeadline(parent, time.Now().Add(timeout)) +} + +// WithValue returns a copy of parent in which the value associated with key is +// val. +// +// Use context Values only for request-scoped data that transits processes and +// APIs, not for passing optional parameters to functions. +func WithValue(parent Context, key interface{}, val interface{}) Context { + return &valueCtx{parent, key, val} +} + +// A valueCtx carries a key-value pair. It implements Value for that key and +// delegates all other calls to the embedded Context. +type valueCtx struct { + Context + key, val interface{} +} + +func (c *valueCtx) String() string { + return fmt.Sprintf("%v.WithValue(%#v, %#v)", c.Context, c.key, c.val) +} + +func (c *valueCtx) Value(key interface{}) interface{} { + if c.key == key { + return c.val + } + return c.Context.Value(key) +} diff --git a/vendor/golang.org/x/net/context/pre_go19.go b/vendor/golang.org/x/net/context/pre_go19.go new file mode 100644 index 000000000..b105f80be --- /dev/null +++ b/vendor/golang.org/x/net/context/pre_go19.go @@ -0,0 +1,109 @@ +// Copyright 2014 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// +build !go1.9 + +package context + +import "time" + +// A Context carries a deadline, a cancelation signal, and other values across +// API boundaries. +// +// Context's methods may be called by multiple goroutines simultaneously. +type Context interface { + // Deadline returns the time when work done on behalf of this context + // should be canceled. Deadline returns ok==false when no deadline is + // set. Successive calls to Deadline return the same results. + Deadline() (deadline time.Time, ok bool) + + // Done returns a channel that's closed when work done on behalf of this + // context should be canceled. Done may return nil if this context can + // never be canceled. Successive calls to Done return the same value. + // + // WithCancel arranges for Done to be closed when cancel is called; + // WithDeadline arranges for Done to be closed when the deadline + // expires; WithTimeout arranges for Done to be closed when the timeout + // elapses. + // + // Done is provided for use in select statements: + // + // // Stream generates values with DoSomething and sends them to out + // // until DoSomething returns an error or ctx.Done is closed. + // func Stream(ctx context.Context, out chan<- Value) error { + // for { + // v, err := DoSomething(ctx) + // if err != nil { + // return err + // } + // select { + // case <-ctx.Done(): + // return ctx.Err() + // case out <- v: + // } + // } + // } + // + // See http://blog.golang.org/pipelines for more examples of how to use + // a Done channel for cancelation. + Done() <-chan struct{} + + // Err returns a non-nil error value after Done is closed. Err returns + // Canceled if the context was canceled or DeadlineExceeded if the + // context's deadline passed. No other values for Err are defined. + // After Done is closed, successive calls to Err return the same value. + Err() error + + // Value returns the value associated with this context for key, or nil + // if no value is associated with key. Successive calls to Value with + // the same key returns the same result. + // + // Use context values only for request-scoped data that transits + // processes and API boundaries, not for passing optional parameters to + // functions. + // + // A key identifies a specific value in a Context. Functions that wish + // to store values in Context typically allocate a key in a global + // variable then use that key as the argument to context.WithValue and + // Context.Value. A key can be any type that supports equality; + // packages should define keys as an unexported type to avoid + // collisions. + // + // Packages that define a Context key should provide type-safe accessors + // for the values stores using that key: + // + // // Package user defines a User type that's stored in Contexts. + // package user + // + // import "golang.org/x/net/context" + // + // // User is the type of value stored in the Contexts. + // type User struct {...} + // + // // key is an unexported type for keys defined in this package. + // // This prevents collisions with keys defined in other packages. + // type key int + // + // // userKey is the key for user.User values in Contexts. It is + // // unexported; clients use user.NewContext and user.FromContext + // // instead of using this key directly. + // var userKey key = 0 + // + // // NewContext returns a new Context that carries value u. + // func NewContext(ctx context.Context, u *User) context.Context { + // return context.WithValue(ctx, userKey, u) + // } + // + // // FromContext returns the User value stored in ctx, if any. + // func FromContext(ctx context.Context) (*User, bool) { + // u, ok := ctx.Value(userKey).(*User) + // return u, ok + // } + Value(key interface{}) interface{} +} + +// A CancelFunc tells an operation to abandon its work. +// A CancelFunc does not wait for the work to stop. +// After the first call, subsequent calls to a CancelFunc do nothing. +type CancelFunc func() diff --git a/vendor/vendor.json b/vendor/vendor.json index 1c61745f5..e8c3fb6f1 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -961,12 +961,6 @@ "path": "github.com/mitchellh/mapstructure", "revision": "281073eb9eb092240d33ef253c404f1cca550309" }, - { - "checksumSHA1": "5x1RX5m8SCkCRLyLL8wBc0qJpV8=", - "path": "github.com/mitchellh/multistep", - "revision": "391576a156a54cfbb4cf5d5eda40cf6ffa3e3a4d", - "revisionTime": "2017-03-16T18:53:39Z" - }, { "checksumSHA1": "m2L8ohfZiFRsMW3iynaH/TWgnSY=", "path": "github.com/mitchellh/panicwrap", @@ -1227,14 +1221,16 @@ "revisionTime": "2017-02-08T20:51:15Z" }, { - "checksumSHA1": "5ARrN3Zq+E9zazFb/N+b08Serys=", + "checksumSHA1": "GtamqiJoL7PGHsN454AoffBFMa8=", "path": "golang.org/x/net/context", - "revision": "6ccd6698c634f5d835c40c1c31848729e0cecda1" + "revision": "5ccada7d0a7ba9aeb5d3aca8d3501b4c2a509fec", + "revisionTime": "2018-01-12T01:53:59Z" }, { - "checksumSHA1": "tHFno3QaRarH85A4DV1FYuWATQI=", + "checksumSHA1": "WHc3uByvGaMcnSoI21fhzYgbOgg=", "path": "golang.org/x/net/context/ctxhttp", - "revision": "6ccd6698c634f5d835c40c1c31848729e0cecda1" + "revision": "5ccada7d0a7ba9aeb5d3aca8d3501b4c2a509fec", + "revisionTime": "2018-01-12T01:53:59Z" }, { "checksumSHA1": "vqc3a+oTUGX8PmD0TS+qQ7gmN8I=", diff --git a/website/source/docs/extending/custom-builders.html.md b/website/source/docs/extending/custom-builders.html.md index 7cd31b161..3d421f35d 100644 --- a/website/source/docs/extending/custom-builders.html.md +++ b/website/source/docs/extending/custom-builders.html.md @@ -82,11 +82,11 @@ And `packer.Cache` is used to store files between multiple Packer runs, and is covered in more detail in the cache section below. Because builder runs are typically a complex set of many steps, the -[multistep](https://github.com/mitchellh/multistep) library is recommended to -bring order to the complexity. Multistep is a library which allows you to -separate your logic into multiple distinct "steps" and string them together. It -fully supports cancellation mid-step and so on. Please check it out, it is how -the built-in builders are all implemented. +[multistep](https://github.com/hashicorp/packer/blob/master/helper/multistep) +helper is recommended to bring order to the complexity. Multistep is a library +which allows you to separate your logic into multiple distinct "steps" and +string them together. It fully supports cancellation mid-step and so on. Please +check it out, it is how the built-in builders are all implemented. Finally, as a result of `Run`, an implementation of `packer.Artifact` should be returned. More details on creating a `packer.Artifact` are covered in the