diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 446d324a1..50a81c058 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -164,8 +165,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.config.SSHPrivateIp), SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.RunConfig.Comm, }, &stepStopAlicloudInstance{ @@ -206,7 +207,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }) // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index a87170c2d..af2893b10 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -17,6 +17,7 @@ import ( awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/chroot" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/hcl2template" "github.com/hashicorp/packer/helper/config" @@ -478,7 +479,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack ) // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 04142b796..6a2077a8b 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/hcl2template" "github.com/hashicorp/packer/helper/communicator" @@ -298,8 +299,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &awscommon.StepSetGeneratedData{ GeneratedData: generatedData, }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.RunConfig.Comm, }, &awscommon.StepStopEBSBackedInstance{ @@ -350,7 +351,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index 6934ce0dc..5d80cc5fa 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/hcl2template" "github.com/hashicorp/packer/helper/communicator" @@ -322,8 +323,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &awscommon.StepSetGeneratedData{ GeneratedData: generatedData, }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.RunConfig.Comm, }, &awscommon.StepStopEBSBackedInstance{ @@ -389,7 +390,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index f9324c0ca..eb352f48b 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/hcl2template" "github.com/hashicorp/packer/helper/communicator" @@ -299,8 +300,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &awscommon.StepSetGeneratedData{ GeneratedData: generatedData, }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.RunConfig.Comm, }, &awscommon.StepStopEBSBackedInstance{ @@ -315,7 +316,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index a717a7750..7e606104d 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -17,6 +17,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" @@ -369,8 +370,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &awscommon.StepSetGeneratedData{ GeneratedData: generatedData, }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.RunConfig.Comm, }, &StepUploadX509Cert{}, @@ -420,7 +421,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index 90bbcc413..7cb551770 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -18,7 +18,7 @@ import ( packerAzureCommon "github.com/hashicorp/packer/builder/azure/common" "github.com/hashicorp/packer/builder/azure/common/constants" "github.com/hashicorp/packer/builder/azure/common/lin" - packerCommon "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -211,8 +211,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: lin.SSHHost, SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &packerCommon.StepProvision{}, - &packerCommon.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, NewStepGetOSDisk(azureClient, ui), @@ -254,7 +254,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, nil }, }, - &packerCommon.StepProvision{}, + &commonsteps.StepProvision{}, NewStepGetOSDisk(azureClient, ui), NewStepGetAdditionalDisks(azureClient, ui), NewStepPowerOffCompute(azureClient, ui), @@ -279,7 +279,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } } - b.runner = packerCommon.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, b.stateBag) // Report any errors. diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index a34ceb223..a6e53af84 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/packer/builder/azure/common/client" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/chroot" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -439,7 +440,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack steps := buildsteps(b.config, info) // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/azure/dtl/builder.go b/builder/azure/dtl/builder.go index 02334ba36..303af3322 100644 --- a/builder/azure/dtl/builder.go +++ b/builder/azure/dtl/builder.go @@ -17,7 +17,7 @@ import ( packerAzureCommon "github.com/hashicorp/packer/builder/azure/common" "github.com/hashicorp/packer/builder/azure/common/constants" "github.com/hashicorp/packer/builder/azure/common/lin" - packerCommon "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -187,8 +187,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: lin.SSHHost, SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &packerCommon.StepProvision{}, - &packerCommon.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, NewStepPowerOffCompute(azureClient, ui, b.config), @@ -215,7 +215,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, nil }, }, - &packerCommon.StepProvision{}, + &commonsteps.StepProvision{}, NewStepPowerOffCompute(azureClient, ui, b.config), NewStepCaptureImage(azureClient, ui, b.config), NewStepPublishToSharedImageGallery(azureClient, ui, b.config), @@ -237,7 +237,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } } - b.runner = packerCommon.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, b.stateBag) // Report any errors. diff --git a/builder/cloudstack/builder.go b/builder/cloudstack/builder.go index c7454d0a2..68e46f523 100644 --- a/builder/cloudstack/builder.go +++ b/builder/cloudstack/builder.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -60,7 +60,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack // Build the steps. steps := []multistep.Step{ &stepPrepareConfig{}, - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -85,8 +85,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack SSHPort: commPort, WinRMPort: commPort, }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, &stepShutdownInstance{}, @@ -94,7 +94,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Configure the runner and run the steps. - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/cloudstack/config.go b/builder/cloudstack/config.go index 5ef0f5e29..219667933 100644 --- a/builder/cloudstack/config.go +++ b/builder/cloudstack/config.go @@ -10,6 +10,7 @@ import ( "time" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/uuid" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" @@ -19,9 +20,9 @@ import ( // Config holds all the details needed to configure the builder. type Config struct { - common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - Comm communicator.Config `mapstructure:",squash"` + common.PackerConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + Comm communicator.Config `mapstructure:",squash"` // The CloudStack API endpoint we will connect to. It can // also be specified via environment variable CLOUDSTACK_API_URL, if set. diff --git a/builder/digitalocean/builder.go b/builder/digitalocean/builder.go index b4492d7d5..21d7be7c8 100644 --- a/builder/digitalocean/builder.go +++ b/builder/digitalocean/builder.go @@ -11,7 +11,7 @@ import ( "github.com/digitalocean/godo" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -91,8 +91,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: communicator.CommHost(b.config.Comm.Host(), "droplet_ip"), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - new(common.StepProvision), - &common.StepCleanupTempKeys{ + new(commonsteps.StepProvision), + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, new(stepShutdown), @@ -103,7 +103,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run the steps - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/docker/builder.go b/builder/docker/builder.go index 3097007f2..f1487f9c0 100644 --- a/builder/docker/builder.go +++ b/builder/docker/builder.go @@ -5,7 +5,7 @@ import ( "log" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" @@ -70,8 +70,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack "dockerWindowsContainer": &StepConnectDocker{}, }, }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, } @@ -93,7 +93,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/googlecompute/builder.go b/builder/googlecompute/builder.go index 74df7f53d..032ba3457 100644 --- a/builder/googlecompute/builder.go +++ b/builder/googlecompute/builder.go @@ -8,7 +8,7 @@ import ( "log" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -95,8 +95,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack SSHConfig: b.config.Comm.SSHConfigFunc(), WinRMConfig: winrmConfig, }, - new(common.StepProvision), - &common.StepCleanupTempKeys{ + new(commonsteps.StepProvision), + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, } @@ -106,7 +106,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack steps = append(steps, new(StepTeardownInstance), new(StepCreateImage)) // Run the steps. - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // Report any errors. diff --git a/builder/hcloud/builder.go b/builder/hcloud/builder.go index be311e7bc..34688984e 100644 --- a/builder/hcloud/builder.go +++ b/builder/hcloud/builder.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -61,15 +61,15 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: getServerIP, SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, &stepShutdownServer{}, &stepCreateSnapshot{}, } // Run the steps - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/hyperone/builder.go b/builder/hyperone/builder.go index c5f1f3c1a..7364d69ae 100644 --- a/builder/hyperone/builder.go +++ b/builder/hyperone/builder.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -91,13 +91,13 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack ) } else { steps = append(steps, - &common.StepProvision{}, + &commonsteps.StepProvision{}, &stepStopVM{}, &stepCreateImage{}, ) } - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/hyperone/step_chroot_provision.go b/builder/hyperone/step_chroot_provision.go index 005c869c5..f0aa6acb0 100644 --- a/builder/hyperone/step_chroot_provision.go +++ b/builder/hyperone/step_chroot_provision.go @@ -3,7 +3,7 @@ package hyperone import ( "context" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -21,7 +21,7 @@ func (s *stepChrootProvision) Run(ctx context.Context, state multistep.StateBag) Wrapped: sshCommunicator, } - stepProvision := common.StepProvision{Comm: comm} + stepProvision := commonsteps.StepProvision{Comm: comm} return stepProvision.Run(ctx, state) } diff --git a/builder/hyperv/common/config.go b/builder/hyperv/common/config.go index 74de2cbe6..2c1e47c34 100644 --- a/builder/hyperv/common/config.go +++ b/builder/hyperv/common/config.go @@ -11,6 +11,7 @@ import ( powershell "github.com/hashicorp/packer/builder/hyperv/common/powershell" "github.com/hashicorp/packer/builder/hyperv/common/powershell/hyperv" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) @@ -36,8 +37,8 @@ const ( ) type CommonConfig struct { - common.FloppyConfig `mapstructure:",squash"` - common.CDConfig `mapstructure:",squash"` + commonsteps.FloppyConfig `mapstructure:",squash"` + commonsteps.CDConfig `mapstructure:",squash"` // The block size of the VHD to be created. // Recommended disk block size for Linux hyper-v guests is 1 MiB. This // defaults to "32" MiB. diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index 91e2bc676..9bd604b18 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -15,6 +15,7 @@ import ( hypervcommon "github.com/hashicorp/packer/builder/hyperv/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/shutdowncommand" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" @@ -53,8 +54,8 @@ type Builder struct { type Config struct { common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - common.ISOConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.ISOConfig `mapstructure:",squash"` bootcommand.BootConfig `mapstructure:",squash"` hypervcommon.OutputConfig `mapstructure:",squash"` hypervcommon.SSHConfig `mapstructure:",squash"` @@ -193,11 +194,11 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &hypervcommon.StepCreateBuildDir{ TempPath: b.config.TempPath, }, - &common.StepOutputDir{ + &commonsteps.StepOutputDir{ Force: b.config.PackerForce, Path: b.config.OutputDir, }, - &common.StepDownload{ + &commonsteps.StepDownload{ Checksum: b.config.ISOChecksum, Description: "ISO", ResultKey: "iso_path", @@ -205,12 +206,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Extension: b.config.TargetExtension, TargetPath: b.config.TargetPath, }, - &common.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, Label: b.config.FloppyConfig.FloppyLabel, }, - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -255,7 +256,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack GuestAdditionsPath: b.config.GuestAdditionsPath, Generation: b.config.Generation, }, - &common.StepCreateCD{ + &commonsteps.StepCreateCD{ Files: b.config.CDConfig.CDFiles, Label: b.config.CDConfig.CDLabel, }, @@ -298,10 +299,10 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, // provision requires communicator to be setup - &common.StepProvision{}, + &commonsteps.StepProvision{}, // Remove ephemeral key from authorized_hosts if using SSH communicator - &common.StepCleanupTempKeys{ + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.SSHConfig.Comm, }, @@ -337,7 +338,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run the steps. - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // Report any errors. diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index ec4dea9a0..ed688a89f 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -15,6 +15,7 @@ import ( powershell "github.com/hashicorp/packer/builder/hyperv/common/powershell" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/shutdowncommand" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" @@ -44,8 +45,8 @@ type Builder struct { type Config struct { common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - common.ISOConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.ISOConfig `mapstructure:",squash"` bootcommand.BootConfig `mapstructure:",squash"` hypervcommon.OutputConfig `mapstructure:",squash"` hypervcommon.SSHConfig `mapstructure:",squash"` @@ -233,11 +234,11 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &hypervcommon.StepCreateBuildDir{ TempPath: b.config.TempPath, }, - &common.StepOutputDir{ + &commonsteps.StepOutputDir{ Force: b.config.PackerForce, Path: b.config.OutputDir, }, - &common.StepDownload{ + &commonsteps.StepDownload{ Checksum: b.config.ISOChecksum, Description: "ISO", ResultKey: "iso_path", @@ -245,12 +246,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Extension: b.config.TargetExtension, TargetPath: b.config.TargetPath, }, - &common.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, Label: b.config.FloppyConfig.FloppyLabel, }, - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -295,7 +296,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack GuestAdditionsPath: b.config.GuestAdditionsPath, Generation: b.config.Generation, }, - &common.StepCreateCD{ + &commonsteps.StepCreateCD{ Files: b.config.CDConfig.CDFiles, Label: b.config.CDConfig.CDLabel, }, @@ -338,10 +339,10 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, // provision requires communicator to be setup - &common.StepProvision{}, + &commonsteps.StepProvision{}, // Remove ephemeral SSH keys, if using - &common.StepCleanupTempKeys{ + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.SSHConfig.Comm, }, @@ -377,7 +378,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack // the clean up actions for each step will be executed reverse order // Run the steps. - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // Report any errors. diff --git a/builder/jdcloud/builder.go b/builder/jdcloud/builder.go index 8ed2c59cd..76f1b3b3d 100644 --- a/builder/jdcloud/builder.go +++ b/builder/jdcloud/builder.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -70,7 +70,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: instanceHost, }, - &common.StepProvision{}, + &commonsteps.StepProvision{}, &stepStopJDCloudInstance{ InstanceSpecConfig: &b.config.JDCloudInstanceSpecConfig, @@ -81,7 +81,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, } - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/linode/builder.go b/builder/linode/builder.go index 0eff01aec..8141cb091 100644 --- a/builder/linode/builder.go +++ b/builder/linode/builder.go @@ -9,9 +9,9 @@ import ( "log" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" "github.com/linode/linodego" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -62,15 +62,15 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (ret Host: commHost(b.config.Comm.Host()), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, &stepShutdownLinode{client}, &stepCreateImage{client}, } - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/lxc/builder.go b/builder/lxc/builder.go index feca45e90..86e125c14 100644 --- a/builder/lxc/builder.go +++ b/builder/lxc/builder.go @@ -6,7 +6,7 @@ import ( "path/filepath" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -59,7 +59,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("wrappedCommand", CommandWrapper(wrappedCommand)) // Run - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/lxc/step_provision.go b/builder/lxc/step_provision.go index fe9f3264b..3a76f26e4 100644 --- a/builder/lxc/step_provision.go +++ b/builder/lxc/step_provision.go @@ -4,7 +4,7 @@ import ( "context" "log" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -28,7 +28,7 @@ func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multi } // Loads hook data from builder's state, if it has been set. - hookData := common.PopulateProvisionHookData(state) + hookData := commonsteps.PopulateProvisionHookData(state) // Update state generated_data with complete hookData // to make them accessible by post-processors diff --git a/builder/lxd/builder.go b/builder/lxd/builder.go index 1a4ae2778..24e700949 100644 --- a/builder/lxd/builder.go +++ b/builder/lxd/builder.go @@ -4,7 +4,7 @@ import ( "context" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -53,7 +53,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("wrappedCommand", CommandWrapper(wrappedCommand)) // Run - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/lxd/step_provision.go b/builder/lxd/step_provision.go index 79f43b21a..114be8fce 100644 --- a/builder/lxd/step_provision.go +++ b/builder/lxd/step_provision.go @@ -4,7 +4,7 @@ import ( "context" "log" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -25,7 +25,7 @@ func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multi } // Loads hook data from builder's state, if it has been set. - hookData := common.PopulateProvisionHookData(state) + hookData := commonsteps.PopulateProvisionHookData(state) // Update state generated_data with complete hookData // to make them accessible by post-processors diff --git a/builder/ncloud/builder.go b/builder/ncloud/builder.go index 5645471b5..c802a2ada 100644 --- a/builder/ncloud/builder.go +++ b/builder/ncloud/builder.go @@ -5,7 +5,7 @@ import ( "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -65,8 +65,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, NewStepStopServerInstance(conn, ui), @@ -94,7 +94,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, nil }, }, - &common.StepProvision{}, + &commonsteps.StepProvision{}, NewStepStopServerInstance(conn, ui), NewStepCreateServerImage(conn, ui, &b.config), NewStepDeleteBlockStorageInstance(conn, ui, &b.config), @@ -103,7 +103,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run! - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, b.stateBag) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, b.stateBag) b.runner.Run(ctx, b.stateBag) // If there was an error, return that diff --git a/builder/null/builder.go b/builder/null/builder.go index 1d2fc40e4..3af67c187 100644 --- a/builder/null/builder.go +++ b/builder/null/builder.go @@ -4,7 +4,7 @@ import ( "context" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -40,7 +40,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack ) steps = append(steps, - new(common.StepProvision), + new(commonsteps.StepProvision), ) // Setup the state bag and initial state for the steps @@ -50,7 +50,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("instance_id", "Null") // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/oneandone/builder.go b/builder/oneandone/builder.go index 8fe3526fd..1600bf7f6 100644 --- a/builder/oneandone/builder.go +++ b/builder/oneandone/builder.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -49,14 +49,14 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: communicator.CommHost(b.config.Comm.Host(), "server_ip"), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, new(stepTakeSnapshot), } - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index 99c226c9a..c93553fcc 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -155,8 +156,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.config.SSHIPVersion), SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.RunConfig.Comm, }, &StepStopServer{}, @@ -173,7 +174,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/oracle/classic/builder.go b/builder/oracle/classic/builder.go index 6a49f808a..87f351ea2 100644 --- a/builder/oracle/classic/builder.go +++ b/builder/oracle/classic/builder.go @@ -12,7 +12,7 @@ import ( "github.com/hashicorp/go-oracle-terraform/opc" "github.com/hashicorp/hcl/v2/hcldec" ocommon "github.com/hashicorp/packer/builder/oracle/common" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -106,7 +106,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: communicator.CommHost(b.config.Comm.Host(), "instance_ip"), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, + &commonsteps.StepProvision{}, &stepTerminatePVMaster{}, &stepSecurity{ SecurityListKey: "security_list_builder", @@ -142,7 +142,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, &stepCreateImage{}, &stepListImages{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, } @@ -169,8 +169,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: communicator.CommHost(b.config.Comm.Host(), "instance_ip"), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, &stepSnapshot{}, @@ -179,7 +179,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run the steps - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/oracle/oci/builder.go b/builder/oracle/oci/builder.go index 96eaee591..f10be1e8c 100644 --- a/builder/oracle/oci/builder.go +++ b/builder/oracle/oci/builder.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" ocommon "github.com/hashicorp/packer/builder/oracle/common" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -70,15 +70,15 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: communicator.CommHost(b.config.Comm.Host(), "instance_ip"), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, &stepImage{}, } // Run the steps - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/osc/bsu/builder.go b/builder/osc/bsu/builder.go index 1d3507cfc..e495547c6 100644 --- a/builder/osc/bsu/builder.go +++ b/builder/osc/bsu/builder.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -163,8 +164,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.config.SSHInterface), SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.RunConfig.Comm, }, &osccommon.StepStopBSUBackedVm{ @@ -194,7 +195,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, } - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index fe276aa3b..d01e97c44 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -185,8 +186,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.config.SSHInterface), SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.RunConfig.Comm, }, &osccommon.StepStopBSUBackedVm{ @@ -221,7 +222,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, } - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/osc/bsuvolume/builder.go b/builder/osc/bsuvolume/builder.go index d04366dfd..e265bbd2e 100644 --- a/builder/osc/bsuvolume/builder.go +++ b/builder/osc/bsuvolume/builder.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -173,8 +174,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.config.SSHInterface), SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.RunConfig.Comm, }, &osccommon.StepStopBSUBackedVm{ @@ -184,7 +185,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index 3bc45dc51..099cb4f7f 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -278,7 +279,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack ) // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/osc/chroot/step_chroot_provision.go b/builder/osc/chroot/step_chroot_provision.go index e621f2fb6..39f034901 100644 --- a/builder/osc/chroot/step_chroot_provision.go +++ b/builder/osc/chroot/step_chroot_provision.go @@ -4,7 +4,7 @@ import ( "context" "log" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -26,7 +26,7 @@ func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) } // Loads hook data from builder's state, if it has been set. - hookData := common.PopulateProvisionHookData(state) + hookData := commonsteps.PopulateProvisionHookData(state) // Update state generated_data with complete hookData // to make them accessible by post-processors diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index 40549cc20..55d395f61 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -12,6 +12,7 @@ import ( parallelscommon "github.com/hashicorp/packer/builder/parallels/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/shutdowncommand" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" @@ -29,9 +30,9 @@ type Builder struct { type Config struct { common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - common.ISOConfig `mapstructure:",squash"` - common.FloppyConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.ISOConfig `mapstructure:",squash"` + commonsteps.FloppyConfig `mapstructure:",squash"` bootcommand.BootConfig `mapstructure:",squash"` parallelscommon.OutputConfig `mapstructure:",squash"` parallelscommon.HWConfig `mapstructure:",squash"` @@ -191,7 +192,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack ParallelsToolsFlavor: b.config.ParallelsToolsFlavor, ParallelsToolsMode: b.config.ParallelsToolsMode, }, - &common.StepDownload{ + &commonsteps.StepDownload{ Checksum: b.config.ISOChecksum, Description: "ISO", Extension: b.config.TargetExtension, @@ -203,12 +204,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Force: b.config.PackerForce, Path: b.config.OutputDir, }, - &common.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, Label: b.config.FloppyConfig.FloppyLabel, }, - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -249,8 +250,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack ParallelsToolsMode: b.config.ParallelsToolsMode, Ctx: b.config.ctx, }, - new(common.StepProvision), - &common.StepCleanupTempKeys{ + new(commonsteps.StepProvision), + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.SSHConfig.Comm, }, ¶llelscommon.StepShutdown{ @@ -275,7 +276,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("ui", ui) // Run - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/parallels/pvm/builder.go b/builder/parallels/pvm/builder.go index 5add2b27a..dcf6ce2eb 100644 --- a/builder/parallels/pvm/builder.go +++ b/builder/parallels/pvm/builder.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -59,7 +59,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Force: b.config.PackerForce, Path: b.config.OutputDir, }, - &common.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, Label: b.config.FloppyConfig.FloppyLabel, @@ -99,12 +99,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack ParallelsToolsMode: b.config.ParallelsToolsMode, Ctx: b.config.ctx, }, - new(common.StepProvision), + new(commonsteps.StepProvision), ¶llelscommon.StepShutdown{ Command: b.config.ShutdownCommand, Timeout: b.config.ShutdownTimeout, }, - &common.StepCleanupTempKeys{ + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.SSHConfig.Comm, }, ¶llelscommon.StepPrlctl{ @@ -117,7 +117,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run the steps. - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // Report any errors. diff --git a/builder/parallels/pvm/config.go b/builder/parallels/pvm/config.go index 0f74308d2..49afa0bd6 100644 --- a/builder/parallels/pvm/config.go +++ b/builder/parallels/pvm/config.go @@ -10,6 +10,7 @@ import ( parallelscommon "github.com/hashicorp/packer/builder/parallels/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/shutdowncommand" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" @@ -19,7 +20,7 @@ import ( // Config is the configuration structure for the builder. type Config struct { common.PackerConfig `mapstructure:",squash"` - common.FloppyConfig `mapstructure:",squash"` + commonsteps.FloppyConfig `mapstructure:",squash"` parallelscommon.OutputConfig `mapstructure:",squash"` parallelscommon.PrlctlConfig `mapstructure:",squash"` parallelscommon.PrlctlPostConfig `mapstructure:",squash"` diff --git a/builder/profitbricks/builder.go b/builder/profitbricks/builder.go index f55d6ae0b..1cf8cc1f8 100644 --- a/builder/profitbricks/builder.go +++ b/builder/profitbricks/builder.go @@ -5,7 +5,7 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -46,8 +46,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: communicator.CommHost(b.config.Comm.Host(), "server_ip"), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, new(stepTakeSnapshot), @@ -55,7 +55,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack config := state.Get("config").(*Config) - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/proxmox/common/builder.go b/builder/proxmox/common/builder.go index a4b407520..784549160 100644 --- a/builder/proxmox/common/builder.go +++ b/builder/proxmox/common/builder.go @@ -7,7 +7,7 @@ import ( "fmt" "github.com/Telmate/proxmox-api-go/proxmox" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -61,7 +61,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook, state &stepStartVM{ vmCreator: b.vmCreator, }, - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -76,8 +76,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook, state Host: commHost((*comm).Host()), SSHConfig: (*comm).SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, &stepConvertToTemplate{}, @@ -87,7 +87,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook, state steps := append(b.preSteps, coreSteps...) steps = append(steps, b.postSteps...) // Run the steps - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/proxmox/common/config.go b/builder/proxmox/common/config.go index 728f31986..8686c4f0b 100644 --- a/builder/proxmox/common/config.go +++ b/builder/proxmox/common/config.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/uuid" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" @@ -23,7 +24,7 @@ import ( type Config struct { common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` bootcommand.BootConfig `mapstructure:",squash"` BootKeyInterval time.Duration `mapstructure:"boot_key_interval"` Comm communicator.Config `mapstructure:",squash"` @@ -66,13 +67,13 @@ type Config struct { } type storageConfig struct { - common.ISOConfig `mapstructure:",squash"` - Device string `mapstructure:"device"` - ISOFile string `mapstructure:"iso_file"` - ISOStoragePool string `mapstructure:"iso_storage_pool"` - Unmount bool `mapstructure:"unmount"` - ShouldUploadISO bool - DownloadPathKey string + commonsteps.ISOConfig `mapstructure:",squash"` + Device string `mapstructure:"device"` + ISOFile string `mapstructure:"iso_file"` + ISOStoragePool string `mapstructure:"iso_storage_pool"` + Unmount bool `mapstructure:"unmount"` + ShouldUploadISO bool + DownloadPathKey string } type nicConfig struct { @@ -133,9 +134,9 @@ func (c *Config) Prepare(upper interface{}, raws ...interface{}) ([]string, []st if c.Password == "" { c.Password = os.Getenv("PROXMOX_PASSWORD") } - if c.BootKeyInterval == 0 && os.Getenv(common.PackerKeyEnv) != "" { + if c.BootKeyInterval == 0 && os.Getenv(bootcommand.PackerKeyEnv) != "" { var err error - c.BootKeyInterval, err = time.ParseDuration(os.Getenv(common.PackerKeyEnv)) + c.BootKeyInterval, err = time.ParseDuration(os.Getenv(bootcommand.PackerKeyEnv)) if err != nil { errs = packer.MultiErrorAppend(errs, err) } diff --git a/builder/proxmox/iso/builder.go b/builder/proxmox/iso/builder.go index 3c7fb960b..699308b58 100644 --- a/builder/proxmox/iso/builder.go +++ b/builder/proxmox/iso/builder.go @@ -6,7 +6,7 @@ import ( proxmoxapi "github.com/Telmate/proxmox-api-go/proxmox" "github.com/hashicorp/hcl/v2/hcldec" proxmox "github.com/hashicorp/packer/builder/proxmox/common" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -34,7 +34,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("iso-config", &b.config) preSteps := []multistep.Step{ - &common.StepDownload{ + &commonsteps.StepDownload{ Checksum: b.config.ISOChecksum, Description: "ISO", Extension: b.config.TargetExtension, @@ -44,7 +44,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, } for idx := range b.config.AdditionalISOFiles { - preSteps = append(preSteps, &common.StepDownload{ + preSteps = append(preSteps, &commonsteps.StepDownload{ Checksum: b.config.AdditionalISOFiles[idx].ISOChecksum, Description: "additional ISO", Extension: b.config.AdditionalISOFiles[idx].TargetExtension, diff --git a/builder/proxmox/iso/config.go b/builder/proxmox/iso/config.go index a04c41c05..4f80fe28f 100644 --- a/builder/proxmox/iso/config.go +++ b/builder/proxmox/iso/config.go @@ -10,18 +10,18 @@ import ( "strings" proxmox "github.com/hashicorp/packer/builder/proxmox/common" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/packer" ) type Config struct { proxmox.Config `mapstructure:",squash"` - common.ISOConfig `mapstructure:",squash"` - ISOFile string `mapstructure:"iso_file"` - ISOStoragePool string `mapstructure:"iso_storage_pool"` - UnmountISO bool `mapstructure:"unmount_iso"` - shouldUploadISO bool + commonsteps.ISOConfig `mapstructure:",squash"` + ISOFile string `mapstructure:"iso_file"` + ISOStoragePool string `mapstructure:"iso_storage_pool"` + UnmountISO bool `mapstructure:"unmount_iso"` + shouldUploadISO bool } func (c *Config) Prepare(raws ...interface{}) ([]string, []string, error) { diff --git a/builder/proxmox/iso/step_upload_iso_test.go b/builder/proxmox/iso/step_upload_iso_test.go index 418005a0c..a6b7fa4fd 100644 --- a/builder/proxmox/iso/step_upload_iso_test.go +++ b/builder/proxmox/iso/step_upload_iso_test.go @@ -6,7 +6,7 @@ import ( "io" "testing" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -51,7 +51,7 @@ func TestUploadISO(t *testing.T) { builderConfig: &Config{ shouldUploadISO: true, ISOStoragePool: "local", - ISOConfig: common.ISOConfig{ISOUrls: []string{"http://server.example/some-file.iso"}}, + ISOConfig: commonsteps.ISOConfig{ISOUrls: []string{"http://server.example/some-file.iso"}}, }, downloadPath: "testdata/test.iso", @@ -64,7 +64,7 @@ func TestUploadISO(t *testing.T) { builderConfig: &Config{ shouldUploadISO: true, ISOStoragePool: "local", - ISOConfig: common.ISOConfig{ISOUrls: []string{"http://server.example/some-file.iso"}}, + ISOConfig: commonsteps.ISOConfig{ISOUrls: []string{"http://server.example/some-file.iso"}}, }, downloadPath: "testdata/test.iso", failUpload: true, @@ -78,7 +78,7 @@ func TestUploadISO(t *testing.T) { builderConfig: &Config{ shouldUploadISO: true, ISOStoragePool: "local", - ISOConfig: common.ISOConfig{ISOUrls: []string{"http://server.example/some-file.iso"}}, + ISOConfig: commonsteps.ISOConfig{ISOUrls: []string{"http://server.example/some-file.iso"}}, }, expectError: true, @@ -90,7 +90,7 @@ func TestUploadISO(t *testing.T) { builderConfig: &Config{ shouldUploadISO: true, ISOStoragePool: "local", - ISOConfig: common.ISOConfig{ISOUrls: []string{"http://server.example/some-file.iso"}}, + ISOConfig: commonsteps.ISOConfig{ISOUrls: []string{"http://server.example/some-file.iso"}}, }, downloadPath: "testdata/non-existent.iso", diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index 6f0939f69..1c94ad70a 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -10,7 +10,7 @@ import ( "path/filepath" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -43,7 +43,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack steps := []multistep.Step{} if !b.config.ISOSkipCache { - steps = append(steps, &common.StepDownload{ + steps = append(steps, &commonsteps.StepDownload{ Checksum: b.config.ISOChecksum, Description: "ISO", Extension: b.config.TargetExtension, @@ -59,12 +59,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } steps = append(steps, new(stepPrepareOutputDir), - &common.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, Label: b.config.FloppyConfig.FloppyLabel, }, - &common.StepCreateCD{ + &commonsteps.StepCreateCD{ Files: b.config.CDConfig.CDFiles, Label: b.config.CDConfig.CDLabel, }, @@ -96,7 +96,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack QemuImgArgs: b.config.QemuImgArgs, }, new(stepHTTPIPDiscover), - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -126,8 +126,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack SSHPort: commPort, WinRMPort: commPort, }, - new(common.StepProvision), - &common.StepCleanupTempKeys{ + new(commonsteps.StepProvision), + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.CommConfig.Comm, }, &stepShutdown{ @@ -154,7 +154,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("ui", ui) // Run - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/qemu/config.go b/builder/qemu/config.go index 13f6c6320..7f3541ba7 100644 --- a/builder/qemu/config.go +++ b/builder/qemu/config.go @@ -15,6 +15,7 @@ import ( "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/shutdowncommand" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" @@ -65,13 +66,13 @@ type QemuImgArgs struct { type Config struct { common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - common.ISOConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.ISOConfig `mapstructure:",squash"` bootcommand.VNCConfig `mapstructure:",squash"` shutdowncommand.ShutdownConfig `mapstructure:",squash"` CommConfig CommConfig `mapstructure:",squash"` - common.FloppyConfig `mapstructure:",squash"` - common.CDConfig `mapstructure:",squash"` + commonsteps.FloppyConfig `mapstructure:",squash"` + commonsteps.CDConfig `mapstructure:",squash"` // Use iso from provided url. Qemu must support // curl block device. This defaults to `false`. ISOSkipCache bool `mapstructure:"iso_skip_cache" required:"false"` diff --git a/builder/qemu/step_run_test.go b/builder/qemu/step_run_test.go index 3bd5375c5..194ebf541 100644 --- a/builder/qemu/step_run_test.go +++ b/builder/qemu/step_run_test.go @@ -4,7 +4,7 @@ import ( "fmt" "testing" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -40,7 +40,7 @@ func Test_UserOverrides(t *testing.T) { testcases := []testCase{ { &Config{ - HTTPConfig: common.HTTPConfig{ + HTTPConfig: commonsteps.HTTPConfig{ HTTPDir: "http/directory", }, OutputDir: "output/directory", diff --git a/builder/scaleway/builder.go b/builder/scaleway/builder.go index e25d4cd0e..157fe624a 100644 --- a/builder/scaleway/builder.go +++ b/builder/scaleway/builder.go @@ -9,7 +9,7 @@ import ( "fmt" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -82,8 +82,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: communicator.CommHost(b.config.Comm.Host(), "server_ip"), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - new(common.StepProvision), - &common.StepCleanupTempKeys{ + new(commonsteps.StepProvision), + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Comm, }, new(stepShutdown), @@ -91,7 +91,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack new(stepImage), } - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/tencentcloud/cvm/builder.go b/builder/tencentcloud/cvm/builder.go index 89c799c18..9bbc04a79 100644 --- a/builder/tencentcloud/cvm/builder.go +++ b/builder/tencentcloud/cvm/builder.go @@ -8,6 +8,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -123,8 +124,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack SSHConfig: b.config.TencentCloudRunConfig.Comm.SSHConfigFunc(), Host: SSHHost(b.config.AssociatePublicIpAddress), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.TencentCloudRunConfig.Comm, }, // We need this step to detach keypair from instance, otherwise @@ -140,7 +141,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, } - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/triton/builder.go b/builder/triton/builder.go index 70e8cd88d..5375552b3 100644 --- a/builder/triton/builder.go +++ b/builder/triton/builder.go @@ -5,7 +5,7 @@ import ( "github.com/hashicorp/go-multierror" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -71,8 +71,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: commHost(b.config.Comm.Host()), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &config.Comm, }, &StepStopMachine{}, @@ -80,7 +80,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &StepDeleteMachine{}, } - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/ucloud/uhost/builder.go b/builder/ucloud/uhost/builder.go index 21c9204df..24b9a68e4 100644 --- a/builder/ucloud/uhost/builder.go +++ b/builder/ucloud/uhost/builder.go @@ -10,6 +10,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -125,7 +126,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack b.config.UseSSHPrivateIp), SSHConfig: b.config.RunConfig.Comm.SSHConfigFunc(), }, - &common.StepProvision{}, + &commonsteps.StepProvision{}, &stepStopInstance{}, &stepCreateImage{}, &stepCopyUCloudImage{ @@ -137,7 +138,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run! - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/vagrant/builder.go b/builder/vagrant/builder.go index 8dd88464e..bdacf9a42 100644 --- a/builder/vagrant/builder.go +++ b/builder/vagrant/builder.go @@ -16,6 +16,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -31,11 +32,11 @@ type Builder struct { } type Config struct { - common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - common.ISOConfig `mapstructure:",squash"` - common.FloppyConfig `mapstructure:",squash"` - bootcommand.BootConfig `mapstructure:",squash"` + common.PackerConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.ISOConfig `mapstructure:",squash"` + commonsteps.FloppyConfig `mapstructure:",squash"` + bootcommand.BootConfig `mapstructure:",squash"` Comm communicator.Config `mapstructure:",squash"` // The directory to create that will contain your output box. We always @@ -298,7 +299,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack steps := []multistep.Step{} // Download if source box isn't from vagrant cloud. if strings.HasSuffix(b.config.SourceBox, ".box") { - steps = append(steps, &common.StepDownload{ + steps = append(steps, &commonsteps.StepDownload{ Checksum: b.config.Checksum, Description: "Box", Extension: "box", @@ -307,7 +308,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }) } steps = append(steps, - &common.StepOutputDir{ + &commonsteps.StepOutputDir{ Force: b.config.PackerForce, Path: b.config.OutputDir, }, @@ -347,7 +348,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: CommHost(), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - new(common.StepProvision), + new(commonsteps.StepProvision), &StepPackage{ SkipPackage: b.config.SkipPackage, Include: b.config.PackageInclude, @@ -356,7 +357,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }) // Run the steps. - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // Report any errors. diff --git a/builder/virtualbox/common/step_download_guest_additions.go b/builder/virtualbox/common/step_download_guest_additions.go index 3e3e2936e..fbe78b3ec 100644 --- a/builder/virtualbox/common/step_download_guest_additions.go +++ b/builder/virtualbox/common/step_download_guest_additions.go @@ -9,7 +9,7 @@ import ( "os" "strings" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -121,7 +121,7 @@ func (s *StepDownloadGuestAdditions) Run(ctx context.Context, state multistep.St log.Printf("Guest additions URL: %s", url) // We're good, so let's go ahead and download this thing.. - downStep := &common.StepDownload{ + downStep := &commonsteps.StepDownload{ Checksum: checksum, Description: "Guest additions", ResultKey: "guest_additions_path", @@ -151,7 +151,7 @@ func (s *StepDownloadGuestAdditions) downloadAdditionsSHA256(ctx context.Context defer os.Remove(checksumsFile.Name()) checksumsFile.Close() - downStep := &common.StepDownload{ + downStep := &commonsteps.StepDownload{ Description: "Guest additions checksums", ResultKey: "guest_additions_checksums_path", Url: []string{checksumsUrl}, diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index f2b18b94f..c1c940ff9 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -12,6 +12,7 @@ import ( vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -28,10 +29,10 @@ type Builder struct { type Config struct { common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - common.ISOConfig `mapstructure:",squash"` - common.FloppyConfig `mapstructure:",squash"` - common.CDConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.ISOConfig `mapstructure:",squash"` + commonsteps.FloppyConfig `mapstructure:",squash"` + commonsteps.CDConfig `mapstructure:",squash"` bootcommand.BootConfig `mapstructure:",squash"` vboxcommon.ExportConfig `mapstructure:",squash"` vboxcommon.OutputConfig `mapstructure:",squash"` @@ -243,7 +244,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack GuestAdditionsSHA256: b.config.GuestAdditionsSHA256, Ctx: b.config.ctx, }, - &common.StepDownload{ + &commonsteps.StepDownload{ Checksum: b.config.ISOChecksum, Description: "ISO", Extension: b.config.TargetExtension, @@ -251,21 +252,21 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack TargetPath: b.config.TargetPath, Url: b.config.ISOUrls, }, - &common.StepOutputDir{ + &commonsteps.StepOutputDir{ Force: b.config.PackerForce, Path: b.config.OutputDir, }, - &common.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, Label: b.config.FloppyConfig.FloppyLabel, }, - &common.StepCreateCD{ + &commonsteps.StepCreateCD{ Files: b.config.CDConfig.CDFiles, Label: b.config.CDConfig.CDLabel, }, new(vboxcommon.StepHTTPIPDiscover), - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -327,8 +328,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack GuestAdditionsPath: b.config.GuestAdditionsPath, Ctx: b.config.ctx, }, - new(common.StepProvision), - &common.StepCleanupTempKeys{ + new(commonsteps.StepProvision), + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.CommConfig.Comm, }, &vboxcommon.StepShutdown{ @@ -365,7 +366,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack state.Put("ui", ui) // Run - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/virtualbox/ovf/builder.go b/builder/virtualbox/ovf/builder.go index 14949c1fc..0165be197 100644 --- a/builder/virtualbox/ovf/builder.go +++ b/builder/virtualbox/ovf/builder.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -50,22 +50,22 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack // Build the steps. steps := []multistep.Step{ - &common.StepOutputDir{ + &commonsteps.StepOutputDir{ Force: b.config.PackerForce, Path: b.config.OutputDir, }, new(vboxcommon.StepSuppressMessages), - &common.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, Label: b.config.FloppyConfig.FloppyLabel, }, - &common.StepCreateCD{ + &commonsteps.StepCreateCD{ Files: b.config.CDConfig.CDFiles, Label: b.config.CDConfig.CDLabel, }, new(vboxcommon.StepHTTPIPDiscover), - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -82,7 +82,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack GuestAdditionsSHA256: b.config.GuestAdditionsSHA256, Ctx: b.config.ctx, }, - &common.StepDownload{ + &commonsteps.StepDownload{ Checksum: b.config.Checksum, Description: "OVF/OVA", Extension: "ova", @@ -143,8 +143,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack GuestAdditionsPath: b.config.GuestAdditionsPath, Ctx: b.config.ctx, }, - new(common.StepProvision), - &common.StepCleanupTempKeys{ + new(commonsteps.StepProvision), + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.CommConfig.Comm, }, &vboxcommon.StepShutdown{ @@ -170,7 +170,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run the steps. - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // Report any errors. diff --git a/builder/virtualbox/ovf/config.go b/builder/virtualbox/ovf/config.go index ab14c132c..ba99f5684 100644 --- a/builder/virtualbox/ovf/config.go +++ b/builder/virtualbox/ovf/config.go @@ -9,6 +9,7 @@ import ( vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -17,9 +18,9 @@ import ( // Config is the configuration structure for the builder. type Config struct { common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - common.FloppyConfig `mapstructure:",squash"` - common.CDConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.FloppyConfig `mapstructure:",squash"` + commonsteps.CDConfig `mapstructure:",squash"` bootcommand.BootConfig `mapstructure:",squash"` vboxcommon.ExportConfig `mapstructure:",squash"` vboxcommon.OutputConfig `mapstructure:",squash"` diff --git a/builder/virtualbox/vm/builder.go b/builder/virtualbox/vm/builder.go index 1e7e5f083..fb1e0fa76 100644 --- a/builder/virtualbox/vm/builder.go +++ b/builder/virtualbox/vm/builder.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -50,11 +50,11 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack // Build the steps. steps := []multistep.Step{ new(vboxcommon.StepSuppressMessages), - &common.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, }, - &common.StepCreateCD{ + &commonsteps.StepCreateCD{ Files: b.config.CDConfig.CDFiles, Label: b.config.CDConfig.CDLabel, }, @@ -64,7 +64,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack KeepRegistered: b.config.KeepRegistered, }, new(vboxcommon.StepHTTPIPDiscover), - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -127,8 +127,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack GuestAdditionsPath: b.config.GuestAdditionsPath, Ctx: b.config.ctx, }, - new(common.StepProvision), - &common.StepCleanupTempKeys{ + new(commonsteps.StepProvision), + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.CommConfig.Comm, }, &vboxcommon.StepShutdown{ @@ -160,13 +160,13 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack if !b.config.SkipExport { steps = append(steps, nil) copy(steps[1:], steps) - steps[0] = &common.StepOutputDir{ + steps[0] = &commonsteps.StepOutputDir{ Force: b.config.PackerForce, Path: b.config.OutputDir, } } // Run the steps. - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // Report any errors. diff --git a/builder/virtualbox/vm/config.go b/builder/virtualbox/vm/config.go index 690141c97..46235aeec 100644 --- a/builder/virtualbox/vm/config.go +++ b/builder/virtualbox/vm/config.go @@ -11,6 +11,7 @@ import ( vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -19,9 +20,9 @@ import ( // Config is the configuration structure for the builder. type Config struct { common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - common.FloppyConfig `mapstructure:",squash"` - common.CDConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.FloppyConfig `mapstructure:",squash"` + commonsteps.CDConfig `mapstructure:",squash"` bootcommand.BootConfig `mapstructure:",squash"` vboxcommon.ExportConfig `mapstructure:",squash"` vboxcommon.OutputConfig `mapstructure:",squash"` diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index db4afcd6b..18e068fdf 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -8,7 +8,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -57,7 +57,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack RemoteType: b.config.RemoteType, ToolsUploadFlavor: b.config.ToolsUploadFlavor, }, - &common.StepDownload{ + &commonsteps.StepDownload{ Checksum: b.config.ISOChecksum, Description: "ISO", Extension: b.config.TargetExtension, @@ -71,12 +71,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack RemoteType: b.config.RemoteType, VMName: b.config.VMName, }, - &common.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, Label: b.config.FloppyConfig.FloppyLabel, }, - &common.StepCreateCD{ + &commonsteps.StepCreateCD{ Files: b.config.CDConfig.CDFiles, Label: b.config.CDConfig.CDLabel, }, @@ -117,7 +117,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, &vmwcommon.StepSuppressMessages{}, &vmwcommon.StepHTTPIPDiscover{}, - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -161,8 +161,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack ToolsUploadPath: b.config.ToolsUploadPath, Ctx: b.config.ctx, }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.SSHConfig.Comm, }, &vmwcommon.StepShutdown{ @@ -196,7 +196,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run! - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // If there was an error, return that diff --git a/builder/vmware/iso/config.go b/builder/vmware/iso/config.go index e40f7320c..3bb7908be 100644 --- a/builder/vmware/iso/config.go +++ b/builder/vmware/iso/config.go @@ -12,6 +12,7 @@ import ( vmwcommon "github.com/hashicorp/packer/builder/vmware/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/shutdowncommand" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" @@ -20,10 +21,10 @@ import ( type Config struct { common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - common.ISOConfig `mapstructure:",squash"` - common.FloppyConfig `mapstructure:",squash"` - common.CDConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.ISOConfig `mapstructure:",squash"` + commonsteps.FloppyConfig `mapstructure:",squash"` + commonsteps.CDConfig `mapstructure:",squash"` bootcommand.VNCConfig `mapstructure:",squash"` vmwcommon.DriverConfig `mapstructure:",squash"` vmwcommon.HWConfig `mapstructure:",squash"` diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index 9b283b9d0..daf27282d 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -9,7 +9,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -68,12 +68,12 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack RemoteType: b.config.RemoteType, VMName: b.config.VMName, }, - &common.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyConfig.FloppyFiles, Directories: b.config.FloppyConfig.FloppyDirectories, Label: b.config.FloppyConfig.FloppyLabel, }, - &common.StepCreateCD{ + &commonsteps.StepCreateCD{ Files: b.config.CDConfig.CDFiles, Label: b.config.CDConfig.CDLabel, }, @@ -107,7 +107,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }, &vmwcommon.StepSuppressMessages{}, &vmwcommon.StepHTTPIPDiscover{}, - &common.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -154,8 +154,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack ToolsUploadPath: b.config.ToolsUploadPath, Ctx: b.config.ctx, }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.SSHConfig.Comm, }, &vmwcommon.StepShutdown{ @@ -189,7 +189,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run the steps. - b.runner = common.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) // Report any errors. diff --git a/builder/vmware/vmx/config.go b/builder/vmware/vmx/config.go index 060030a85..6892156a6 100644 --- a/builder/vmware/vmx/config.go +++ b/builder/vmware/vmx/config.go @@ -10,6 +10,7 @@ import ( vmwcommon "github.com/hashicorp/packer/builder/vmware/common" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/bootcommand" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/shutdowncommand" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" @@ -19,10 +20,10 @@ import ( // Config is the configuration structure for the builder. type Config struct { common.PackerConfig `mapstructure:",squash"` - common.HTTPConfig `mapstructure:",squash"` - common.FloppyConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.FloppyConfig `mapstructure:",squash"` bootcommand.VNCConfig `mapstructure:",squash"` - common.CDConfig `mapstructure:",squash"` + commonsteps.CDConfig `mapstructure:",squash"` vmwcommon.DriverConfig `mapstructure:",squash"` vmwcommon.OutputConfig `mapstructure:",squash"` vmwcommon.RunConfig `mapstructure:",squash"` diff --git a/builder/vsphere/clone/builder.go b/builder/vsphere/clone/builder.go index 92d574187..5c8bbdf7d 100644 --- a/builder/vsphere/clone/builder.go +++ b/builder/vsphere/clone/builder.go @@ -7,7 +7,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/driver" - packerCommon "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -41,7 +41,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepConnect{ Config: &b.config.ConnectConfig, }, - &packerCommon.StepCreateCD{ + &commonsteps.StepCreateCD{ Files: b.config.CDConfig.CDFiles, Label: b.config.CDConfig.CDLabel, }, @@ -74,7 +74,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack if b.config.Comm.Type != "none" { steps = append(steps, - &packerCommon.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyFiles, Directories: b.config.FloppyDirectories, Label: b.config.FloppyLabel, @@ -89,7 +89,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack HTTPIP: b.config.BootConfig.HTTPIP, Network: b.config.WaitIpConfig.GetIPNet(), }, - &packerCommon.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -117,7 +117,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: common.CommHost(b.config.Comm.Host()), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &packerCommon.StepProvision{}, + &commonsteps.StepProvision{}, &common.StepShutdown{ Config: &b.config.ShutdownConfig, }, @@ -157,7 +157,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }) } - b.runner = packerCommon.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/vsphere/clone/config.go b/builder/vsphere/clone/config.go index 1d0bd7388..dd612c9b7 100644 --- a/builder/vsphere/clone/config.go +++ b/builder/vsphere/clone/config.go @@ -6,6 +6,7 @@ package clone import ( "github.com/hashicorp/packer/builder/vsphere/common" packerCommon "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" @@ -14,8 +15,8 @@ import ( type Config struct { packerCommon.PackerConfig `mapstructure:",squash"` - packerCommon.HTTPConfig `mapstructure:",squash"` - packerCommon.CDConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.CDConfig `mapstructure:",squash"` common.ConnectConfig `mapstructure:",squash"` CloneConfig `mapstructure:",squash"` diff --git a/builder/vsphere/iso/builder.go b/builder/vsphere/iso/builder.go index 45fe1ca0b..ff2d58cb5 100644 --- a/builder/vsphere/iso/builder.go +++ b/builder/vsphere/iso/builder.go @@ -6,7 +6,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/driver" - packerCommon "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -41,7 +41,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Config: &b.config.ConnectConfig, }, &common.StepDownload{ - DownloadStep: &packerCommon.StepDownload{ + DownloadStep: &commonsteps.StepDownload{ Checksum: b.config.ISOChecksum, Description: "ISO", Extension: b.config.TargetExtension, @@ -54,7 +54,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Datastore: b.config.Datastore, Host: b.config.Host, }, - &packerCommon.StepCreateCD{ + &commonsteps.StepCreateCD{ Files: b.config.CDConfig.CDFiles, Label: b.config.CDConfig.CDLabel, }, @@ -77,7 +77,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack &common.StepConfigParams{ Config: &b.config.ConfigParamsConfig, }, - &packerCommon.StepCreateFloppy{ + &commonsteps.StepCreateFloppy{ Files: b.config.FloppyFiles, Directories: b.config.FloppyDirectories, Label: b.config.FloppyLabel, @@ -92,7 +92,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack HTTPIP: b.config.BootConfig.HTTPIP, Network: b.config.WaitIpConfig.GetIPNet(), }, - &packerCommon.StepHTTPServer{ + &commonsteps.StepHTTPServer{ HTTPDir: b.config.HTTPDir, HTTPPortMin: b.config.HTTPPortMin, HTTPPortMax: b.config.HTTPPortMax, @@ -119,7 +119,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: common.CommHost(b.config.Comm.Host()), SSHConfig: b.config.Comm.SSHConfigFunc(), }, - &packerCommon.StepProvision{}, + &commonsteps.StepProvision{}, ) } @@ -159,7 +159,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack }) } - b.runner = packerCommon.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) + b.runner = commonsteps.NewRunnerWithPauseFn(steps, b.config.PackerConfig, ui, state) b.runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { diff --git a/builder/vsphere/iso/config.go b/builder/vsphere/iso/config.go index 95cf4e3bd..09b9b1723 100644 --- a/builder/vsphere/iso/config.go +++ b/builder/vsphere/iso/config.go @@ -6,6 +6,7 @@ package iso import ( "github.com/hashicorp/packer/builder/vsphere/common" packerCommon "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" @@ -14,8 +15,8 @@ import ( type Config struct { packerCommon.PackerConfig `mapstructure:",squash"` - packerCommon.HTTPConfig `mapstructure:",squash"` - packerCommon.CDConfig `mapstructure:",squash"` + commonsteps.HTTPConfig `mapstructure:",squash"` + commonsteps.CDConfig `mapstructure:",squash"` common.ConnectConfig `mapstructure:",squash"` CreateConfig `mapstructure:",squash"` @@ -23,7 +24,7 @@ type Config struct { common.HardwareConfig `mapstructure:",squash"` common.ConfigParamsConfig `mapstructure:",squash"` - packerCommon.ISOConfig `mapstructure:",squash"` + commonsteps.ISOConfig `mapstructure:",squash"` common.CDRomConfig `mapstructure:",squash"` common.RemoveCDRomConfig `mapstructure:",squash"` diff --git a/builder/yandex/builder.go b/builder/yandex/builder.go index dec8446a8..450386233 100644 --- a/builder/yandex/builder.go +++ b/builder/yandex/builder.go @@ -6,7 +6,7 @@ import ( "github.com/google/uuid" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/multistep" @@ -83,8 +83,8 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack Host: commHost, SSHConfig: b.config.Communicator.SSHConfigFunc(), }, - &common.StepProvision{}, - &common.StepCleanupTempKeys{ + &commonsteps.StepProvision{}, + &commonsteps.StepCleanupTempKeys{ Comm: &b.config.Communicator, }, &StepTeardownInstance{}, @@ -94,7 +94,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack } // Run the steps - b.runner = common.NewRunner(steps, b.config.PackerConfig, ui) + b.runner = commonsteps.NewRunner(steps, b.config.PackerConfig, ui) b.runner.Run(ctx, state) // Report any errors diff --git a/common/bootcommand/config.go b/common/bootcommand/config.go index ad5e8b700..79c14d3d5 100644 --- a/common/bootcommand/config.go +++ b/common/bootcommand/config.go @@ -10,6 +10,15 @@ import ( "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" ) +// PackerKeyEnv is used to specify the key interval (delay) between keystrokes +// sent to the VM, typically in boot commands. This is to prevent host CPU +// utilization from causing key presses to be skipped or repeated incorrectly. +const PackerKeyEnv = "PACKER_KEY_INTERVAL" + +// PackerKeyDefault 100ms is appropriate for shared build infrastructure while a +// shorter delay (e.g. 10ms) can be used on a workstation. See PackerKeyEnv. +const PackerKeyDefault = 100 * time.Millisecond + // The boot configuration is very important: `boot_command` specifies the keys // to type when the virtual machine is first booted in order to start the OS // installer. This command is typed after boot_wait, which gives the virtual diff --git a/common/bootcommand/pc_xt_driver.go b/common/bootcommand/pc_xt_driver.go index 2a3dcb746..93ab9f21f 100644 --- a/common/bootcommand/pc_xt_driver.go +++ b/common/bootcommand/pc_xt_driver.go @@ -8,8 +8,6 @@ import ( "time" "unicode" "unicode/utf8" - - "github.com/hashicorp/packer/common" ) // SendCodeFunc will be called to send codes to the VM @@ -41,8 +39,8 @@ func (sc *scancode) makeBreak() []string { func NewPCXTDriver(send SendCodeFunc, chunkSize int, interval time.Duration) *pcXTDriver { // We delay (default 100ms) between each input event to allow for CPU or // network latency. See PackerKeyEnv for tuning. - keyInterval := common.PackerKeyDefault - if delay, err := time.ParseDuration(os.Getenv(common.PackerKeyEnv)); err == nil { + keyInterval := PackerKeyDefault + if delay, err := time.ParseDuration(os.Getenv(PackerKeyEnv)); err == nil { keyInterval = delay } // Override interval based on builder-specific override diff --git a/common/bootcommand/usb_driver.go b/common/bootcommand/usb_driver.go index 519c28525..c79c5a312 100644 --- a/common/bootcommand/usb_driver.go +++ b/common/bootcommand/usb_driver.go @@ -8,7 +8,6 @@ import ( "time" "unicode" - "github.com/hashicorp/packer/common" "golang.org/x/mobile/event/key" ) @@ -25,8 +24,8 @@ type usbDriver struct { func NewUSBDriver(send SendUsbScanCodes, interval time.Duration) *usbDriver { // We delay (default 100ms) between each key event to allow for CPU or // network latency. See PackerKeyEnv for tuning. - keyInterval := common.PackerKeyDefault - if delay, err := time.ParseDuration(os.Getenv(common.PackerKeyEnv)); err == nil { + keyInterval := PackerKeyDefault + if delay, err := time.ParseDuration(os.Getenv(PackerKeyEnv)); err == nil { keyInterval = delay } // override interval based on builder-specific override. diff --git a/common/bootcommand/vnc_driver.go b/common/bootcommand/vnc_driver.go index 027bcffca..f1b98ae8d 100644 --- a/common/bootcommand/vnc_driver.go +++ b/common/bootcommand/vnc_driver.go @@ -7,8 +7,6 @@ import ( "strings" "time" "unicode" - - "github.com/hashicorp/packer/common" ) const KeyLeftShift uint32 = 0xFFE1 @@ -28,8 +26,8 @@ type vncDriver struct { func NewVNCDriver(c VNCKeyEvent, interval time.Duration) *vncDriver { // We delay (default 100ms) between each key event to allow for CPU or // network latency. See PackerKeyEnv for tuning. - keyInterval := common.PackerKeyDefault - if delay, err := time.ParseDuration(os.Getenv(common.PackerKeyEnv)); err == nil { + keyInterval := PackerKeyDefault + if delay, err := time.ParseDuration(os.Getenv(PackerKeyEnv)); err == nil { keyInterval = delay } // override interval based on builder-specific override. diff --git a/common/chroot/step_chroot_provision.go b/common/chroot/step_chroot_provision.go index 5ab7182eb..e18dae77d 100644 --- a/common/chroot/step_chroot_provision.go +++ b/common/chroot/step_chroot_provision.go @@ -5,6 +5,7 @@ import ( "log" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) @@ -26,7 +27,7 @@ func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) } // Loads hook data from builder's state, if it has been set. - hookData := common.PopulateProvisionHookData(state) + hookData := commonsteps.PopulateProvisionHookData(state) // Update state generated_data with complete hookData // to make them accessible by post-processors diff --git a/common/extra_iso_config.go b/common/commonsteps/extra_iso_config.go similarity index 99% rename from common/extra_iso_config.go rename to common/commonsteps/extra_iso_config.go index 5f4707c27..749a59bf7 100644 --- a/common/extra_iso_config.go +++ b/common/commonsteps/extra_iso_config.go @@ -1,6 +1,6 @@ //go:generate struct-markdown -package common +package commonsteps import ( "fmt" diff --git a/common/extra_iso_config_test.go b/common/commonsteps/extra_iso_config_test.go similarity index 99% rename from common/extra_iso_config_test.go rename to common/commonsteps/extra_iso_config_test.go index bcc555976..70b87057f 100644 --- a/common/extra_iso_config_test.go +++ b/common/commonsteps/extra_iso_config_test.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "testing" diff --git a/common/floppy_config.go b/common/commonsteps/floppy_config.go similarity index 99% rename from common/floppy_config.go rename to common/commonsteps/floppy_config.go index 175d36f73..71685e23c 100644 --- a/common/floppy_config.go +++ b/common/commonsteps/floppy_config.go @@ -1,6 +1,6 @@ //go:generate struct-markdown -package common +package commonsteps import ( "fmt" diff --git a/common/floppy_config_test.go b/common/commonsteps/floppy_config_test.go similarity index 98% rename from common/floppy_config_test.go rename to common/commonsteps/floppy_config_test.go index ee9c742ff..235652e24 100644 --- a/common/floppy_config_test.go +++ b/common/commonsteps/floppy_config_test.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "testing" diff --git a/common/http_config.go b/common/commonsteps/http_config.go similarity index 99% rename from common/http_config.go rename to common/commonsteps/http_config.go index 0cb176eb4..6939c43ec 100644 --- a/common/http_config.go +++ b/common/commonsteps/http_config.go @@ -1,6 +1,6 @@ //go:generate struct-markdown -package common +package commonsteps import ( "errors" diff --git a/common/http_config_test.go b/common/commonsteps/http_config_test.go similarity index 97% rename from common/http_config_test.go rename to common/commonsteps/http_config_test.go index 02b800845..add5c9304 100644 --- a/common/http_config_test.go +++ b/common/commonsteps/http_config_test.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "testing" diff --git a/common/iso_config.go b/common/commonsteps/iso_config.go similarity index 99% rename from common/iso_config.go rename to common/commonsteps/iso_config.go index 14addecd1..5034939a0 100644 --- a/common/iso_config.go +++ b/common/commonsteps/iso_config.go @@ -1,6 +1,6 @@ //go:generate struct-markdown -package common +package commonsteps import ( "context" diff --git a/common/iso_config_test.go b/common/commonsteps/iso_config_test.go similarity index 99% rename from common/iso_config_test.go rename to common/commonsteps/iso_config_test.go index 502195d52..cdf97aa6f 100644 --- a/common/iso_config_test.go +++ b/common/commonsteps/iso_config_test.go @@ -1,6 +1,6 @@ // +build !windows -package common +package commonsteps import ( "io" diff --git a/common/multistep_debug.go b/common/commonsteps/multistep_debug.go similarity index 98% rename from common/multistep_debug.go rename to common/commonsteps/multistep_debug.go index 2d1a58291..9ef48f4d4 100644 --- a/common/multistep_debug.go +++ b/common/commonsteps/multistep_debug.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "fmt" diff --git a/common/multistep_runner.go b/common/commonsteps/multistep_runner.go similarity index 91% rename from common/multistep_runner.go rename to common/commonsteps/multistep_runner.go index 7dd614562..5c7508203 100644 --- a/common/multistep_runner.go +++ b/common/commonsteps/multistep_runner.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "context" @@ -8,11 +8,12 @@ import ( "strings" "time" + "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" ) -func newRunner(steps []multistep.Step, config PackerConfig, ui packer.Ui) (multistep.Runner, multistep.DebugPauseFn) { +func newRunner(steps []multistep.Step, config common.PackerConfig, ui packer.Ui) (multistep.Runner, multistep.DebugPauseFn) { switch config.PackerOnError { case "", "cleanup": case "abort": @@ -47,7 +48,7 @@ func newRunner(steps []multistep.Step, config PackerConfig, ui packer.Ui) (multi // NewRunner returns a multistep.Runner that runs steps augmented with support // for -debug and -on-error command line arguments. -func NewRunner(steps []multistep.Step, config PackerConfig, ui packer.Ui) multistep.Runner { +func NewRunner(steps []multistep.Step, config common.PackerConfig, ui packer.Ui) multistep.Runner { runner, _ := newRunner(steps, config, ui) return runner } @@ -56,7 +57,7 @@ func NewRunner(steps []multistep.Step, config PackerConfig, ui packer.Ui) multis // with support for -debug and -on-error command line arguments. With -debug it // puts the multistep.DebugPauseFn that will pause execution between steps into // the state under the key "pauseFn". -func NewRunnerWithPauseFn(steps []multistep.Step, config PackerConfig, ui packer.Ui, state multistep.StateBag) multistep.Runner { +func NewRunnerWithPauseFn(steps []multistep.Step, config common.PackerConfig, ui packer.Ui, state multistep.StateBag) multistep.Runner { runner, pauseFn := newRunner(steps, config, ui) if pauseFn != nil { state.Put("pauseFn", pauseFn) diff --git a/common/step_cleanup_temp_keys.go b/common/commonsteps/step_cleanup_temp_keys.go similarity index 99% rename from common/step_cleanup_temp_keys.go rename to common/commonsteps/step_cleanup_temp_keys.go index a6235a91d..aa1c7c4f8 100644 --- a/common/step_cleanup_temp_keys.go +++ b/common/commonsteps/step_cleanup_temp_keys.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "context" diff --git a/common/step_create_cdrom.go b/common/commonsteps/step_create_cdrom.go similarity index 99% rename from common/step_create_cdrom.go rename to common/commonsteps/step_create_cdrom.go index 0f1c5664d..5cecbcbb7 100644 --- a/common/step_create_cdrom.go +++ b/common/commonsteps/step_create_cdrom.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "context" diff --git a/common/step_create_cdrom_test.go b/common/commonsteps/step_create_cdrom_test.go similarity index 99% rename from common/step_create_cdrom_test.go rename to common/commonsteps/step_create_cdrom_test.go index bdcc83535..cfdf05404 100644 --- a/common/step_create_cdrom_test.go +++ b/common/commonsteps/step_create_cdrom_test.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "bytes" diff --git a/common/step_create_floppy.go b/common/commonsteps/step_create_floppy.go similarity index 99% rename from common/step_create_floppy.go rename to common/commonsteps/step_create_floppy.go index 128a0e78b..418df6fbf 100644 --- a/common/step_create_floppy.go +++ b/common/commonsteps/step_create_floppy.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "context" diff --git a/common/step_create_floppy_test.go b/common/commonsteps/step_create_floppy_test.go similarity index 99% rename from common/step_create_floppy_test.go rename to common/commonsteps/step_create_floppy_test.go index e2680acdb..78bc135d7 100644 --- a/common/step_create_floppy_test.go +++ b/common/commonsteps/step_create_floppy_test.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "bytes" diff --git a/common/step_download.go b/common/commonsteps/step_download.go similarity index 99% rename from common/step_download.go rename to common/commonsteps/step_download.go index f2f0ca177..b23585b37 100644 --- a/common/step_download.go +++ b/common/commonsteps/step_download.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "context" diff --git a/common/step_download_test.go b/common/commonsteps/step_download_test.go similarity index 99% rename from common/step_download_test.go rename to common/commonsteps/step_download_test.go index 26cd026e9..b6c7870c2 100644 --- a/common/step_download_test.go +++ b/common/commonsteps/step_download_test.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "bytes" diff --git a/common/step_http_server.go b/common/commonsteps/step_http_server.go similarity index 98% rename from common/step_http_server.go rename to common/commonsteps/step_http_server.go index c63e51dcd..df0673774 100644 --- a/common/step_http_server.go +++ b/common/commonsteps/step_http_server.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "context" diff --git a/common/step_output_dir.go b/common/commonsteps/step_output_dir.go similarity index 98% rename from common/step_output_dir.go rename to common/commonsteps/step_output_dir.go index 4f68b80c2..2dbdda596 100644 --- a/common/step_output_dir.go +++ b/common/commonsteps/step_output_dir.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "context" diff --git a/common/step_output_dir_test.go b/common/commonsteps/step_output_dir_test.go similarity index 99% rename from common/step_output_dir_test.go rename to common/commonsteps/step_output_dir_test.go index 7a5f58d95..cf658e8a1 100644 --- a/common/step_output_dir_test.go +++ b/common/commonsteps/step_output_dir_test.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "bytes" diff --git a/common/step_provision.go b/common/commonsteps/step_provision.go similarity index 99% rename from common/step_provision.go rename to common/commonsteps/step_provision.go index 2326649b9..1ec20e365 100644 --- a/common/step_provision.go +++ b/common/commonsteps/step_provision.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "context" diff --git a/common/step_provision_test.go b/common/commonsteps/step_provision_test.go similarity index 99% rename from common/step_provision_test.go rename to common/commonsteps/step_provision_test.go index 33a971e13..ddca131fe 100644 --- a/common/step_provision_test.go +++ b/common/commonsteps/step_provision_test.go @@ -1,4 +1,4 @@ -package common +package commonsteps import ( "fmt" diff --git a/common/test-fixtures/SomeDir/myfile.txt b/common/commonsteps/test-fixtures/SomeDir/myfile.txt similarity index 100% rename from common/test-fixtures/SomeDir/myfile.txt rename to common/commonsteps/test-fixtures/SomeDir/myfile.txt diff --git a/common/test-fixtures/floppy-hier/test-0/file1 b/common/commonsteps/test-fixtures/floppy-hier/test-0/file1 similarity index 100% rename from common/test-fixtures/floppy-hier/test-0/file1 rename to common/commonsteps/test-fixtures/floppy-hier/test-0/file1 diff --git a/common/test-fixtures/floppy-hier/test-0/file2 b/common/commonsteps/test-fixtures/floppy-hier/test-0/file2 similarity index 100% rename from common/test-fixtures/floppy-hier/test-0/file2 rename to common/commonsteps/test-fixtures/floppy-hier/test-0/file2 diff --git a/common/test-fixtures/floppy-hier/test-0/file3 b/common/commonsteps/test-fixtures/floppy-hier/test-0/file3 similarity index 100% rename from common/test-fixtures/floppy-hier/test-0/file3 rename to common/commonsteps/test-fixtures/floppy-hier/test-0/file3 diff --git a/common/test-fixtures/floppy-hier/test-1/dir1/file1 b/common/commonsteps/test-fixtures/floppy-hier/test-1/dir1/file1 similarity index 100% rename from common/test-fixtures/floppy-hier/test-1/dir1/file1 rename to common/commonsteps/test-fixtures/floppy-hier/test-1/dir1/file1 diff --git a/common/test-fixtures/floppy-hier/test-1/dir1/file2 b/common/commonsteps/test-fixtures/floppy-hier/test-1/dir1/file2 similarity index 100% rename from common/test-fixtures/floppy-hier/test-1/dir1/file2 rename to common/commonsteps/test-fixtures/floppy-hier/test-1/dir1/file2 diff --git a/common/test-fixtures/floppy-hier/test-1/dir1/file3 b/common/commonsteps/test-fixtures/floppy-hier/test-1/dir1/file3 similarity index 100% rename from common/test-fixtures/floppy-hier/test-1/dir1/file3 rename to common/commonsteps/test-fixtures/floppy-hier/test-1/dir1/file3 diff --git a/common/test-fixtures/floppy-hier/test-2/dir1/file1 b/common/commonsteps/test-fixtures/floppy-hier/test-2/dir1/file1 similarity index 100% rename from common/test-fixtures/floppy-hier/test-2/dir1/file1 rename to common/commonsteps/test-fixtures/floppy-hier/test-2/dir1/file1 diff --git a/common/test-fixtures/floppy-hier/test-2/dir1/subdir1/file1 b/common/commonsteps/test-fixtures/floppy-hier/test-2/dir1/subdir1/file1 similarity index 100% rename from common/test-fixtures/floppy-hier/test-2/dir1/subdir1/file1 rename to common/commonsteps/test-fixtures/floppy-hier/test-2/dir1/subdir1/file1 diff --git a/common/test-fixtures/floppy-hier/test-2/dir1/subdir1/file2 b/common/commonsteps/test-fixtures/floppy-hier/test-2/dir1/subdir1/file2 similarity index 100% rename from common/test-fixtures/floppy-hier/test-2/dir1/subdir1/file2 rename to common/commonsteps/test-fixtures/floppy-hier/test-2/dir1/subdir1/file2 diff --git a/common/test-fixtures/floppy-hier/test-2/dir2/subdir1/file1 b/common/commonsteps/test-fixtures/floppy-hier/test-2/dir2/subdir1/file1 similarity index 100% rename from common/test-fixtures/floppy-hier/test-2/dir2/subdir1/file1 rename to common/commonsteps/test-fixtures/floppy-hier/test-2/dir2/subdir1/file1 diff --git a/common/test-fixtures/floppy-hier/test-2/dir2/subdir1/file2 b/common/commonsteps/test-fixtures/floppy-hier/test-2/dir2/subdir1/file2 similarity index 100% rename from common/test-fixtures/floppy-hier/test-2/dir2/subdir1/file2 rename to common/commonsteps/test-fixtures/floppy-hier/test-2/dir2/subdir1/file2 diff --git a/common/test-fixtures/root/another.txt b/common/commonsteps/test-fixtures/root/another.txt similarity index 100% rename from common/test-fixtures/root/another.txt rename to common/commonsteps/test-fixtures/root/another.txt diff --git a/common/test-fixtures/root/another.txt.sha1sum b/common/commonsteps/test-fixtures/root/another.txt.sha1sum similarity index 100% rename from common/test-fixtures/root/another.txt.sha1sum rename to common/commonsteps/test-fixtures/root/another.txt.sha1sum diff --git a/common/test-fixtures/root/basic.txt b/common/commonsteps/test-fixtures/root/basic.txt similarity index 100% rename from common/test-fixtures/root/basic.txt rename to common/commonsteps/test-fixtures/root/basic.txt diff --git a/common/test-fixtures/root/basic.txt.sha1sum b/common/commonsteps/test-fixtures/root/basic.txt.sha1sum similarity index 100% rename from common/test-fixtures/root/basic.txt.sha1sum rename to common/commonsteps/test-fixtures/root/basic.txt.sha1sum diff --git a/common/test-fixtures/root/subfolder.sum b/common/commonsteps/test-fixtures/root/subfolder.sum similarity index 100% rename from common/test-fixtures/root/subfolder.sum rename to common/commonsteps/test-fixtures/root/subfolder.sum diff --git a/common/config.go b/common/config.go deleted file mode 100644 index 8094e05e5..000000000 --- a/common/config.go +++ /dev/null @@ -1,14 +0,0 @@ -package common - -import ( - "time" -) - -// PackerKeyEnv is used to specify the key interval (delay) between keystrokes -// sent to the VM, typically in boot commands. This is to prevent host CPU -// utilization from causing key presses to be skipped or repeated incorrectly. -const PackerKeyEnv = "PACKER_KEY_INTERVAL" - -// PackerKeyDefault 100ms is appropriate for shared build infrastructure while a -// shorter delay (e.g. 10ms) can be used on a workstation. See PackerKeyEnv. -const PackerKeyDefault = 100 * time.Millisecond diff --git a/common/shell-local/run.go b/common/shell-local/run.go index 85ade3696..cb3a47f83 100644 --- a/common/shell-local/run.go +++ b/common/shell-local/run.go @@ -11,7 +11,7 @@ import ( "sort" "strings" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/packer/tmp" @@ -181,15 +181,15 @@ func createFlattenedEnvVars(config *Config) (string, error) { // expose ip address variables httpAddr := config.generatedData["PackerHTTPAddr"] - if httpAddr != nil && httpAddr != common.HttpAddrNotImplemented { + if httpAddr != nil && httpAddr != commonsteps.HttpAddrNotImplemented { envVars["PACKER_HTTP_ADDR"] = httpAddr.(string) } httpIP := config.generatedData["PackerHTTPIP"] - if httpIP != nil && httpIP != common.HttpIPNotImplemented { + if httpIP != nil && httpIP != commonsteps.HttpIPNotImplemented { envVars["PACKER_HTTP_IP"] = httpIP.(string) } httpPort := config.generatedData["PackerHTTPPort"] - if httpPort != nil && httpPort != common.HttpPortNotImplemented { + if httpPort != nil && httpPort != commonsteps.HttpPortNotImplemented { envVars["PACKER_HTTP_PORT"] = httpPort.(string) } diff --git a/common/test-fixtures/fileurl/cake b/common/test-fixtures/fileurl/cake deleted file mode 100644 index e800d1ffb..000000000 --- a/common/test-fixtures/fileurl/cake +++ /dev/null @@ -1 +0,0 @@ -delicious chocolate cake diff --git a/go.mod b/go.mod index a89a5bc24..352ad70ee 100644 --- a/go.mod +++ b/go.mod @@ -94,6 +94,7 @@ require ( github.com/mitchellh/go-homedir v1.1.0 github.com/mitchellh/go-testing-interface v1.0.3 // indirect github.com/mitchellh/go-vnc v0.0.0-20150629162542-723ed9867aed + github.com/mitchellh/gox v1.0.1 // indirect github.com/mitchellh/iochan v1.0.0 github.com/mitchellh/mapstructure v1.2.3 github.com/mitchellh/panicwrap v1.0.0 @@ -133,11 +134,11 @@ require ( github.com/zclconf/go-cty-yaml v1.0.1 golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9 golang.org/x/mobile v0.0.0-20191130191448-5c0e7e404af8 - golang.org/x/net v0.0.0-20200904194848-62affa334b73 + golang.org/x/net v0.0.0-20201021035429-f5854403a974 golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43 - golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 - golang.org/x/sys v0.0.0-20200918174421-af09f7315aff - golang.org/x/tools v0.0.0-20200918232735-d647fc253266 + golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 + golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f + golang.org/x/tools v0.0.0-20201111133315-69daaf961d65 google.golang.org/api v0.32.0 google.golang.org/genproto v0.0.0-20200918140846-d0d605568037 // indirect google.golang.org/grpc v1.32.0 diff --git a/go.sum b/go.sum index 8a908afec..bbf61b351 100644 --- a/go.sum +++ b/go.sum @@ -376,6 +376,7 @@ github.com/hashicorp/go-uuid v1.0.1 h1:fv1ep09latC32wFoVwnqcnKJGnMSdBanPczbHAYm1 github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.2 h1:cfejS+Tpcp13yd5nYHWDI6qVCny6wyX2Mt5SGur2IGE= github.com/hashicorp/go-uuid v1.0.2/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.2.0 h1:3vNe/fWF5CBgRIguda1meWhsZHy3m8gCJ5wx+dIzX/E= @@ -510,6 +511,8 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZX github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/gox v1.0.1 h1:x0jD3dcHk9a9xPSDN6YEL4xL6Qz0dvNYm8yZqui5chI= +github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= github.com/mitchellh/iochan v1.0.0 h1:C+X3KsSTLFVBr/tK1eYN/vs4rJcvsiLU338UhYPJWeY= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= @@ -753,6 +756,8 @@ golang.org/x/net v0.0.0-20200822124328-c89045814202 h1:VvcQYSHwXgi7W+TpUR6A9g6Up golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20200904194848-62affa334b73 h1:MXfv8rhZWmFeqX3GNZRsd6vOLoaCHjYEX3qkRo3YBUA= golang.org/x/net v0.0.0-20200904194848-62affa334b73/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= +golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI= +golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -771,6 +776,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a h1:WXEvlFVvvGxCJLG6REjsT03i golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 h1:qwRHBd0NqMbJxfbotnDhm2ByMI1Shq4Y6oRJo21SGJA= golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 h1:SQFwaSi55rU7vdNs9Yr0Z324VNlrF+0wMqRXT4St8ck= +golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -815,6 +822,8 @@ golang.org/x/sys v0.0.0-20200828194041-157a740278f4/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200918174421-af09f7315aff h1:1CPUrky56AcgSpxz/KfgzQWzfG09u5YOL8MvPYBlrL8= golang.org/x/sys v0.0.0-20200918174421-af09f7315aff/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f h1:+Nyd8tzPX9R7BWHguqsrbFdRx3WQ/1ib8I44HXV5yTA= +golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -875,6 +884,8 @@ golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82u golang.org/x/tools v0.0.0-20200915173823-2db8f0ff891c/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= golang.org/x/tools v0.0.0-20200918232735-d647fc253266 h1:k7tVuG0g1JwmD3Jh8oAl1vQ1C3jb4Hi/dUl1wWDBJpQ= golang.org/x/tools v0.0.0-20200918232735-d647fc253266/go.mod h1:z6u4i615ZeAfBE4XtMziQW1fSVJXACjjbWkB/mvPzlU= +golang.org/x/tools v0.0.0-20201111133315-69daaf961d65 h1:cuDLV0fZoIC/Oj72hGUKPhXR2AvbvJoQKPmSeE5nH4Q= +golang.org/x/tools v0.0.0-20201111133315-69daaf961d65/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/post-processor/docker-push/post-processor.go b/post-processor/docker-push/post-processor.go index ba264d418..4c90fb25f 100644 --- a/post-processor/docker-push/post-processor.go +++ b/post-processor/docker-push/post-processor.go @@ -5,6 +5,7 @@ package dockerpush import ( "context" "fmt" + "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/docker" "github.com/hashicorp/packer/common" diff --git a/post-processor/googlecompute-export/post-processor.go b/post-processor/googlecompute-export/post-processor.go index d24018617..c0ef8aa05 100644 --- a/post-processor/googlecompute-export/post-processor.go +++ b/post-processor/googlecompute-export/post-processor.go @@ -12,6 +12,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/googlecompute" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/communicator" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -224,7 +225,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact } // Run the steps. - p.runner = common.NewRunner(steps, p.config.PackerConfig, ui) + p.runner = commonsteps.NewRunner(steps, p.config.PackerConfig, ui) p.runner.Run(ctx, state) result := &Artifact{paths: p.config.Paths} diff --git a/post-processor/vagrant-cloud/post-processor.go b/post-processor/vagrant-cloud/post-processor.go index 487fde5b1..5e4f9798e 100644 --- a/post-processor/vagrant-cloud/post-processor.go +++ b/post-processor/vagrant-cloud/post-processor.go @@ -20,6 +20,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" @@ -195,7 +196,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact steps = append(steps, new(stepReleaseVersion)) // Run the steps - p.runner = common.NewRunner(steps, p.config.PackerConfig, ui) + p.runner = commonsteps.NewRunner(steps, p.config.PackerConfig, ui) p.runner.Run(ctx, state) // If there was an error, return that diff --git a/post-processor/vsphere-template/post-processor.go b/post-processor/vsphere-template/post-processor.go index 3d3675cd8..4986500eb 100644 --- a/post-processor/vsphere-template/post-processor.go +++ b/post-processor/vsphere-template/post-processor.go @@ -10,17 +10,17 @@ import ( "strings" "time" + "github.com/hashicorp/hcl/v2/hcldec" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" vsphere "github.com/hashicorp/packer/builder/vsphere/common" - vspherepost "github.com/hashicorp/packer/post-processor/vsphere" - - "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" "github.com/hashicorp/packer/post-processor/artifice" + vspherepost "github.com/hashicorp/packer/post-processor/vsphere" "github.com/vmware/govmomi" ) @@ -144,7 +144,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact NewStepCreateSnapshot(artifact, p), NewStepMarkAsTemplate(artifact, p), } - runner := common.NewRunnerWithPauseFn(steps, p.config.PackerConfig, ui, state) + runner := commonsteps.NewRunnerWithPauseFn(steps, p.config.PackerConfig, ui, state) runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { return nil, false, false, rawErr.(error) diff --git a/post-processor/yandex-export/post-processor.go b/post-processor/yandex-export/post-processor.go index 40f8639fa..38741484c 100644 --- a/post-processor/yandex-export/post-processor.go +++ b/post-processor/yandex-export/post-processor.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/builder/yandex" "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/packerbuilderdata" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/helper/multistep" @@ -217,7 +218,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packer.Ui, artifact } // Run the steps. - p.runner = common.NewRunner(steps, p.config.PackerConfig, ui) + p.runner = commonsteps.NewRunner(steps, p.config.PackerConfig, ui) p.runner.Run(ctx, state) if rawErr, ok := state.GetOk("error"); ok { return nil, false, false, rawErr.(error) diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index 27dee7bbb..0f09d7c19 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -32,6 +32,7 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/common" "github.com/hashicorp/packer/common/adapter" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -739,7 +740,7 @@ func (p *Provisioner) createCmdArgs(httpAddr, inventory, playbook, privKeyFile s args = append(args, "-e", fmt.Sprintf("packer_builder_type=%s", p.config.PackerBuilderType)) // expose packer_http_addr extra variable - if httpAddr != common.HttpAddrNotImplemented { + if httpAddr != commonsteps.HttpAddrNotImplemented { args = append(args, "-e", fmt.Sprintf("packer_http_addr=%s", httpAddr)) } diff --git a/provisioner/ansible/provisioner_test.go b/provisioner/ansible/provisioner_test.go index a98fae8a4..18da6d92a 100644 --- a/provisioner/ansible/provisioner_test.go +++ b/provisioner/ansible/provisioner_test.go @@ -14,7 +14,7 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" confighelper "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" "github.com/stretchr/testify/assert" @@ -475,9 +475,9 @@ func basicGenData(input map[string]interface{}) map[string]interface{} { "SSHPrivateKey": "asdf", "SSHAgentAuth": false, "User": "PartyPacker", - "PackerHTTPAddr": common.HttpAddrNotImplemented, - "PackerHTTPIP": common.HttpIPNotImplemented, - "PackerHTTPPort": common.HttpPortNotImplemented, + "PackerHTTPAddr": commonsteps.HttpAddrNotImplemented, + "PackerHTTPIP": commonsteps.HttpIPNotImplemented, + "PackerHTTPPort": commonsteps.HttpPortNotImplemented, } if input == nil { return gd @@ -510,7 +510,7 @@ func TestCreateCmdArgs(t *testing.T) { generatedData: basicGenData(nil), ExtraArguments: []string{"-e", "hello-world"}, AnsibleEnvVars: []string{"ENV_1=pancakes", "ENV_2=bananas"}, - callArgs: []string{common.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", "/path/to/privkey.pem"}, + callArgs: []string{commonsteps.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", "/path/to/privkey.pem"}, ExpectedArgs: []string{"-e", "packer_build_name=\"packerparty\"", "-e", "packer_builder_type=fakebuilder", "-e", "ansible_ssh_private_key_file=/path/to/privkey.pem", "--ssh-extra-args", "'-o IdentitiesOnly=yes'", "-e", "hello-world", "-i", "/var/inventory", "test-playbook.yml"}, ExpectedEnvVars: []string{"ENV_1=pancakes", "ENV_2=bananas"}, }, @@ -522,7 +522,7 @@ func TestCreateCmdArgs(t *testing.T) { ExtraArguments: []string{"-e", "hello-world"}, AnsibleSSHExtraArgs: []string{"-o IdentitiesOnly=no"}, AnsibleEnvVars: []string{"ENV_1=pancakes", "ENV_2=bananas"}, - callArgs: []string{common.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", "/path/to/privkey.pem"}, + callArgs: []string{commonsteps.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", "/path/to/privkey.pem"}, ExpectedArgs: []string{"-e", "packer_build_name=\"packerparty\"", "-e", "packer_builder_type=fakebuilder", "--ssh-extra-args", "'-o IdentitiesOnly=no'", "-e", "ansible_ssh_private_key_file=/path/to/privkey.pem", "-e", "hello-world", "-i", "/var/inventory", "test-playbook.yml"}, ExpectedEnvVars: []string{"ENV_1=pancakes", "ENV_2=bananas"}, }, @@ -532,7 +532,7 @@ func TestCreateCmdArgs(t *testing.T) { UseProxy: confighelper.TriTrue, generatedData: basicGenData(nil), ExtraArguments: []string{"-e", "hello-world"}, - callArgs: []string{common.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", "/path/to/privkey.pem"}, + callArgs: []string{commonsteps.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", "/path/to/privkey.pem"}, ExpectedArgs: []string{"-e", "packer_build_name=\"packerparty\"", "-e", "packer_builder_type=fakebuilder", "-e", "ansible_ssh_private_key_file=/path/to/privkey.pem", "--ssh-extra-args", "'-o IdentitiesOnly=yes'", "-e", "hello-world", "-i", "/var/inventory", "test-playbook.yml"}, ExpectedEnvVars: []string{}, }, @@ -545,7 +545,7 @@ func TestCreateCmdArgs(t *testing.T) { }), ExtraArguments: []string{"-e", "hello-world"}, AnsibleEnvVars: []string{"ENV_1=pancakes", "ENV_2=bananas"}, - callArgs: []string{common.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", ""}, + callArgs: []string{commonsteps.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", ""}, ExpectedArgs: []string{"-e", "packer_build_name=\"packerparty\"", "-e", "packer_builder_type=fakebuilder", "-e", "hello-world", "-i", "/var/inventory", "test-playbook.yml"}, ExpectedEnvVars: []string{"ENV_1=pancakes", "ENV_2=bananas"}, }, @@ -584,7 +584,7 @@ func TestCreateCmdArgs(t *testing.T) { }), ExtraArguments: []string{"-e", "hello-world"}, AnsibleEnvVars: []string{"ENV_1=pancakes", "ENV_2=bananas"}, - callArgs: []string{common.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", ""}, + callArgs: []string{commonsteps.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", ""}, ExpectedArgs: []string{"-e", "packer_build_name=\"packerparty\"", "-e", "packer_builder_type=fakebuilder", "-e", "hello-world", "-i", "/var/inventory", "test-playbook.yml"}, ExpectedEnvVars: []string{"ENV_1=pancakes", "ENV_2=bananas"}, }, @@ -637,7 +637,7 @@ func TestCreateCmdArgs(t *testing.T) { UseProxy: confighelper.TriTrue, generatedData: basicGenData(nil), ExtraArguments: []string{"-e", "hello-world"}, - callArgs: []string{common.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", "/path/to/privkey.pem"}, + callArgs: []string{commonsteps.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", "/path/to/privkey.pem"}, ExpectedArgs: []string{"-e", "packer_build_name=\"packerparty\"", "-e", "packer_builder_type=fakebuilder", "-e", "ansible_ssh_private_key_file=/path/to/privkey.pem", "--ssh-extra-args", "'-o IdentitiesOnly=yes'", "-e", "hello-world", "-i", "/var/inventory", "test-playbook.yml"}, ExpectedEnvVars: []string{}, }, @@ -648,7 +648,7 @@ func TestCreateCmdArgs(t *testing.T) { generatedData: basicGenData(nil), AnsibleSSHExtraArgs: []string{"-o IdentitiesOnly=no"}, ExtraArguments: []string{"-e", "hello-world"}, - callArgs: []string{common.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", "/path/to/privkey.pem"}, + callArgs: []string{commonsteps.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", "/path/to/privkey.pem"}, ExpectedArgs: []string{"-e", "packer_build_name=\"packerparty\"", "-e", "packer_builder_type=fakebuilder", "-e", "ansible_ssh_private_key_file=/path/to/privkey.pem", "--ssh-extra-args", "'-o IdentitiesOnly=no'", "-e", "hello-world", "-i", "/var/inventory", "test-playbook.yml"}, ExpectedEnvVars: []string{}, }, @@ -656,7 +656,7 @@ func TestCreateCmdArgs(t *testing.T) { TestName: "Use SSH Agent", UseProxy: confighelper.TriTrue, generatedData: basicGenData(nil), - callArgs: []string{common.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", ""}, + callArgs: []string{commonsteps.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", ""}, ExpectedArgs: []string{"-e", "packer_builder_type=fakebuilder", "-i", "/var/inventory", "test-playbook.yml"}, ExpectedEnvVars: []string{}, }, @@ -664,7 +664,7 @@ func TestCreateCmdArgs(t *testing.T) { // No builder name. This shouldn't cause an error, it just shouldn't be set. HCL, yo. TestName: "No builder name. This shouldn't cause an error, it just shouldn't be set. HCL, yo.", generatedData: basicGenData(nil), - callArgs: []string{common.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", ""}, + callArgs: []string{commonsteps.HttpAddrNotImplemented, "/var/inventory", "test-playbook.yml", ""}, ExpectedArgs: []string{"-e", "packer_builder_type=fakebuilder", "-i", "/var/inventory", "test-playbook.yml"}, ExpectedEnvVars: []string{}, }, diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index 639314b96..714f11271 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -17,7 +17,7 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/guestexec" "github.com/hashicorp/packer/common/retry" "github.com/hashicorp/packer/common/shell" @@ -407,15 +407,15 @@ func (p *Provisioner) createFlattenedEnvVars(elevated bool) (flattened string) { // expose ip address variables httpAddr := p.generatedData["PackerHTTPAddr"] - if httpAddr != nil && httpAddr != common.HttpAddrNotImplemented { + if httpAddr != nil && httpAddr != commonsteps.HttpAddrNotImplemented { envVars["PACKER_HTTP_ADDR"] = httpAddr.(string) } httpIP := p.generatedData["PackerHTTPIP"] - if httpIP != nil && httpIP != common.HttpIPNotImplemented { + if httpIP != nil && httpIP != commonsteps.HttpIPNotImplemented { envVars["PACKER_HTTP_IP"] = httpIP.(string) } httpPort := p.generatedData["PackerHTTPPort"] - if httpPort != nil && httpPort != common.HttpPortNotImplemented { + if httpPort != nil && httpPort != commonsteps.HttpPortNotImplemented { envVars["PACKER_HTTP_PORT"] = httpPort.(string) } diff --git a/provisioner/powershell/provisioner_test.go b/provisioner/powershell/provisioner_test.go index 4def2785c..f6eb73d64 100644 --- a/provisioner/powershell/provisioner_test.go +++ b/provisioner/powershell/provisioner_test.go @@ -11,7 +11,7 @@ import ( "testing" "time" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/packer" "github.com/stretchr/testify/assert" ) @@ -856,8 +856,8 @@ func testConfigWithSkipClean() map[string]interface{} { func generatedData() map[string]interface{} { return map[string]interface{}{ - "PackerHTTPAddr": common.HttpAddrNotImplemented, - "PackerHTTPIP": common.HttpIPNotImplemented, - "PackerHTTPPort": common.HttpPortNotImplemented, + "PackerHTTPAddr": commonsteps.HttpAddrNotImplemented, + "PackerHTTPIP": commonsteps.HttpIPNotImplemented, + "PackerHTTPPort": commonsteps.HttpPortNotImplemented, } } diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index aec7dc021..7b6fdd918 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -18,7 +18,7 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/retry" "github.com/hashicorp/packer/common/shell" "github.com/hashicorp/packer/helper/config" @@ -418,15 +418,15 @@ func (p *Provisioner) escapeEnvVars() ([]string, map[string]string) { // expose ip address variables httpAddr := p.generatedData["PackerHTTPAddr"] - if httpAddr != nil && httpAddr != common.HttpAddrNotImplemented { + if httpAddr != nil && httpAddr != commonsteps.HttpAddrNotImplemented { envVars["PACKER_HTTP_ADDR"] = httpAddr.(string) } httpIP := p.generatedData["PackerHTTPIP"] - if httpIP != nil && httpIP != common.HttpIPNotImplemented { + if httpIP != nil && httpIP != commonsteps.HttpIPNotImplemented { envVars["PACKER_HTTP_IP"] = httpIP.(string) } httpPort := p.generatedData["PackerHTTPPort"] - if httpPort != nil && httpPort != common.HttpPortNotImplemented { + if httpPort != nil && httpPort != commonsteps.HttpPortNotImplemented { envVars["PACKER_HTTP_PORT"] = httpPort.(string) } diff --git a/provisioner/shell/provisioner_test.go b/provisioner/shell/provisioner_test.go index e4e05e699..b26f744c7 100644 --- a/provisioner/shell/provisioner_test.go +++ b/provisioner/shell/provisioner_test.go @@ -7,7 +7,7 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/packer" ) @@ -563,8 +563,8 @@ func TestProvisionerRemotePathDefaultsSuccessfully(t *testing.T) { func generatedData() map[string]interface{} { return map[string]interface{}{ - "PackerHTTPAddr": common.HttpAddrNotImplemented, - "PackerHTTPIP": common.HttpIPNotImplemented, - "PackerHTTPPort": common.HttpPortNotImplemented, + "PackerHTTPAddr": commonsteps.HttpAddrNotImplemented, + "PackerHTTPIP": commonsteps.HttpIPNotImplemented, + "PackerHTTPPort": commonsteps.HttpPortNotImplemented, } } diff --git a/provisioner/windows-shell/provisioner.go b/provisioner/windows-shell/provisioner.go index 7654154d3..36b6c0512 100644 --- a/provisioner/windows-shell/provisioner.go +++ b/provisioner/windows-shell/provisioner.go @@ -16,7 +16,7 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/common/retry" "github.com/hashicorp/packer/common/shell" "github.com/hashicorp/packer/helper/config" @@ -241,15 +241,15 @@ func (p *Provisioner) createFlattenedEnvVars() (flattened string) { // expose ip address variables httpAddr := p.generatedData["PackerHTTPAddr"] - if httpAddr != nil && httpAddr != common.HttpAddrNotImplemented { + if httpAddr != nil && httpAddr != commonsteps.HttpAddrNotImplemented { envVars["PACKER_HTTP_ADDR"] = httpAddr.(string) } httpIP := p.generatedData["PackerHTTPIP"] - if httpIP != nil && httpIP != common.HttpIPNotImplemented { + if httpIP != nil && httpIP != commonsteps.HttpIPNotImplemented { envVars["PACKER_HTTP_IP"] = httpIP.(string) } httpPort := p.generatedData["PackerHTTPPort"] - if httpPort != nil && httpPort != common.HttpPortNotImplemented { + if httpPort != nil && httpPort != commonsteps.HttpPortNotImplemented { envVars["PACKER_HTTP_PORT"] = httpPort.(string) } diff --git a/provisioner/windows-shell/provisioner_test.go b/provisioner/windows-shell/provisioner_test.go index 4fb65ac3f..158ce31f5 100644 --- a/provisioner/windows-shell/provisioner_test.go +++ b/provisioner/windows-shell/provisioner_test.go @@ -9,7 +9,7 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/common" + "github.com/hashicorp/packer/common/commonsteps" "github.com/hashicorp/packer/packer" ) @@ -433,8 +433,8 @@ func TestCancel(t *testing.T) { } func generatedData() map[string]interface{} { return map[string]interface{}{ - "PackerHTTPAddr": common.HttpAddrNotImplemented, - "PackerHTTPIP": common.HttpIPNotImplemented, - "PackerHTTPPort": common.HttpPortNotImplemented, + "PackerHTTPAddr": commonsteps.HttpAddrNotImplemented, + "PackerHTTPIP": commonsteps.HttpIPNotImplemented, + "PackerHTTPPort": commonsteps.HttpPortNotImplemented, } } diff --git a/vendor/golang.org/x/net/html/const.go b/vendor/golang.org/x/net/html/const.go index 73804d347..ff7acf2d5 100644 --- a/vendor/golang.org/x/net/html/const.go +++ b/vendor/golang.org/x/net/html/const.go @@ -52,7 +52,7 @@ var isSpecialElementMap = map[string]bool{ "iframe": true, "img": true, "input": true, - "keygen": true, + "keygen": true, // "keygen" has been removed from the spec, but are kept here for backwards compatibility. "li": true, "link": true, "listing": true, diff --git a/vendor/golang.org/x/net/html/foreign.go b/vendor/golang.org/x/net/html/foreign.go index 74774c458..9da9e9dc4 100644 --- a/vendor/golang.org/x/net/html/foreign.go +++ b/vendor/golang.org/x/net/html/foreign.go @@ -161,65 +161,62 @@ var mathMLAttributeAdjustments = map[string]string{ } var svgAttributeAdjustments = map[string]string{ - "attributename": "attributeName", - "attributetype": "attributeType", - "basefrequency": "baseFrequency", - "baseprofile": "baseProfile", - "calcmode": "calcMode", - "clippathunits": "clipPathUnits", - "contentscripttype": "contentScriptType", - "contentstyletype": "contentStyleType", - "diffuseconstant": "diffuseConstant", - "edgemode": "edgeMode", - "externalresourcesrequired": "externalResourcesRequired", - "filterunits": "filterUnits", - "glyphref": "glyphRef", - "gradienttransform": "gradientTransform", - "gradientunits": "gradientUnits", - "kernelmatrix": "kernelMatrix", - "kernelunitlength": "kernelUnitLength", - "keypoints": "keyPoints", - "keysplines": "keySplines", - "keytimes": "keyTimes", - "lengthadjust": "lengthAdjust", - "limitingconeangle": "limitingConeAngle", - "markerheight": "markerHeight", - "markerunits": "markerUnits", - "markerwidth": "markerWidth", - "maskcontentunits": "maskContentUnits", - "maskunits": "maskUnits", - "numoctaves": "numOctaves", - "pathlength": "pathLength", - "patterncontentunits": "patternContentUnits", - "patterntransform": "patternTransform", - "patternunits": "patternUnits", - "pointsatx": "pointsAtX", - "pointsaty": "pointsAtY", - "pointsatz": "pointsAtZ", - "preservealpha": "preserveAlpha", - "preserveaspectratio": "preserveAspectRatio", - "primitiveunits": "primitiveUnits", - "refx": "refX", - "refy": "refY", - "repeatcount": "repeatCount", - "repeatdur": "repeatDur", - "requiredextensions": "requiredExtensions", - "requiredfeatures": "requiredFeatures", - "specularconstant": "specularConstant", - "specularexponent": "specularExponent", - "spreadmethod": "spreadMethod", - "startoffset": "startOffset", - "stddeviation": "stdDeviation", - "stitchtiles": "stitchTiles", - "surfacescale": "surfaceScale", - "systemlanguage": "systemLanguage", - "tablevalues": "tableValues", - "targetx": "targetX", - "targety": "targetY", - "textlength": "textLength", - "viewbox": "viewBox", - "viewtarget": "viewTarget", - "xchannelselector": "xChannelSelector", - "ychannelselector": "yChannelSelector", - "zoomandpan": "zoomAndPan", + "attributename": "attributeName", + "attributetype": "attributeType", + "basefrequency": "baseFrequency", + "baseprofile": "baseProfile", + "calcmode": "calcMode", + "clippathunits": "clipPathUnits", + "diffuseconstant": "diffuseConstant", + "edgemode": "edgeMode", + "filterunits": "filterUnits", + "glyphref": "glyphRef", + "gradienttransform": "gradientTransform", + "gradientunits": "gradientUnits", + "kernelmatrix": "kernelMatrix", + "kernelunitlength": "kernelUnitLength", + "keypoints": "keyPoints", + "keysplines": "keySplines", + "keytimes": "keyTimes", + "lengthadjust": "lengthAdjust", + "limitingconeangle": "limitingConeAngle", + "markerheight": "markerHeight", + "markerunits": "markerUnits", + "markerwidth": "markerWidth", + "maskcontentunits": "maskContentUnits", + "maskunits": "maskUnits", + "numoctaves": "numOctaves", + "pathlength": "pathLength", + "patterncontentunits": "patternContentUnits", + "patterntransform": "patternTransform", + "patternunits": "patternUnits", + "pointsatx": "pointsAtX", + "pointsaty": "pointsAtY", + "pointsatz": "pointsAtZ", + "preservealpha": "preserveAlpha", + "preserveaspectratio": "preserveAspectRatio", + "primitiveunits": "primitiveUnits", + "refx": "refX", + "refy": "refY", + "repeatcount": "repeatCount", + "repeatdur": "repeatDur", + "requiredextensions": "requiredExtensions", + "requiredfeatures": "requiredFeatures", + "specularconstant": "specularConstant", + "specularexponent": "specularExponent", + "spreadmethod": "spreadMethod", + "startoffset": "startOffset", + "stddeviation": "stdDeviation", + "stitchtiles": "stitchTiles", + "surfacescale": "surfaceScale", + "systemlanguage": "systemLanguage", + "tablevalues": "tableValues", + "targetx": "targetX", + "targety": "targetY", + "textlength": "textLength", + "viewbox": "viewBox", + "viewtarget": "viewTarget", + "xchannelselector": "xChannelSelector", + "ychannelselector": "yChannelSelector", + "zoomandpan": "zoomAndPan", } diff --git a/vendor/golang.org/x/net/html/render.go b/vendor/golang.org/x/net/html/render.go index 46879c083..b46d81ca6 100644 --- a/vendor/golang.org/x/net/html/render.go +++ b/vendor/golang.org/x/net/html/render.go @@ -263,7 +263,7 @@ var voidElements = map[string]bool{ "hr": true, "img": true, "input": true, - "keygen": true, + "keygen": true, // "keygen" has been removed from the spec, but are kept here for backwards compatibility. "link": true, "meta": true, "param": true, diff --git a/vendor/golang.org/x/net/http/httpproxy/proxy.go b/vendor/golang.org/x/net/http/httpproxy/proxy.go index 163645b86..1415b0779 100644 --- a/vendor/golang.org/x/net/http/httpproxy/proxy.go +++ b/vendor/golang.org/x/net/http/httpproxy/proxy.go @@ -27,8 +27,7 @@ import ( type Config struct { // HTTPProxy represents the value of the HTTP_PROXY or // http_proxy environment variable. It will be used as the proxy - // URL for HTTP requests and HTTPS requests unless overridden by - // HTTPSProxy or NoProxy. + // URL for HTTP requests unless overridden by NoProxy. HTTPProxy string // HTTPSProxy represents the HTTPS_PROXY or https_proxy @@ -129,8 +128,7 @@ func (cfg *config) proxyForURL(reqURL *url.URL) (*url.URL, error) { var proxy *url.URL if reqURL.Scheme == "https" { proxy = cfg.httpsProxy - } - if proxy == nil { + } else if reqURL.Scheme == "http" { proxy = cfg.httpProxy if proxy != nil && cfg.CGI { return nil, errors.New("refusing to use HTTP_PROXY value in CGI environment; see golang.org/s/cgihttpproxy") diff --git a/vendor/golang.org/x/net/http2/server.go b/vendor/golang.org/x/net/http2/server.go index 02714ade6..2aa859f76 100644 --- a/vendor/golang.org/x/net/http2/server.go +++ b/vendor/golang.org/x/net/http2/server.go @@ -1694,6 +1694,7 @@ func (sc *serverConn) processData(f *DataFrame) error { if len(data) > 0 { wrote, err := st.body.Write(data) if err != nil { + sc.sendWindowUpdate(nil, int(f.Length)-wrote) return streamError(id, ErrCodeStreamClosed) } if wrote != len(data) { diff --git a/vendor/golang.org/x/net/http2/transport.go b/vendor/golang.org/x/net/http2/transport.go index 4ec326699..4182f52b4 100644 --- a/vendor/golang.org/x/net/http2/transport.go +++ b/vendor/golang.org/x/net/http2/transport.go @@ -689,6 +689,7 @@ func (t *Transport) newClientConn(c net.Conn, singleUse bool) (*ClientConn, erro cc.inflow.add(transportDefaultConnFlow + initialWindowSize) cc.bw.Flush() if cc.werr != nil { + cc.Close() return nil, cc.werr } @@ -1080,6 +1081,15 @@ func (cc *ClientConn) roundTrip(req *http.Request) (res *http.Response, gotErrAf bodyWriter := cc.t.getBodyWriterState(cs, body) cs.on100 = bodyWriter.on100 + defer func() { + cc.wmu.Lock() + werr := cc.werr + cc.wmu.Unlock() + if werr != nil { + cc.Close() + } + }() + cc.wmu.Lock() endStream := !hasBody && !hasTrailers werr := cc.writeHeaders(cs.ID, endStream, int(cc.maxFrameSize), hdrs) diff --git a/vendor/golang.org/x/sys/cpu/cpu.go b/vendor/golang.org/x/sys/cpu/cpu.go index 5cce25ed9..f77701fe8 100644 --- a/vendor/golang.org/x/sys/cpu/cpu.go +++ b/vendor/golang.org/x/sys/cpu/cpu.go @@ -29,26 +29,46 @@ type CacheLinePad struct{ _ [cacheLineSize]byte } // and HasAVX2 are only set if the OS supports XMM and YMM // registers in addition to the CPUID feature bit being set. var X86 struct { - _ CacheLinePad - HasAES bool // AES hardware implementation (AES NI) - HasADX bool // Multi-precision add-carry instruction extensions - HasAVX bool // Advanced vector extension - HasAVX2 bool // Advanced vector extension 2 - HasBMI1 bool // Bit manipulation instruction set 1 - HasBMI2 bool // Bit manipulation instruction set 2 - HasERMS bool // Enhanced REP for MOVSB and STOSB - HasFMA bool // Fused-multiply-add instructions - HasOSXSAVE bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers. - HasPCLMULQDQ bool // PCLMULQDQ instruction - most often used for AES-GCM - HasPOPCNT bool // Hamming weight instruction POPCNT. - HasRDRAND bool // RDRAND instruction (on-chip random number generator) - HasRDSEED bool // RDSEED instruction (on-chip random number generator) - HasSSE2 bool // Streaming SIMD extension 2 (always available on amd64) - HasSSE3 bool // Streaming SIMD extension 3 - HasSSSE3 bool // Supplemental streaming SIMD extension 3 - HasSSE41 bool // Streaming SIMD extension 4 and 4.1 - HasSSE42 bool // Streaming SIMD extension 4 and 4.2 - _ CacheLinePad + _ CacheLinePad + HasAES bool // AES hardware implementation (AES NI) + HasADX bool // Multi-precision add-carry instruction extensions + HasAVX bool // Advanced vector extension + HasAVX2 bool // Advanced vector extension 2 + HasAVX512 bool // Advanced vector extension 512 + HasAVX512F bool // Advanced vector extension 512 Foundation Instructions + HasAVX512CD bool // Advanced vector extension 512 Conflict Detection Instructions + HasAVX512ER bool // Advanced vector extension 512 Exponential and Reciprocal Instructions + HasAVX512PF bool // Advanced vector extension 512 Prefetch Instructions Instructions + HasAVX512VL bool // Advanced vector extension 512 Vector Length Extensions + HasAVX512BW bool // Advanced vector extension 512 Byte and Word Instructions + HasAVX512DQ bool // Advanced vector extension 512 Doubleword and Quadword Instructions + HasAVX512IFMA bool // Advanced vector extension 512 Integer Fused Multiply Add + HasAVX512VBMI bool // Advanced vector extension 512 Vector Byte Manipulation Instructions + HasAVX5124VNNIW bool // Advanced vector extension 512 Vector Neural Network Instructions Word variable precision + HasAVX5124FMAPS bool // Advanced vector extension 512 Fused Multiply Accumulation Packed Single precision + HasAVX512VPOPCNTDQ bool // Advanced vector extension 512 Double and quad word population count instructions + HasAVX512VPCLMULQDQ bool // Advanced vector extension 512 Vector carry-less multiply operations + HasAVX512VNNI bool // Advanced vector extension 512 Vector Neural Network Instructions + HasAVX512GFNI bool // Advanced vector extension 512 Galois field New Instructions + HasAVX512VAES bool // Advanced vector extension 512 Vector AES instructions + HasAVX512VBMI2 bool // Advanced vector extension 512 Vector Byte Manipulation Instructions 2 + HasAVX512BITALG bool // Advanced vector extension 512 Bit Algorithms + HasAVX512BF16 bool // Advanced vector extension 512 BFloat16 Instructions + HasBMI1 bool // Bit manipulation instruction set 1 + HasBMI2 bool // Bit manipulation instruction set 2 + HasERMS bool // Enhanced REP for MOVSB and STOSB + HasFMA bool // Fused-multiply-add instructions + HasOSXSAVE bool // OS supports XSAVE/XRESTOR for saving/restoring XMM registers. + HasPCLMULQDQ bool // PCLMULQDQ instruction - most often used for AES-GCM + HasPOPCNT bool // Hamming weight instruction POPCNT. + HasRDRAND bool // RDRAND instruction (on-chip random number generator) + HasRDSEED bool // RDSEED instruction (on-chip random number generator) + HasSSE2 bool // Streaming SIMD extension 2 (always available on amd64) + HasSSE3 bool // Streaming SIMD extension 3 + HasSSSE3 bool // Supplemental streaming SIMD extension 3 + HasSSE41 bool // Streaming SIMD extension 4 and 4.1 + HasSSE42 bool // Streaming SIMD extension 4 and 4.2 + _ CacheLinePad } // ARM64 contains the supported CPU features of the diff --git a/vendor/golang.org/x/sys/cpu/cpu_arm64.go b/vendor/golang.org/x/sys/cpu/cpu_arm64.go index 2d9002438..951078f2e 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_arm64.go +++ b/vendor/golang.org/x/sys/cpu/cpu_arm64.go @@ -39,7 +39,7 @@ func initOptions() { func archInit() { switch runtime.GOOS { - case "android", "darwin", "netbsd": + case "android", "darwin", "ios", "netbsd": // Android and iOS don't seem to allow reading these registers. // // NetBSD: diff --git a/vendor/golang.org/x/sys/cpu/cpu_x86.go b/vendor/golang.org/x/sys/cpu/cpu_x86.go index 2ad039d40..48d429331 100644 --- a/vendor/golang.org/x/sys/cpu/cpu_x86.go +++ b/vendor/golang.org/x/sys/cpu/cpu_x86.go @@ -16,6 +16,26 @@ func initOptions() { {Name: "aes", Feature: &X86.HasAES}, {Name: "avx", Feature: &X86.HasAVX}, {Name: "avx2", Feature: &X86.HasAVX2}, + {Name: "avx512", Feature: &X86.HasAVX512}, + {Name: "avx512f", Feature: &X86.HasAVX512F}, + {Name: "avx512cd", Feature: &X86.HasAVX512CD}, + {Name: "avx512er", Feature: &X86.HasAVX512ER}, + {Name: "avx512pf", Feature: &X86.HasAVX512PF}, + {Name: "avx512vl", Feature: &X86.HasAVX512VL}, + {Name: "avx512bw", Feature: &X86.HasAVX512BW}, + {Name: "avx512dq", Feature: &X86.HasAVX512DQ}, + {Name: "avx512ifma", Feature: &X86.HasAVX512IFMA}, + {Name: "avx512vbmi", Feature: &X86.HasAVX512VBMI}, + {Name: "avx512vnniw", Feature: &X86.HasAVX5124VNNIW}, + {Name: "avx5124fmaps", Feature: &X86.HasAVX5124FMAPS}, + {Name: "avx512vpopcntdq", Feature: &X86.HasAVX512VPOPCNTDQ}, + {Name: "avx512vpclmulqdq", Feature: &X86.HasAVX512VPCLMULQDQ}, + {Name: "avx512vnni", Feature: &X86.HasAVX512VNNI}, + {Name: "avx512gfni", Feature: &X86.HasAVX512GFNI}, + {Name: "avx512vaes", Feature: &X86.HasAVX512VAES}, + {Name: "avx512vbmi2", Feature: &X86.HasAVX512VBMI2}, + {Name: "avx512bitalg", Feature: &X86.HasAVX512BITALG}, + {Name: "avx512bf16", Feature: &X86.HasAVX512BF16}, {Name: "bmi1", Feature: &X86.HasBMI1}, {Name: "bmi2", Feature: &X86.HasBMI2}, {Name: "erms", Feature: &X86.HasERMS}, @@ -59,12 +79,15 @@ func archInit() { X86.HasOSXSAVE = isSet(27, ecx1) X86.HasRDRAND = isSet(30, ecx1) - osSupportsAVX := false + var osSupportsAVX, osSupportsAVX512 bool // For XGETBV, OSXSAVE bit is required and sufficient. if X86.HasOSXSAVE { eax, _ := xgetbv() // Check if XMM and YMM registers have OS support. osSupportsAVX = isSet(1, eax) && isSet(2, eax) + + // Check if OPMASK and ZMM registers have OS support. + osSupportsAVX512 = osSupportsAVX && isSet(5, eax) && isSet(6, eax) && isSet(7, eax) } X86.HasAVX = isSet(28, ecx1) && osSupportsAVX @@ -73,7 +96,7 @@ func archInit() { return } - _, ebx7, _, _ := cpuid(7, 0) + _, ebx7, ecx7, edx7 := cpuid(7, 0) X86.HasBMI1 = isSet(3, ebx7) X86.HasAVX2 = isSet(5, ebx7) && osSupportsAVX X86.HasBMI2 = isSet(8, ebx7) @@ -81,6 +104,30 @@ func archInit() { X86.HasRDSEED = isSet(18, ebx7) X86.HasADX = isSet(19, ebx7) + X86.HasAVX512 = isSet(16, ebx7) && osSupportsAVX512 // Because avx-512 foundation is the core required extension + if X86.HasAVX512 { + X86.HasAVX512F = true + X86.HasAVX512CD = isSet(28, ebx7) + X86.HasAVX512ER = isSet(27, ebx7) + X86.HasAVX512PF = isSet(26, ebx7) + X86.HasAVX512VL = isSet(31, ebx7) + X86.HasAVX512BW = isSet(30, ebx7) + X86.HasAVX512DQ = isSet(17, ebx7) + X86.HasAVX512IFMA = isSet(21, ebx7) + X86.HasAVX512VBMI = isSet(1, ecx7) + X86.HasAVX5124VNNIW = isSet(2, edx7) + X86.HasAVX5124FMAPS = isSet(3, edx7) + X86.HasAVX512VPOPCNTDQ = isSet(14, ecx7) + X86.HasAVX512VPCLMULQDQ = isSet(10, ecx7) + X86.HasAVX512VNNI = isSet(11, ecx7) + X86.HasAVX512GFNI = isSet(8, ecx7) + X86.HasAVX512VAES = isSet(9, ecx7) + X86.HasAVX512VBMI2 = isSet(6, ecx7) + X86.HasAVX512BITALG = isSet(12, ecx7) + + eax71, _, _, _ := cpuid(7, 1) + X86.HasAVX512BF16 = isSet(5, eax71) + } } func isSet(bitpos uint, value uint32) bool { diff --git a/vendor/golang.org/x/sys/unix/gccgo.go b/vendor/golang.org/x/sys/unix/gccgo.go index cd6f5a613..86032c11e 100644 --- a/vendor/golang.org/x/sys/unix/gccgo.go +++ b/vendor/golang.org/x/sys/unix/gccgo.go @@ -12,10 +12,8 @@ import "syscall" // We can't use the gc-syntax .s files for gccgo. On the plus side // much of the functionality can be written directly in Go. -//extern gccgoRealSyscallNoError func realSyscallNoError(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r uintptr) -//extern gccgoRealSyscall func realSyscall(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r, errno uintptr) func SyscallNoError(trap, a1, a2, a3 uintptr) (r1, r2 uintptr) { diff --git a/vendor/golang.org/x/sys/unix/gccgo_c.c b/vendor/golang.org/x/sys/unix/gccgo_c.c index c44730c5e..2cb1fefac 100644 --- a/vendor/golang.org/x/sys/unix/gccgo_c.c +++ b/vendor/golang.org/x/sys/unix/gccgo_c.c @@ -21,6 +21,9 @@ struct ret { uintptr_t err; }; +struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) + __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscall"); + struct ret gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) { @@ -32,6 +35,9 @@ gccgoRealSyscall(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintp return r; } +uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) + __asm__(GOSYM_PREFIX GOPKGPATH ".realSyscallNoError"); + uintptr_t gccgoRealSyscallNoError(uintptr_t trap, uintptr_t a1, uintptr_t a2, uintptr_t a3, uintptr_t a4, uintptr_t a5, uintptr_t a6, uintptr_t a7, uintptr_t a8, uintptr_t a9) { diff --git a/vendor/golang.org/x/sys/unix/mkerrors.sh b/vendor/golang.org/x/sys/unix/mkerrors.sh index e7c51aa40..1bef7148d 100644 --- a/vendor/golang.org/x/sys/unix/mkerrors.sh +++ b/vendor/golang.org/x/sys/unix/mkerrors.sh @@ -517,6 +517,7 @@ ccflags="$@" $2 ~ /^CP_/ || $2 ~ /^CPUSTATES$/ || $2 ~ /^ALG_/ || + $2 ~ /^FI(CLONE|DEDUPERANGE)/ || $2 ~ /^FS_(POLICY_FLAGS|KEY_DESC|ENCRYPTION_MODE|[A-Z0-9_]+_KEY_SIZE)/ || $2 ~ /^FS_IOC_.*(ENCRYPTION|VERITY|[GS]ETFLAGS)/ || $2 ~ /^FS_VERITY_/ || diff --git a/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go b/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go index 7d08dae5b..57a0021da 100644 --- a/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go +++ b/vendor/golang.org/x/sys/unix/sockcmsg_unix_other.go @@ -20,7 +20,7 @@ func cmsgAlignOf(salen int) int { case "aix": // There is no alignment on AIX. salign = 1 - case "darwin", "illumos", "solaris": + case "darwin", "ios", "illumos", "solaris": // NOTE: It seems like 64-bit Darwin, Illumos and Solaris // kernels still require 32-bit aligned access to network // subsystem. @@ -32,6 +32,10 @@ func cmsgAlignOf(salen int) int { if runtime.GOARCH == "arm" { salign = 8 } + // NetBSD aarch64 requires 128-bit alignment. + if runtime.GOOS == "netbsd" && runtime.GOARCH == "arm64" { + salign = 16 + } } return (salen + salign - 1) & ^(salign - 1) diff --git a/vendor/golang.org/x/sys/unix/syscall_bsd.go b/vendor/golang.org/x/sys/unix/syscall_bsd.go index 60bbe10ad..123536a02 100644 --- a/vendor/golang.org/x/sys/unix/syscall_bsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_bsd.go @@ -18,6 +18,21 @@ import ( "unsafe" ) +const ImplementsGetwd = true + +func Getwd() (string, error) { + var buf [PathMax]byte + _, err := Getcwd(buf[0:]) + if err != nil { + return "", err + } + n := clen(buf[:]) + if n < 1 { + return "", EINVAL + } + return string(buf[:n]), nil +} + /* * Wrapped */ @@ -272,7 +287,7 @@ func Accept(fd int) (nfd int, sa Sockaddr, err error) { if err != nil { return } - if runtime.GOOS == "darwin" && len == 0 { + if (runtime.GOOS == "darwin" || runtime.GOOS == "ios") && len == 0 { // Accepted socket has no address. // This is likely due to a bug in xnu kernels, // where instead of ECONNABORTED error socket diff --git a/vendor/golang.org/x/sys/unix/syscall_darwin.go b/vendor/golang.org/x/sys/unix/syscall_darwin.go index eddcf3a91..21b8092cd 100644 --- a/vendor/golang.org/x/sys/unix/syscall_darwin.go +++ b/vendor/golang.org/x/sys/unix/syscall_darwin.go @@ -13,29 +13,10 @@ package unix import ( - "errors" "syscall" "unsafe" ) -const ImplementsGetwd = true - -func Getwd() (string, error) { - buf := make([]byte, 2048) - attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0) - if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 { - wd := string(attrs[0]) - // Sanity check that it's an absolute path and ends - // in a null byte, which we then strip. - if wd[0] == '/' && wd[len(wd)-1] == 0 { - return wd[:len(wd)-1], nil - } - } - // If pkg/os/getwd.go gets ENOTSUP, it will fall back to the - // slow algorithm. - return "", ENOTSUP -} - // SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets. type SockaddrDatalink struct { Len uint8 @@ -97,11 +78,6 @@ func direntNamlen(buf []byte) (uint64, bool) { func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) } func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) } -const ( - attrBitMapCount = 5 - attrCmnFullpath = 0x08000000 -) - type attrList struct { bitmapCount uint16 _ uint16 @@ -112,54 +88,6 @@ type attrList struct { Forkattr uint32 } -func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) { - if len(attrBuf) < 4 { - return nil, errors.New("attrBuf too small") - } - attrList.bitmapCount = attrBitMapCount - - var _p0 *byte - _p0, err = BytePtrFromString(path) - if err != nil { - return nil, err - } - - if err := getattrlist(_p0, unsafe.Pointer(&attrList), unsafe.Pointer(&attrBuf[0]), uintptr(len(attrBuf)), int(options)); err != nil { - return nil, err - } - size := *(*uint32)(unsafe.Pointer(&attrBuf[0])) - - // dat is the section of attrBuf that contains valid data, - // without the 4 byte length header. All attribute offsets - // are relative to dat. - dat := attrBuf - if int(size) < len(attrBuf) { - dat = dat[:size] - } - dat = dat[4:] // remove length prefix - - for i := uint32(0); int(i) < len(dat); { - header := dat[i:] - if len(header) < 8 { - return attrs, errors.New("truncated attribute header") - } - datOff := *(*int32)(unsafe.Pointer(&header[0])) - attrLen := *(*uint32)(unsafe.Pointer(&header[4])) - if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) { - return attrs, errors.New("truncated results; attrBuf too small") - } - end := uint32(datOff) + attrLen - attrs = append(attrs, dat[datOff:end]) - i = end - if r := i % 4; r != 0 { - i += (4 - r) - } - } - return -} - -//sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) - //sysnb pipe() (r int, w int, err error) func Pipe(p []int) (err error) { @@ -419,6 +347,7 @@ func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err e //sys Fpathconf(fd int, name int) (val int, err error) //sys Fsync(fd int) (err error) //sys Ftruncate(fd int, length int64) (err error) +//sys Getcwd(buf []byte) (n int, err error) //sys Getdtablesize() (size int) //sysnb Getegid() (egid int) //sysnb Geteuid() (uid int) diff --git a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go index 8a195ae58..bed7dcfec 100644 --- a/vendor/golang.org/x/sys/unix/syscall_dragonfly.go +++ b/vendor/golang.org/x/sys/unix/syscall_dragonfly.go @@ -129,23 +129,8 @@ func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) { return } -const ImplementsGetwd = true - //sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD -func Getwd() (string, error) { - var buf [PathMax]byte - _, err := Getcwd(buf[0:]) - if err != nil { - return "", err - } - n := clen(buf[:]) - if n < 1 { - return "", EINVAL - } - return string(buf[:n]), nil -} - func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { var _p0 unsafe.Pointer var bufsize uintptr diff --git a/vendor/golang.org/x/sys/unix/syscall_freebsd.go b/vendor/golang.org/x/sys/unix/syscall_freebsd.go index 6932e7c2c..f6db02aff 100644 --- a/vendor/golang.org/x/sys/unix/syscall_freebsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_freebsd.go @@ -140,23 +140,8 @@ func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) { return } -const ImplementsGetwd = true - //sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD -func Getwd() (string, error) { - var buf [PathMax]byte - _, err := Getcwd(buf[0:]) - if err != nil { - return "", err - } - n := clen(buf[:]) - if n < 1 { - return "", EINVAL - } - return string(buf[:n]), nil -} - func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { var ( _p0 unsafe.Pointer diff --git a/vendor/golang.org/x/sys/unix/syscall_illumos.go b/vendor/golang.org/x/sys/unix/syscall_illumos.go index 16e40091c..bbc4f3ea5 100644 --- a/vendor/golang.org/x/sys/unix/syscall_illumos.go +++ b/vendor/golang.org/x/sys/unix/syscall_illumos.go @@ -56,7 +56,7 @@ func Pwritev(fd int, iovs [][]byte, off int64) (n int, err error) { return n, err } -//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) +//sys accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) = libsocket.accept4 func Accept4(fd int, flags int) (nfd int, sa Sockaddr, err error) { var rsa RawSockaddrAny diff --git a/vendor/golang.org/x/sys/unix/syscall_linux.go b/vendor/golang.org/x/sys/unix/syscall_linux.go index ec7e4c4d3..94dafa4e5 100644 --- a/vendor/golang.org/x/sys/unix/syscall_linux.go +++ b/vendor/golang.org/x/sys/unix/syscall_linux.go @@ -112,6 +112,31 @@ func IoctlGetRTCWkAlrm(fd int) (*RTCWkAlrm, error) { return &value, err } +// IoctlFileClone performs an FICLONERANGE ioctl operation to clone the range of +// data conveyed in value to the file associated with the file descriptor +// destFd. See the ioctl_ficlonerange(2) man page for details. +func IoctlFileCloneRange(destFd int, value *FileCloneRange) error { + err := ioctl(destFd, FICLONERANGE, uintptr(unsafe.Pointer(value))) + runtime.KeepAlive(value) + return err +} + +// IoctlFileClone performs an FICLONE ioctl operation to clone the entire file +// associated with the file description srcFd to the file associated with the +// file descriptor destFd. See the ioctl_ficlone(2) man page for details. +func IoctlFileClone(destFd, srcFd int) error { + return ioctl(destFd, FICLONE, uintptr(srcFd)) +} + +// IoctlFileClone performs an FIDEDUPERANGE ioctl operation to share the range of +// data conveyed in value with the file associated with the file descriptor +// destFd. See the ioctl_fideduperange(2) man page for details. +func IoctlFileDedupeRange(destFd int, value *FileDedupeRange) error { + err := ioctl(destFd, FIDEDUPERANGE, uintptr(unsafe.Pointer(value))) + runtime.KeepAlive(value) + return err +} + //sys Linkat(olddirfd int, oldpath string, newdirfd int, newpath string, flags int) (err error) func Link(oldpath string, newpath string) (err error) { diff --git a/vendor/golang.org/x/sys/unix/syscall_netbsd.go b/vendor/golang.org/x/sys/unix/syscall_netbsd.go index 45b50a610..dbd5e03b6 100644 --- a/vendor/golang.org/x/sys/unix/syscall_netbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_netbsd.go @@ -141,23 +141,8 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { return } -const ImplementsGetwd = true - //sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD -func Getwd() (string, error) { - var buf [PathMax]byte - _, err := Getcwd(buf[0:]) - if err != nil { - return "", err - } - n := clen(buf[:]) - if n < 1 { - return "", EINVAL - } - return string(buf[:n]), nil -} - // TODO func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { return -1, ENOSYS diff --git a/vendor/golang.org/x/sys/unix/syscall_openbsd.go b/vendor/golang.org/x/sys/unix/syscall_openbsd.go index a266e92a9..2c1f46ea1 100644 --- a/vendor/golang.org/x/sys/unix/syscall_openbsd.go +++ b/vendor/golang.org/x/sys/unix/syscall_openbsd.go @@ -114,23 +114,8 @@ func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) { return } -const ImplementsGetwd = true - //sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD -func Getwd() (string, error) { - var buf [PathMax]byte - _, err := Getcwd(buf[0:]) - if err != nil { - return "", err - } - n := clen(buf[:]) - if n < 1 { - return "", EINVAL - } - return string(buf[:n]), nil -} - func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { if raceenabled { raceReleaseMerge(unsafe.Pointer(&ioSync)) diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux.go b/vendor/golang.org/x/sys/unix/zerrors_linux.go index 388050a0f..79e032f4f 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux.go @@ -686,6 +686,7 @@ const ( FD_CLOEXEC = 0x1 FD_SETSIZE = 0x400 FF0 = 0x0 + FIDEDUPERANGE = 0xc0189436 FSCRYPT_KEY_DESCRIPTOR_SIZE = 0x8 FSCRYPT_KEY_DESC_PREFIX = "fscrypt:" FSCRYPT_KEY_DESC_PREFIX_SIZE = 0x8 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go index 11b25f68c..dd282c08b 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_386.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_386.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x40049409 + FICLONERANGE = 0x4020940d FLUSHO = 0x1000 FP_XSTATE_MAGIC2 = 0x46505845 FS_IOC_ENABLE_VERITY = 0x40806685 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go index f92cff6ea..82fc93c7b 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_amd64.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x40049409 + FICLONERANGE = 0x4020940d FLUSHO = 0x1000 FP_XSTATE_MAGIC2 = 0x46505845 FS_IOC_ENABLE_VERITY = 0x40806685 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go index 12bcbf88d..fe7094f27 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x40049409 + FICLONERANGE = 0x4020940d FLUSHO = 0x1000 FS_IOC_ENABLE_VERITY = 0x40806685 FS_IOC_GETFLAGS = 0x80046601 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go index 84f71e99f..3b6cc5880 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_arm64.go @@ -73,6 +73,8 @@ const ( EXTRA_MAGIC = 0x45585401 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x40049409 + FICLONERANGE = 0x4020940d FLUSHO = 0x1000 FPSIMD_MAGIC = 0x46508001 FS_IOC_ENABLE_VERITY = 0x40806685 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go index eeadea943..ce3d9ae15 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x80049409 + FICLONERANGE = 0x8020940d FLUSHO = 0x2000 FS_IOC_ENABLE_VERITY = 0x80806685 FS_IOC_GETFLAGS = 0x40046601 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go index 0be6c4ccc..7a85215ce 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x80049409 + FICLONERANGE = 0x8020940d FLUSHO = 0x2000 FS_IOC_ENABLE_VERITY = 0x80806685 FS_IOC_GETFLAGS = 0x40086601 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go index 0880b745c..07d4cc1bd 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mips64le.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x80049409 + FICLONERANGE = 0x8020940d FLUSHO = 0x2000 FS_IOC_ENABLE_VERITY = 0x80806685 FS_IOC_GETFLAGS = 0x40086601 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go index c8a66627a..d4842ba1c 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_mipsle.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x80049409 + FICLONERANGE = 0x8020940d FLUSHO = 0x2000 FS_IOC_ENABLE_VERITY = 0x80806685 FS_IOC_GETFLAGS = 0x40046601 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go index 97aae63f1..941e20dac 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000000 FF1 = 0x4000 FFDLY = 0x4000 + FICLONE = 0x80049409 + FICLONERANGE = 0x8020940d FLUSHO = 0x800000 FS_IOC_ENABLE_VERITY = 0x80806685 FS_IOC_GETFLAGS = 0x40086601 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go index b0c3b0664..63d3bc566 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_ppc64le.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000000 FF1 = 0x4000 FFDLY = 0x4000 + FICLONE = 0x80049409 + FICLONERANGE = 0x8020940d FLUSHO = 0x800000 FS_IOC_ENABLE_VERITY = 0x80806685 FS_IOC_GETFLAGS = 0x40086601 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go index 0c0518193..490bee1ab 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_riscv64.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x40049409 + FICLONERANGE = 0x4020940d FLUSHO = 0x1000 FS_IOC_ENABLE_VERITY = 0x40806685 FS_IOC_GETFLAGS = 0x80086601 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go index 0b96bd462..467b8218e 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_s390x.go @@ -71,6 +71,8 @@ const ( EXTPROC = 0x10000 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x40049409 + FICLONERANGE = 0x4020940d FLUSHO = 0x1000 FS_IOC_ENABLE_VERITY = 0x40806685 FS_IOC_GETFLAGS = 0x80086601 diff --git a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go index bd5c30577..79fbafbcf 100644 --- a/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go +++ b/vendor/golang.org/x/sys/unix/zerrors_linux_sparc64.go @@ -75,6 +75,8 @@ const ( EXTPROC = 0x10000 FF1 = 0x8000 FFDLY = 0x8000 + FICLONE = 0x80049409 + FICLONERANGE = 0x8020940d FLUSHO = 0x1000 FS_IOC_ENABLE_VERITY = 0x80806685 FS_IOC_GETFLAGS = 0x40086601 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go index 397614720..bd13b3856 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.go @@ -490,21 +490,6 @@ func libc_munlockall_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) { - _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -func libc_getattrlist_trampoline() - -//go:linkname libc_getattrlist libc_getattrlist -//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func pipe() (r int, w int, err error) { r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) r = int(r0) @@ -1277,6 +1262,28 @@ func libc_ftruncate_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(funcPC(libc_getcwd_trampoline), uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func libc_getcwd_trampoline() + +//go:linkname libc_getcwd libc_getcwd +//go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdtablesize() (size int) { r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0) size = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s index 961058db8..d5fb53fd1 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_386.s @@ -60,8 +60,6 @@ TEXT ·libc_munlock_trampoline(SB),NOSPLIT,$0-0 JMP libc_munlock(SB) TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0 JMP libc_munlockall(SB) -TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0 - JMP libc_getattrlist(SB) TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0 JMP libc_pipe(SB) TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0 @@ -146,6 +144,8 @@ TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0 JMP libc_fsync(SB) TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0 JMP libc_ftruncate(SB) +TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0 + JMP libc_getcwd(SB) TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0 JMP libc_getdtablesize(SB) TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go index e253f4387..d81696f9e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.go @@ -490,21 +490,6 @@ func libc_munlockall_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) { - _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -func libc_getattrlist_trampoline() - -//go:linkname libc_getattrlist libc_getattrlist -//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func pipe() (r int, w int, err error) { r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) r = int(r0) @@ -1277,6 +1262,28 @@ func libc_ftruncate_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(funcPC(libc_getcwd_trampoline), uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func libc_getcwd_trampoline() + +//go:linkname libc_getcwd libc_getcwd +//go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdtablesize() (size int) { r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0) size = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s index b8be24c6b..887fd5f4e 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_amd64.s @@ -60,8 +60,6 @@ TEXT ·libc_munlock_trampoline(SB),NOSPLIT,$0-0 JMP libc_munlock(SB) TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0 JMP libc_munlockall(SB) -TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0 - JMP libc_getattrlist(SB) TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0 JMP libc_pipe(SB) TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0 @@ -146,6 +144,8 @@ TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0 JMP libc_fsync(SB) TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0 JMP libc_ftruncate(SB) +TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0 + JMP libc_getcwd(SB) TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0 JMP libc_getdtablesize(SB) TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go index be2e28311..d6b5249c2 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.go @@ -490,21 +490,6 @@ func libc_munlockall_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) { - _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -func libc_getattrlist_trampoline() - -//go:linkname libc_getattrlist libc_getattrlist -//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func pipe() (r int, w int, err error) { r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) r = int(r0) @@ -1277,6 +1262,28 @@ func libc_ftruncate_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(funcPC(libc_getcwd_trampoline), uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func libc_getcwd_trampoline() + +//go:linkname libc_getcwd libc_getcwd +//go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdtablesize() (size int) { r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0) size = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s index 403c21f06..5eec5f1d9 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm.s @@ -60,8 +60,6 @@ TEXT ·libc_munlock_trampoline(SB),NOSPLIT,$0-0 JMP libc_munlock(SB) TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0 JMP libc_munlockall(SB) -TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0 - JMP libc_getattrlist(SB) TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0 JMP libc_pipe(SB) TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0 @@ -146,6 +144,8 @@ TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0 JMP libc_fsync(SB) TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0 JMP libc_ftruncate(SB) +TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0 + JMP libc_getcwd(SB) TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0 JMP libc_getdtablesize(SB) TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go index 34976a4c2..08638436c 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.go @@ -490,21 +490,6 @@ func libc_munlockall_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) { - _, _, e1 := syscall_syscall6(funcPC(libc_getattrlist_trampoline), uintptr(unsafe.Pointer(path)), uintptr(list), uintptr(buf), uintptr(size), uintptr(options), 0) - if e1 != 0 { - err = errnoErr(e1) - } - return -} - -func libc_getattrlist_trampoline() - -//go:linkname libc_getattrlist libc_getattrlist -//go:cgo_import_dynamic libc_getattrlist getattrlist "/usr/lib/libSystem.B.dylib" - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func pipe() (r int, w int, err error) { r0, r1, e1 := syscall_rawSyscall(funcPC(libc_pipe_trampoline), 0, 0, 0) r = int(r0) @@ -1277,6 +1262,28 @@ func libc_ftruncate_trampoline() // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT +func Getcwd(buf []byte) (n int, err error) { + var _p0 unsafe.Pointer + if len(buf) > 0 { + _p0 = unsafe.Pointer(&buf[0]) + } else { + _p0 = unsafe.Pointer(&_zero) + } + r0, _, e1 := syscall_syscall(funcPC(libc_getcwd_trampoline), uintptr(_p0), uintptr(len(buf)), 0) + n = int(r0) + if e1 != 0 { + err = errnoErr(e1) + } + return +} + +func libc_getcwd_trampoline() + +//go:linkname libc_getcwd libc_getcwd +//go:cgo_import_dynamic libc_getcwd getcwd "/usr/lib/libSystem.B.dylib" + +// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT + func Getdtablesize() (size int) { r0, _, _ := syscall_syscall(funcPC(libc_getdtablesize_trampoline), 0, 0, 0) size = int(r0) diff --git a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s index abe7b6edf..16aebee23 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s +++ b/vendor/golang.org/x/sys/unix/zsyscall_darwin_arm64.s @@ -60,8 +60,6 @@ TEXT ·libc_munlock_trampoline(SB),NOSPLIT,$0-0 JMP libc_munlock(SB) TEXT ·libc_munlockall_trampoline(SB),NOSPLIT,$0-0 JMP libc_munlockall(SB) -TEXT ·libc_getattrlist_trampoline(SB),NOSPLIT,$0-0 - JMP libc_getattrlist(SB) TEXT ·libc_pipe_trampoline(SB),NOSPLIT,$0-0 JMP libc_pipe(SB) TEXT ·libc_getxattr_trampoline(SB),NOSPLIT,$0-0 @@ -146,6 +144,8 @@ TEXT ·libc_fsync_trampoline(SB),NOSPLIT,$0-0 JMP libc_fsync(SB) TEXT ·libc_ftruncate_trampoline(SB),NOSPLIT,$0-0 JMP libc_ftruncate(SB) +TEXT ·libc_getcwd_trampoline(SB),NOSPLIT,$0-0 + JMP libc_getcwd(SB) TEXT ·libc_getdtablesize_trampoline(SB),NOSPLIT,$0-0 JMP libc_getdtablesize(SB) TEXT ·libc_getegid_trampoline(SB),NOSPLIT,$0-0 diff --git a/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go b/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go index 8b329c458..d3af083f4 100644 --- a/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go +++ b/vendor/golang.org/x/sys/unix/zsyscall_illumos_amd64.go @@ -13,7 +13,7 @@ import ( //go:cgo_import_dynamic libc_preadv preadv "libc.so" //go:cgo_import_dynamic libc_writev writev "libc.so" //go:cgo_import_dynamic libc_pwritev pwritev "libc.so" -//go:cgo_import_dynamic libc_accept4 accept4 "libc.so" +//go:cgo_import_dynamic libc_accept4 accept4 "libsocket.so" //go:cgo_import_dynamic libc_pipe2 pipe2 "libc.so" //go:linkname procreadv libc_readv diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go index 9f47b87c5..6103f2150 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_386.go @@ -145,6 +145,10 @@ type Dirent struct { _ [3]byte } +const ( + PathMax = 0x400 +) + type RawSockaddrInet4 struct { Len uint8 Family uint8 diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go index 966798a87..e6576d1c4 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_amd64.go @@ -151,6 +151,10 @@ type Dirent struct { _ [3]byte } +const ( + PathMax = 0x400 +) + type RawSockaddrInet4 struct { Len uint8 Family uint8 diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go index 4fe4c9cd7..af9560fa1 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm.go @@ -146,6 +146,10 @@ type Dirent struct { _ [3]byte } +const ( + PathMax = 0x400 +) + type RawSockaddrInet4 struct { Len uint8 Family uint8 diff --git a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go index 21999e4b0..a09c0f942 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go +++ b/vendor/golang.org/x/sys/unix/ztypes_darwin_arm64.go @@ -151,6 +151,10 @@ type Dirent struct { _ [3]byte } +const ( + PathMax = 0x400 +) + type RawSockaddrInet4 struct { Len uint8 Family uint8 diff --git a/vendor/golang.org/x/sys/unix/ztypes_linux.go b/vendor/golang.org/x/sys/unix/ztypes_linux.go index 68e4974a9..a92a5019a 100644 --- a/vendor/golang.org/x/sys/unix/ztypes_linux.go +++ b/vendor/golang.org/x/sys/unix/ztypes_linux.go @@ -76,6 +76,21 @@ type Fsid struct { Val [2]int32 } +type FileCloneRange struct { + Src_fd int64 + Src_offset uint64 + Src_length uint64 + Dest_offset uint64 +} + +type FileDedupeRange struct { + Src_offset uint64 + Src_length uint64 + Dest_count uint16 + Reserved1 uint16 + Reserved2 uint32 +} + type FscryptPolicy struct { Version uint8 Contents_encryption_mode uint8 diff --git a/vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter.go b/vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter.go index 8dcd8bbb7..e8cba6b23 100644 --- a/vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter.go +++ b/vendor/golang.org/x/tools/go/internal/gcimporter/gcimporter.go @@ -491,7 +491,7 @@ func (p *parser) parseMapType(parent *types.Package) types.Type { // // For unqualified and anonymous names, the returned package is the parent // package unless parent == nil, in which case the returned package is the -// package being imported. (The parent package is not nil if the the name +// package being imported. (The parent package is not nil if the name // is an unqualified struct field or interface method name belonging to a // type declared in another package.) // diff --git a/vendor/golang.org/x/tools/go/internal/packagesdriver/sizes.go b/vendor/golang.org/x/tools/go/internal/packagesdriver/sizes.go index dc6177c12..35bc6a412 100644 --- a/vendor/golang.org/x/tools/go/internal/packagesdriver/sizes.go +++ b/vendor/golang.org/x/tools/go/internal/packagesdriver/sizes.go @@ -39,7 +39,12 @@ func GetSizes(ctx context.Context, buildFlags, env []string, gocmdRunner *gocomm } if tool == "off" { - return GetSizesGolist(ctx, buildFlags, env, gocmdRunner, dir) + inv := gocommand.Invocation{ + BuildFlags: buildFlags, + Env: env, + WorkingDir: dir, + } + return GetSizesGolist(ctx, inv, gocmdRunner) } req, err := json.Marshal(struct { @@ -75,26 +80,17 @@ func GetSizes(ctx context.Context, buildFlags, env []string, gocmdRunner *gocomm return response.Sizes, nil } -func GetSizesGolist(ctx context.Context, buildFlags, env []string, gocmdRunner *gocommand.Runner, dir string) (types.Sizes, error) { - inv := gocommand.Invocation{ - Verb: "list", - Args: []string{"-f", "{{context.GOARCH}} {{context.Compiler}}", "--", "unsafe"}, - Env: env, - BuildFlags: buildFlags, - WorkingDir: dir, - } +func GetSizesGolist(ctx context.Context, inv gocommand.Invocation, gocmdRunner *gocommand.Runner) (types.Sizes, error) { + inv.Verb = "list" + inv.Args = []string{"-f", "{{context.GOARCH}} {{context.Compiler}}", "--", "unsafe"} stdout, stderr, friendlyErr, rawErr := gocmdRunner.RunRaw(ctx, inv) var goarch, compiler string if rawErr != nil { if strings.Contains(rawErr.Error(), "cannot find main module") { // User's running outside of a module. All bets are off. Get GOARCH and guess compiler is gc. // TODO(matloob): Is this a problem in practice? - inv := gocommand.Invocation{ - Verb: "env", - Args: []string{"GOARCH"}, - Env: env, - WorkingDir: dir, - } + inv.Verb = "env" + inv.Args = []string{"GOARCH"} envout, enverr := gocmdRunner.Run(ctx, inv) if enverr != nil { return nil, enverr diff --git a/vendor/golang.org/x/tools/go/packages/golist.go b/vendor/golang.org/x/tools/go/packages/golist.go index bc04503c1..81381fa1c 100644 --- a/vendor/golang.org/x/tools/go/packages/golist.go +++ b/vendor/golang.org/x/tools/go/packages/golist.go @@ -10,6 +10,7 @@ import ( "encoding/json" "fmt" "go/types" + "io/ioutil" "log" "os" "os/exec" @@ -91,7 +92,7 @@ type golistState struct { goVersionOnce sync.Once goVersionError error - goVersion string // third field of 'go version' + goVersion int // The X in Go 1.X. // vendorDirs caches the (non)existence of vendor directories. vendorDirs map[string]bool @@ -139,6 +140,12 @@ func goListDriver(cfg *Config, patterns ...string) (*driverResponse, error) { response := newDeduper() + state := &golistState{ + cfg: cfg, + ctx: ctx, + vendorDirs: map[string]bool{}, + } + // Fill in response.Sizes asynchronously if necessary. var sizeserr error var sizeswg sync.WaitGroup @@ -146,19 +153,13 @@ func goListDriver(cfg *Config, patterns ...string) (*driverResponse, error) { sizeswg.Add(1) go func() { var sizes types.Sizes - sizes, sizeserr = packagesdriver.GetSizesGolist(ctx, cfg.BuildFlags, cfg.Env, cfg.gocmdRunner, cfg.Dir) + sizes, sizeserr = packagesdriver.GetSizesGolist(ctx, state.cfgInvocation(), cfg.gocmdRunner) // types.SizesFor always returns nil or a *types.StdSizes. response.dr.Sizes, _ = sizes.(*types.StdSizes) sizeswg.Done() }() } - state := &golistState{ - cfg: cfg, - ctx: ctx, - vendorDirs: map[string]bool{}, - } - // Determine files requested in contains patterns var containFiles []string restPatterns := make([]string, 0, len(patterns)) @@ -208,56 +209,58 @@ extractQueries: } } - modifiedPkgs, needPkgs, err := state.processGolistOverlay(response) - if err != nil { - return nil, err - } + // Only use go/packages' overlay processing if we're using a Go version + // below 1.16. Otherwise, go list handles it. + if goVersion, err := state.getGoVersion(); err == nil && goVersion < 16 { + modifiedPkgs, needPkgs, err := state.processGolistOverlay(response) + if err != nil { + return nil, err + } - var containsCandidates []string - if len(containFiles) > 0 { - containsCandidates = append(containsCandidates, modifiedPkgs...) - containsCandidates = append(containsCandidates, needPkgs...) - } - if err := state.addNeededOverlayPackages(response, needPkgs); err != nil { - return nil, err - } - // Check candidate packages for containFiles. - if len(containFiles) > 0 { - for _, id := range containsCandidates { - pkg, ok := response.seenPackages[id] - if !ok { - response.addPackage(&Package{ - ID: id, - Errors: []Error{ - { + var containsCandidates []string + if len(containFiles) > 0 { + containsCandidates = append(containsCandidates, modifiedPkgs...) + containsCandidates = append(containsCandidates, needPkgs...) + } + if err := state.addNeededOverlayPackages(response, needPkgs); err != nil { + return nil, err + } + // Check candidate packages for containFiles. + if len(containFiles) > 0 { + for _, id := range containsCandidates { + pkg, ok := response.seenPackages[id] + if !ok { + response.addPackage(&Package{ + ID: id, + Errors: []Error{{ Kind: ListError, Msg: fmt.Sprintf("package %s expected but not seen", id), - }, - }, - }) - continue - } - for _, f := range containFiles { - for _, g := range pkg.GoFiles { - if sameFile(f, g) { - response.addRoot(id) + }}, + }) + continue + } + for _, f := range containFiles { + for _, g := range pkg.GoFiles { + if sameFile(f, g) { + response.addRoot(id) + } } } } } - } - // Add root for any package that matches a pattern. This applies only to - // packages that are modified by overlays, since they are not added as - // roots automatically. - for _, pattern := range restPatterns { - match := matchPattern(pattern) - for _, pkgID := range modifiedPkgs { - pkg, ok := response.seenPackages[pkgID] - if !ok { - continue - } - if match(pkg.PkgPath) { - response.addRoot(pkg.ID) + // Add root for any package that matches a pattern. This applies only to + // packages that are modified by overlays, since they are not added as + // roots automatically. + for _, pattern := range restPatterns { + match := matchPattern(pattern) + for _, pkgID := range modifiedPkgs { + pkg, ok := response.seenPackages[pkgID] + if !ok { + continue + } + if match(pkg.PkgPath) { + response.addRoot(pkg.ID) + } } } } @@ -381,32 +384,34 @@ func (state *golistState) adhocPackage(pattern, query string) (*driverResponse, // Fields must match go list; // see $GOROOT/src/cmd/go/internal/load/pkg.go. type jsonPackage struct { - ImportPath string - Dir string - Name string - Export string - GoFiles []string - CompiledGoFiles []string - CFiles []string - CgoFiles []string - CXXFiles []string - MFiles []string - HFiles []string - FFiles []string - SFiles []string - SwigFiles []string - SwigCXXFiles []string - SysoFiles []string - Imports []string - ImportMap map[string]string - Deps []string - Module *Module - TestGoFiles []string - TestImports []string - XTestGoFiles []string - XTestImports []string - ForTest string // q in a "p [q.test]" package, else "" - DepOnly bool + ImportPath string + Dir string + Name string + Export string + GoFiles []string + CompiledGoFiles []string + IgnoredGoFiles []string + IgnoredOtherFiles []string + CFiles []string + CgoFiles []string + CXXFiles []string + MFiles []string + HFiles []string + FFiles []string + SFiles []string + SwigFiles []string + SwigCXXFiles []string + SysoFiles []string + Imports []string + ImportMap map[string]string + Deps []string + Module *Module + TestGoFiles []string + TestImports []string + XTestGoFiles []string + XTestImports []string + ForTest string // q in a "p [q.test]" package, else "" + DepOnly bool Error *jsonPackageError } @@ -558,6 +563,7 @@ func (state *golistState) createDriverResponse(words ...string) (*driverResponse GoFiles: absJoin(p.Dir, p.GoFiles, p.CgoFiles), CompiledGoFiles: absJoin(p.Dir, p.CompiledGoFiles), OtherFiles: absJoin(p.Dir, otherFiles(p)...), + IgnoredFiles: absJoin(p.Dir, p.IgnoredGoFiles, p.IgnoredOtherFiles), forTest: p.ForTest, Module: p.Module, } @@ -728,7 +734,7 @@ func (state *golistState) shouldAddFilenameFromError(p *jsonPackage) bool { // On Go 1.14 and earlier, only add filenames from errors if the import stack is empty. // The import stack behaves differently for these versions than newer Go versions. - if strings.HasPrefix(goV, "go1.13") || strings.HasPrefix(goV, "go1.14") { + if goV < 15 { return len(p.Error.ImportStack) == 0 } @@ -739,31 +745,9 @@ func (state *golistState) shouldAddFilenameFromError(p *jsonPackage) bool { return len(p.Error.ImportStack) == 0 || p.Error.ImportStack[len(p.Error.ImportStack)-1] == p.ImportPath } -func (state *golistState) getGoVersion() (string, error) { +func (state *golistState) getGoVersion() (int, error) { state.goVersionOnce.Do(func() { - var b *bytes.Buffer - // Invoke go version. Don't use invokeGo because it will supply build flags, and - // go version doesn't expect build flags. - inv := gocommand.Invocation{ - Verb: "version", - Env: state.cfg.Env, - Logf: state.cfg.Logf, - } - gocmdRunner := state.cfg.gocmdRunner - if gocmdRunner == nil { - gocmdRunner = &gocommand.Runner{} - } - b, _, _, state.goVersionError = gocmdRunner.RunRaw(state.cfg.Context, inv) - if state.goVersionError != nil { - return - } - - sp := strings.Split(b.String(), " ") - if len(sp) < 3 { - state.goVersionError = fmt.Errorf("go version output: expected 'go version ', got '%s'", b.String()) - return - } - state.goVersion = sp[2] + state.goVersion, state.goVersionError = gocommand.GoVersion(state.ctx, state.cfgInvocation(), state.cfg.gocmdRunner) }) return state.goVersion, state.goVersionError } @@ -836,18 +820,46 @@ func golistargs(cfg *Config, words []string) []string { return fullargs } -// invokeGo returns the stdout of a go command invocation. -func (state *golistState) invokeGo(verb string, args ...string) (*bytes.Buffer, error) { +// cfgInvocation returns an Invocation that reflects cfg's settings. +func (state *golistState) cfgInvocation() gocommand.Invocation { cfg := state.cfg - - inv := gocommand.Invocation{ - Verb: verb, - Args: args, + return gocommand.Invocation{ BuildFlags: cfg.BuildFlags, + ModFile: cfg.modFile, + ModFlag: cfg.modFlag, Env: cfg.Env, Logf: cfg.Logf, WorkingDir: cfg.Dir, } +} + +// invokeGo returns the stdout of a go command invocation. +func (state *golistState) invokeGo(verb string, args ...string) (*bytes.Buffer, error) { + cfg := state.cfg + + inv := state.cfgInvocation() + + // For Go versions 1.16 and above, `go list` accepts overlays directly via + // the -overlay flag. Set it, if it's available. + // + // The check for "list" is not necessarily required, but we should avoid + // getting the go version if possible. + if verb == "list" { + goVersion, err := state.getGoVersion() + if err != nil { + return nil, err + } + if goVersion >= 16 { + filename, cleanup, err := state.writeOverlays() + if err != nil { + return nil, err + } + defer cleanup() + inv.Overlay = filename + } + } + inv.Verb = verb + inv.Args = args gocmdRunner := cfg.gocmdRunner if gocmdRunner == nil { gocmdRunner = &gocommand.Runner{} @@ -987,6 +999,67 @@ func (state *golistState) invokeGo(verb string, args ...string) (*bytes.Buffer, return stdout, nil } +// OverlayJSON is the format overlay files are expected to be in. +// The Replace map maps from overlaid paths to replacement paths: +// the Go command will forward all reads trying to open +// each overlaid path to its replacement path, or consider the overlaid +// path not to exist if the replacement path is empty. +// +// From golang/go#39958. +type OverlayJSON struct { + Replace map[string]string `json:"replace,omitempty"` +} + +// writeOverlays writes out files for go list's -overlay flag, as described +// above. +func (state *golistState) writeOverlays() (filename string, cleanup func(), err error) { + // Do nothing if there are no overlays in the config. + if len(state.cfg.Overlay) == 0 { + return "", func() {}, nil + } + dir, err := ioutil.TempDir("", "gopackages-*") + if err != nil { + return "", nil, err + } + // The caller must clean up this directory, unless this function returns an + // error. + cleanup = func() { + os.RemoveAll(dir) + } + defer func() { + if err != nil { + cleanup() + } + }() + overlays := map[string]string{} + for k, v := range state.cfg.Overlay { + // Create a unique filename for the overlaid files, to avoid + // creating nested directories. + noSeparator := strings.Join(strings.Split(filepath.ToSlash(k), "/"), "") + f, err := ioutil.TempFile(dir, fmt.Sprintf("*-%s", noSeparator)) + if err != nil { + return "", func() {}, err + } + if _, err := f.Write(v); err != nil { + return "", func() {}, err + } + if err := f.Close(); err != nil { + return "", func() {}, err + } + overlays[k] = f.Name() + } + b, err := json.Marshal(OverlayJSON{Replace: overlays}) + if err != nil { + return "", func() {}, err + } + // Write out the overlay file that contains the filepath mappings. + filename = filepath.Join(dir, "overlay.json") + if err := ioutil.WriteFile(filename, b, 0665); err != nil { + return "", func() {}, err + } + return filename, cleanup, nil +} + func containsGoFile(s []string) bool { for _, f := range s { if strings.HasSuffix(f, ".go") { diff --git a/vendor/golang.org/x/tools/go/packages/golist_overlay.go b/vendor/golang.org/x/tools/go/packages/golist_overlay.go index 874f90134..de2c1dc57 100644 --- a/vendor/golang.org/x/tools/go/packages/golist_overlay.go +++ b/vendor/golang.org/x/tools/go/packages/golist_overlay.go @@ -1,3 +1,7 @@ +// Copyright 2018 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. + package packages import ( @@ -253,7 +257,7 @@ func (state *golistState) processGolistOverlay(response *responseDeduper) (modif return modifiedPkgs, needPkgs, err } -// resolveImport finds the the ID of a package given its import path. +// resolveImport finds the ID of a package given its import path. // In particular, it will find the right vendored copy when in GOPATH mode. func (state *golistState) resolveImport(sourceDir, importPath string) (string, error) { env, err := state.getEnv() diff --git a/vendor/golang.org/x/tools/go/packages/packages.go b/vendor/golang.org/x/tools/go/packages/packages.go index 04053f1e7..38475e871 100644 --- a/vendor/golang.org/x/tools/go/packages/packages.go +++ b/vendor/golang.org/x/tools/go/packages/packages.go @@ -144,6 +144,12 @@ type Config struct { // the build system's query tool. BuildFlags []string + // modFile will be used for -modfile in go command invocations. + modFile string + + // modFlag will be used for -modfile in go command invocations. + modFlag string + // Fset provides source position information for syntax trees and types. // If Fset is nil, Load will use a new fileset, but preserve Fset's value. Fset *token.FileSet @@ -289,6 +295,11 @@ type Package struct { // including assembly, C, C++, Fortran, Objective-C, SWIG, and so on. OtherFiles []string + // IgnoredFiles lists source files that are not part of the package + // using the current build configuration but that might be part of + // the package using other build configurations. + IgnoredFiles []string + // ExportFile is the absolute path to a file containing type // information for the package as provided by the build system. ExportFile string @@ -361,6 +372,12 @@ func init() { packagesinternal.SetGoCmdRunner = func(config interface{}, runner *gocommand.Runner) { config.(*Config).gocmdRunner = runner } + packagesinternal.SetModFile = func(config interface{}, value string) { + config.(*Config).modFile = value + } + packagesinternal.SetModFlag = func(config interface{}, value string) { + config.(*Config).modFlag = value + } packagesinternal.TypecheckCgo = int(typecheckCgo) } @@ -404,6 +421,7 @@ type flatPackage struct { GoFiles []string `json:",omitempty"` CompiledGoFiles []string `json:",omitempty"` OtherFiles []string `json:",omitempty"` + IgnoredFiles []string `json:",omitempty"` ExportFile string `json:",omitempty"` Imports map[string]string `json:",omitempty"` } @@ -426,6 +444,7 @@ func (p *Package) MarshalJSON() ([]byte, error) { GoFiles: p.GoFiles, CompiledGoFiles: p.CompiledGoFiles, OtherFiles: p.OtherFiles, + IgnoredFiles: p.IgnoredFiles, ExportFile: p.ExportFile, } if len(p.Imports) > 0 { @@ -712,7 +731,8 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) { result[i] = lpkg.Package } for i := range ld.pkgs { - // Clear all unrequested fields, for extra de-Hyrum-ization. + // Clear all unrequested fields, + // to catch programs that use more than they request. if ld.requestedMode&NeedName == 0 { ld.pkgs[i].Name = "" ld.pkgs[i].PkgPath = "" @@ -720,6 +740,7 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) { if ld.requestedMode&NeedFiles == 0 { ld.pkgs[i].GoFiles = nil ld.pkgs[i].OtherFiles = nil + ld.pkgs[i].IgnoredFiles = nil } if ld.requestedMode&NeedCompiledGoFiles == 0 { ld.pkgs[i].CompiledGoFiles = nil diff --git a/vendor/golang.org/x/tools/internal/gocommand/invoke.go b/vendor/golang.org/x/tools/internal/gocommand/invoke.go index f516e1762..8ba225383 100644 --- a/vendor/golang.org/x/tools/internal/gocommand/invoke.go +++ b/vendor/golang.org/x/tools/internal/gocommand/invoke.go @@ -130,6 +130,9 @@ type Invocation struct { Verb string Args []string BuildFlags []string + ModFlag string + ModFile string + Overlay string Env []string WorkingDir string Logf func(format string, args ...interface{}) @@ -158,17 +161,41 @@ func (i *Invocation) run(ctx context.Context, stdout, stderr io.Writer) error { } goArgs := []string{i.Verb} + + appendModFile := func() { + if i.ModFile != "" { + goArgs = append(goArgs, "-modfile="+i.ModFile) + } + } + appendModFlag := func() { + if i.ModFlag != "" { + goArgs = append(goArgs, "-mod="+i.ModFlag) + } + } + appendOverlayFlag := func() { + if i.Overlay != "" { + goArgs = append(goArgs, "-overlay="+i.Overlay) + } + } + switch i.Verb { - case "mod": - // mod needs the sub-verb before build flags. - goArgs = append(goArgs, i.Args[0]) - goArgs = append(goArgs, i.BuildFlags...) - goArgs = append(goArgs, i.Args[1:]...) - case "env": - // env doesn't take build flags. + case "env", "version": goArgs = append(goArgs, i.Args...) - default: + case "mod": + // mod needs the sub-verb before flags. + goArgs = append(goArgs, i.Args[0]) + appendModFile() + goArgs = append(goArgs, i.Args[1:]...) + case "get": goArgs = append(goArgs, i.BuildFlags...) + appendModFile() + goArgs = append(goArgs, i.Args...) + + default: // notably list and build. + goArgs = append(goArgs, i.BuildFlags...) + appendModFile() + appendModFlag() + appendOverlayFlag() goArgs = append(goArgs, i.Args...) } cmd := exec.Command("go", goArgs...) diff --git a/vendor/golang.org/x/tools/internal/gocommand/version.go b/vendor/golang.org/x/tools/internal/gocommand/version.go new file mode 100644 index 000000000..60d45ac0e --- /dev/null +++ b/vendor/golang.org/x/tools/internal/gocommand/version.go @@ -0,0 +1,40 @@ +// Copyright 2020 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. + +package gocommand + +import ( + "context" + "fmt" + "strings" +) + +// GoVersion checks the go version by running "go list" with modules off. +// It returns the X in Go 1.X. +func GoVersion(ctx context.Context, inv Invocation, r *Runner) (int, error) { + inv.Verb = "list" + inv.Args = []string{"-e", "-f", `{{context.ReleaseTags}}`} + inv.Env = append(append([]string{}, inv.Env...), "GO111MODULE=off") + // Unset any unneeded flags. + inv.ModFile = "" + inv.ModFlag = "" + stdoutBytes, err := r.Run(ctx, inv) + if err != nil { + return 0, err + } + stdout := stdoutBytes.String() + if len(stdout) < 3 { + return 0, fmt.Errorf("bad ReleaseTags output: %q", stdout) + } + // Split up "[go1.1 go1.15]" + tags := strings.Fields(stdout[1 : len(stdout)-2]) + for i := len(tags) - 1; i >= 0; i-- { + var version int + if _, err := fmt.Sscanf(tags[i], "go1.%d", &version); err != nil { + continue + } + return version, nil + } + return 0, fmt.Errorf("no parseable ReleaseTags in %v", tags) +} diff --git a/vendor/golang.org/x/tools/internal/imports/fix.go b/vendor/golang.org/x/tools/internal/imports/fix.go index 675d16c87..d859617b7 100644 --- a/vendor/golang.org/x/tools/internal/imports/fix.go +++ b/vendor/golang.org/x/tools/internal/imports/fix.go @@ -83,7 +83,7 @@ type ImportFix struct { IdentName string // FixType is the type of fix this is (AddImport, DeleteImport, SetImportName). FixType ImportFixType - Relevance int // see pkg + Relevance float64 // see pkg } // An ImportInfo represents a single import statement. @@ -592,9 +592,9 @@ func getFixes(fset *token.FileSet, f *ast.File, filename string, env *ProcessEnv return fixes, nil } -// Highest relevance, used for the standard library. Chosen arbitrarily to -// match pre-existing gopls code. -const MaxRelevance = 7 +// MaxRelevance is the highest relevance, used for the standard library. +// Chosen arbitrarily to match pre-existing gopls code. +const MaxRelevance = 7.0 // getCandidatePkgs works with the passed callback to find all acceptable packages. // It deduplicates by import path, and uses a cached stdlib rather than reading @@ -607,6 +607,10 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena if err != nil { return err } + + var mu sync.Mutex // to guard asynchronous access to dupCheck + dupCheck := map[string]struct{}{} + // Start off with the standard library. for importPath, exports := range stdlib { p := &pkg{ @@ -615,14 +619,12 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena packageName: path.Base(importPath), relevance: MaxRelevance, } + dupCheck[importPath] = struct{}{} if notSelf(p) && wrappedCallback.dirFound(p) && wrappedCallback.packageNameLoaded(p) { wrappedCallback.exportsLoaded(p, exports) } } - var mu sync.Mutex - dupCheck := map[string]struct{}{} - scanFilter := &scanCallback{ rootFound: func(root gopathwalk.Root) bool { // Exclude goroot results -- getting them is relatively expensive, not cached, @@ -658,8 +660,8 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena return resolver.scan(ctx, scanFilter) } -func ScoreImportPaths(ctx context.Context, env *ProcessEnv, paths []string) (map[string]int, error) { - result := make(map[string]int) +func ScoreImportPaths(ctx context.Context, env *ProcessEnv, paths []string) (map[string]float64, error) { + result := make(map[string]float64) resolver, err := env.GetResolver() if err != nil { return nil, err @@ -802,6 +804,8 @@ type ProcessEnv struct { GocmdRunner *gocommand.Runner BuildFlags []string + ModFlag string + ModFile string // Env overrides the OS environment, and can be used to specify // GOPROXY, GO111MODULE, etc. PATH cannot be set here, because @@ -995,7 +999,7 @@ type Resolver interface { // loadExports may be called concurrently. loadExports(ctx context.Context, pkg *pkg, includeTest bool) (string, []string, error) // scoreImportPath returns the relevance for an import path. - scoreImportPath(ctx context.Context, path string) int + scoreImportPath(ctx context.Context, path string) float64 ClearForNewScan() } @@ -1260,10 +1264,10 @@ func packageDirToName(dir string) (packageName string, err error) { } type pkg struct { - dir string // absolute file path to pkg directory ("/usr/lib/go/src/net/http") - importPathShort string // vendorless import path ("net/http", "a/b") - packageName string // package name loaded from source if requested - relevance int // a weakly-defined score of how relevant a package is. 0 is most relevant. + dir string // absolute file path to pkg directory ("/usr/lib/go/src/net/http") + importPathShort string // vendorless import path ("net/http", "a/b") + packageName string // package name loaded from source if requested + relevance float64 // a weakly-defined score of how relevant a package is. 0 is most relevant. } type pkgDistance struct { @@ -1389,7 +1393,7 @@ func (r *gopathResolver) scan(ctx context.Context, callback *scanCallback) error return nil } -func (r *gopathResolver) scoreImportPath(ctx context.Context, path string) int { +func (r *gopathResolver) scoreImportPath(ctx context.Context, path string) float64 { if _, ok := stdlib[path]; ok { return MaxRelevance } diff --git a/vendor/golang.org/x/tools/internal/imports/mod.go b/vendor/golang.org/x/tools/internal/imports/mod.go index 94880d616..73f7a4958 100644 --- a/vendor/golang.org/x/tools/internal/imports/mod.go +++ b/vendor/golang.org/x/tools/internal/imports/mod.go @@ -59,6 +59,8 @@ func (r *ModuleResolver) init() error { } inv := gocommand.Invocation{ BuildFlags: r.env.BuildFlags, + ModFlag: r.env.ModFlag, + ModFile: r.env.ModFile, Env: r.env.env(), Logf: r.env.Logf, WorkingDir: r.env.WorkingDir, @@ -345,10 +347,11 @@ func (r *ModuleResolver) modInfo(dir string) (modDir string, modName string) { } if r.dirInModuleCache(dir) { - matches := modCacheRegexp.FindStringSubmatch(dir) - index := strings.Index(dir, matches[1]+"@"+matches[2]) - modDir := filepath.Join(dir[:index], matches[1]+"@"+matches[2]) - return modDir, readModName(filepath.Join(modDir, "go.mod")) + if matches := modCacheRegexp.FindStringSubmatch(dir); len(matches) == 3 { + index := strings.Index(dir, matches[1]+"@"+matches[2]) + modDir := filepath.Join(dir[:index], matches[1]+"@"+matches[2]) + return modDir, readModName(filepath.Join(modDir, "go.mod")) + } } for { if info, ok := r.cacheLoad(dir); ok { @@ -487,7 +490,7 @@ func (r *ModuleResolver) scan(ctx context.Context, callback *scanCallback) error return nil } -func (r *ModuleResolver) scoreImportPath(ctx context.Context, path string) int { +func (r *ModuleResolver) scoreImportPath(ctx context.Context, path string) float64 { if _, ok := stdlib[path]; ok { return MaxRelevance } @@ -495,17 +498,31 @@ func (r *ModuleResolver) scoreImportPath(ctx context.Context, path string) int { return modRelevance(mod) } -func modRelevance(mod *gocommand.ModuleJSON) int { +func modRelevance(mod *gocommand.ModuleJSON) float64 { + var relevance float64 switch { case mod == nil: // out of scope return MaxRelevance - 4 case mod.Indirect: - return MaxRelevance - 3 + relevance = MaxRelevance - 3 case !mod.Main: - return MaxRelevance - 2 + relevance = MaxRelevance - 2 default: - return MaxRelevance - 1 // main module ties with stdlib + relevance = MaxRelevance - 1 // main module ties with stdlib } + + _, versionString, ok := module.SplitPathVersion(mod.Path) + if ok { + index := strings.Index(versionString, "v") + if index == -1 { + return relevance + } + if versionNumber, err := strconv.ParseFloat(versionString[index+1:], 64); err == nil { + relevance += versionNumber / 1000 + } + } + + return relevance } // canonicalize gets the result of canonicalizing the packages using the results diff --git a/vendor/golang.org/x/tools/internal/packagesinternal/packages.go b/vendor/golang.org/x/tools/internal/packagesinternal/packages.go index 2c4527f24..1335a5eed 100644 --- a/vendor/golang.org/x/tools/internal/packagesinternal/packages.go +++ b/vendor/golang.org/x/tools/internal/packagesinternal/packages.go @@ -12,3 +12,6 @@ var GetGoCmdRunner = func(config interface{}) *gocommand.Runner { return nil } var SetGoCmdRunner = func(config interface{}, runner *gocommand.Runner) {} var TypecheckCgo int + +var SetModFlag = func(config interface{}, value string) {} +var SetModFile = func(config interface{}, value string) {} diff --git a/vendor/golang.org/x/tools/internal/typesinternal/errorcode.go b/vendor/golang.org/x/tools/internal/typesinternal/errorcode.go new file mode 100644 index 000000000..65473eb22 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typesinternal/errorcode.go @@ -0,0 +1,1358 @@ +// Copyright 2020 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. + +package typesinternal + +//go:generate stringer -type=ErrorCode + +type ErrorCode int + +// This file defines the error codes that can be produced during type-checking. +// Collectively, these codes provide an identifier that may be used to +// implement special handling for certain types of errors. +// +// Error codes should be fine-grained enough that the exact nature of the error +// can be easily determined, but coarse enough that they are not an +// implementation detail of the type checking algorithm. As a rule-of-thumb, +// errors should be considered equivalent if there is a theoretical refactoring +// of the type checker in which they are emitted in exactly one place. For +// example, the type checker emits different error messages for "too many +// arguments" and "too few arguments", but one can imagine an alternative type +// checker where this check instead just emits a single "wrong number of +// arguments", so these errors should have the same code. +// +// Error code names should be as brief as possible while retaining accuracy and +// distinctiveness. In most cases names should start with an adjective +// describing the nature of the error (e.g. "invalid", "unused", "misplaced"), +// and end with a noun identifying the relevant language object. For example, +// "DuplicateDecl" or "InvalidSliceExpr". For brevity, naming follows the +// convention that "bad" implies a problem with syntax, and "invalid" implies a +// problem with types. + +const ( + _ ErrorCode = iota + + // Test is reserved for errors that only apply while in self-test mode. + Test + + /* package names */ + + // BlankPkgName occurs when a package name is the blank identifier "_". + // + // Per the spec: + // "The PackageName must not be the blank identifier." + BlankPkgName + + // MismatchedPkgName occurs when a file's package name doesn't match the + // package name already established by other files. + MismatchedPkgName + + // InvalidPkgUse occurs when a package identifier is used outside of a + // selector expression. + // + // Example: + // import "fmt" + // + // var _ = fmt + InvalidPkgUse + + /* imports */ + + // BadImportPath occurs when an import path is not valid. + BadImportPath + + // BrokenImport occurs when importing a package fails. + // + // Example: + // import "amissingpackage" + BrokenImport + + // ImportCRenamed occurs when the special import "C" is renamed. "C" is a + // pseudo-package, and must not be renamed. + // + // Example: + // import _ "C" + ImportCRenamed + + // UnusedImport occurs when an import is unused. + // + // Example: + // import "fmt" + // + // func main() {} + UnusedImport + + /* initialization */ + + // InvalidInitCycle occurs when an invalid cycle is detected within the + // initialization graph. + // + // Example: + // var x int = f() + // + // func f() int { return x } + InvalidInitCycle + + /* decls */ + + // DuplicateDecl occurs when an identifier is declared multiple times. + // + // Example: + // var x = 1 + // var x = 2 + DuplicateDecl + + // InvalidDeclCycle occurs when a declaration cycle is not valid. + // + // Example: + // import "unsafe" + // + // type T struct { + // a [n]int + // } + // + // var n = unsafe.Sizeof(T{}) + InvalidDeclCycle + + // InvalidTypeCycle occurs when a cycle in type definitions results in a + // type that is not well-defined. + // + // Example: + // import "unsafe" + // + // type T [unsafe.Sizeof(T{})]int + InvalidTypeCycle + + /* decls > const */ + + // InvalidConstInit occurs when a const declaration has a non-constant + // initializer. + // + // Example: + // var x int + // const _ = x + InvalidConstInit + + // InvalidConstVal occurs when a const value cannot be converted to its + // target type. + // + // TODO(findleyr): this error code and example are not very clear. Consider + // removing it. + // + // Example: + // const _ = 1 << "hello" + InvalidConstVal + + // InvalidConstType occurs when the underlying type in a const declaration + // is not a valid constant type. + // + // Example: + // const c *int = 4 + InvalidConstType + + /* decls > var (+ other variable assignment codes) */ + + // UntypedNil occurs when the predeclared (untyped) value nil is used to + // initialize a variable declared without an explicit type. + // + // Example: + // var x = nil + UntypedNil + + // WrongAssignCount occurs when the number of values on the right-hand side + // of an assignment or or initialization expression does not match the number + // of variables on the left-hand side. + // + // Example: + // var x = 1, 2 + WrongAssignCount + + // UnassignableOperand occurs when the left-hand side of an assignment is + // not assignable. + // + // Example: + // func f() { + // const c = 1 + // c = 2 + // } + UnassignableOperand + + // NoNewVar occurs when a short variable declaration (':=') does not declare + // new variables. + // + // Example: + // func f() { + // x := 1 + // x := 2 + // } + NoNewVar + + // MultiValAssignOp occurs when an assignment operation (+=, *=, etc) does + // not have single-valued left-hand or right-hand side. + // + // Per the spec: + // "In assignment operations, both the left- and right-hand expression lists + // must contain exactly one single-valued expression" + // + // Example: + // func f() int { + // x, y := 1, 2 + // x, y += 1 + // return x + y + // } + MultiValAssignOp + + // InvalidIfaceAssign occurs when a value of type T is used as an + // interface, but T does not implement a method of the expected interface. + // + // Example: + // type I interface { + // f() + // } + // + // type T int + // + // var x I = T(1) + InvalidIfaceAssign + + // InvalidChanAssign occurs when a chan assignment is invalid. + // + // Per the spec, a value x is assignable to a channel type T if: + // "x is a bidirectional channel value, T is a channel type, x's type V and + // T have identical element types, and at least one of V or T is not a + // defined type." + // + // Example: + // type T1 chan int + // type T2 chan int + // + // var x T1 + // // Invalid assignment because both types are named + // var _ T2 = x + InvalidChanAssign + + // IncompatibleAssign occurs when the type of the right-hand side expression + // in an assignment cannot be assigned to the type of the variable being + // assigned. + // + // Example: + // var x []int + // var _ int = x + IncompatibleAssign + + // UnaddressableFieldAssign occurs when trying to assign to a struct field + // in a map value. + // + // Example: + // func f() { + // m := make(map[string]struct{i int}) + // m["foo"].i = 42 + // } + UnaddressableFieldAssign + + /* decls > type (+ other type expression codes) */ + + // NotAType occurs when the identifier used as the underlying type in a type + // declaration or the right-hand side of a type alias does not denote a type. + // + // Example: + // var S = 2 + // + // type T S + NotAType + + // InvalidArrayLen occurs when an array length is not a constant value. + // + // Example: + // var n = 3 + // var _ = [n]int{} + InvalidArrayLen + + // BlankIfaceMethod occurs when a method name is '_'. + // + // Per the spec: + // "The name of each explicitly specified method must be unique and not + // blank." + // + // Example: + // type T interface { + // _(int) + // } + BlankIfaceMethod + + // IncomparableMapKey occurs when a map key type does not support the == and + // != operators. + // + // Per the spec: + // "The comparison operators == and != must be fully defined for operands of + // the key type; thus the key type must not be a function, map, or slice." + // + // Example: + // var x map[T]int + // + // type T []int + IncomparableMapKey + + // InvalidIfaceEmbed occurs when a non-interface type is embedded in an + // interface. + // + // Example: + // type T struct {} + // + // func (T) m() + // + // type I interface { + // T + // } + InvalidIfaceEmbed + + // InvalidPtrEmbed occurs when an embedded field is of the pointer form *T, + // and T itself is itself a pointer, an unsafe.Pointer, or an interface. + // + // Per the spec: + // "An embedded field must be specified as a type name T or as a pointer to + // a non-interface type name *T, and T itself may not be a pointer type." + // + // Example: + // type T *int + // + // type S struct { + // *T + // } + InvalidPtrEmbed + + /* decls > func and method */ + + // BadRecv occurs when a method declaration does not have exactly one + // receiver parameter. + // + // Example: + // func () _() {} + BadRecv + + // InvalidRecv occurs when a receiver type expression is not of the form T + // or *T, or T is a pointer type. + // + // Example: + // type T struct {} + // + // func (**T) m() {} + InvalidRecv + + // DuplicateFieldAndMethod occurs when an identifier appears as both a field + // and method name. + // + // Example: + // type T struct { + // m int + // } + // + // func (T) m() {} + DuplicateFieldAndMethod + + // DuplicateMethod occurs when two methods on the same receiver type have + // the same name. + // + // Example: + // type T struct {} + // func (T) m() {} + // func (T) m(i int) int { return i } + DuplicateMethod + + /* decls > special */ + + // InvalidBlank occurs when a blank identifier is used as a value or type. + // + // Per the spec: + // "The blank identifier may appear as an operand only on the left-hand side + // of an assignment." + // + // Example: + // var x = _ + InvalidBlank + + // InvalidIota occurs when the predeclared identifier iota is used outside + // of a constant declaration. + // + // Example: + // var x = iota + InvalidIota + + // MissingInitBody occurs when an init function is missing its body. + // + // Example: + // func init() + MissingInitBody + + // InvalidInitSig occurs when an init function declares parameters or + // results. + // + // Example: + // func init() int { return 1 } + InvalidInitSig + + // InvalidInitDecl occurs when init is declared as anything other than a + // function. + // + // Example: + // var init = 1 + InvalidInitDecl + + // InvalidMainDecl occurs when main is declared as anything other than a + // function, in a main package. + InvalidMainDecl + + /* exprs */ + + // TooManyValues occurs when a function returns too many values for the + // expression context in which it is used. + // + // Example: + // func ReturnTwo() (int, int) { + // return 1, 2 + // } + // + // var x = ReturnTwo() + TooManyValues + + // NotAnExpr occurs when a type expression is used where a value expression + // is expected. + // + // Example: + // type T struct {} + // + // func f() { + // T + // } + NotAnExpr + + /* exprs > const */ + + // TruncatedFloat occurs when a float constant is truncated to an integer + // value. + // + // Example: + // var _ int = 98.6 + TruncatedFloat + + // NumericOverflow occurs when a numeric constant overflows its target type. + // + // Example: + // var x int8 = 1000 + NumericOverflow + + /* exprs > operation */ + + // UndefinedOp occurs when an operator is not defined for the type(s) used + // in an operation. + // + // Example: + // var c = "a" - "b" + UndefinedOp + + // MismatchedTypes occurs when operand types are incompatible in a binary + // operation. + // + // Example: + // var a = "hello" + // var b = 1 + // var c = a - b + MismatchedTypes + + // DivByZero occurs when a division operation is provable at compile + // time to be a division by zero. + // + // Example: + // const divisor = 0 + // var x int = 1/divisor + DivByZero + + // NonNumericIncDec occurs when an increment or decrement operator is + // applied to a non-numeric value. + // + // Example: + // func f() { + // var c = "c" + // c++ + // } + NonNumericIncDec + + /* exprs > ptr */ + + // UnaddressableOperand occurs when the & operator is applied to an + // unaddressable expression. + // + // Example: + // var x = &1 + UnaddressableOperand + + // InvalidIndirection occurs when a non-pointer value is indirected via the + // '*' operator. + // + // Example: + // var x int + // var y = *x + InvalidIndirection + + /* exprs > [] */ + + // NonIndexableOperand occurs when an index operation is applied to a value + // that cannot be indexed. + // + // Example: + // var x = 1 + // var y = x[1] + NonIndexableOperand + + // InvalidIndex occurs when an index argument is not of integer type, + // negative, or out-of-bounds. + // + // Example: + // var s = [...]int{1,2,3} + // var x = s[5] + // + // Example: + // var s = []int{1,2,3} + // var _ = s[-1] + // + // Example: + // var s = []int{1,2,3} + // var i string + // var _ = s[i] + InvalidIndex + + // SwappedSliceIndices occurs when constant indices in a slice expression + // are decreasing in value. + // + // Example: + // var _ = []int{1,2,3}[2:1] + SwappedSliceIndices + + /* operators > slice */ + + // NonSliceableOperand occurs when a slice operation is applied to a value + // whose type is not sliceable, or is unaddressable. + // + // Example: + // var x = [...]int{1, 2, 3}[:1] + // + // Example: + // var x = 1 + // var y = 1[:1] + NonSliceableOperand + + // InvalidSliceExpr occurs when a three-index slice expression (a[x:y:z]) is + // applied to a string. + // + // Example: + // var s = "hello" + // var x = s[1:2:3] + InvalidSliceExpr + + /* exprs > shift */ + + // InvalidShiftCount occurs when the right-hand side of a shift operation is + // either non-integer, negative, or too large. + // + // Example: + // var ( + // x string + // y int = 1 << x + // ) + InvalidShiftCount + + // InvalidShiftOperand occurs when the shifted operand is not an integer. + // + // Example: + // var s = "hello" + // var x = s << 2 + InvalidShiftOperand + + /* exprs > chan */ + + // InvalidReceive occurs when there is a channel receive from a value that + // is either not a channel, or is a send-only channel. + // + // Example: + // func f() { + // var x = 1 + // <-x + // } + InvalidReceive + + // InvalidSend occurs when there is a channel send to a value that is not a + // channel, or is a receive-only channel. + // + // Example: + // func f() { + // var x = 1 + // x <- "hello!" + // } + InvalidSend + + /* exprs > literal */ + + // DuplicateLitKey occurs when an index is duplicated in a slice, array, or + // map literal. + // + // Example: + // var _ = []int{0:1, 0:2} + // + // Example: + // var _ = map[string]int{"a": 1, "a": 2} + DuplicateLitKey + + // MissingLitKey occurs when a map literal is missing a key expression. + // + // Example: + // var _ = map[string]int{1} + MissingLitKey + + // InvalidLitIndex occurs when the key in a key-value element of a slice or + // array literal is not an integer constant. + // + // Example: + // var i = 0 + // var x = []string{i: "world"} + InvalidLitIndex + + // OversizeArrayLit occurs when an array literal exceeds its length. + // + // Example: + // var _ = [2]int{1,2,3} + OversizeArrayLit + + // MixedStructLit occurs when a struct literal contains a mix of positional + // and named elements. + // + // Example: + // var _ = struct{i, j int}{i: 1, 2} + MixedStructLit + + // InvalidStructLit occurs when a positional struct literal has an incorrect + // number of values. + // + // Example: + // var _ = struct{i, j int}{1,2,3} + InvalidStructLit + + // MissingLitField occurs when a struct literal refers to a field that does + // not exist on the struct type. + // + // Example: + // var _ = struct{i int}{j: 2} + MissingLitField + + // DuplicateLitField occurs when a struct literal contains duplicated + // fields. + // + // Example: + // var _ = struct{i int}{i: 1, i: 2} + DuplicateLitField + + // UnexportedLitField occurs when a positional struct literal implicitly + // assigns an unexported field of an imported type. + UnexportedLitField + + // InvalidLitField occurs when a field name is not a valid identifier. + // + // Example: + // var _ = struct{i int}{1: 1} + InvalidLitField + + // UntypedLit occurs when a composite literal omits a required type + // identifier. + // + // Example: + // type outer struct{ + // inner struct { i int } + // } + // + // var _ = outer{inner: {1}} + UntypedLit + + // InvalidLit occurs when a composite literal expression does not match its + // type. + // + // Example: + // type P *struct{ + // x int + // } + // var _ = P {} + InvalidLit + + /* exprs > selector */ + + // AmbiguousSelector occurs when a selector is ambiguous. + // + // Example: + // type E1 struct { i int } + // type E2 struct { i int } + // type T struct { E1; E2 } + // + // var x T + // var _ = x.i + AmbiguousSelector + + // UndeclaredImportedName occurs when a package-qualified identifier is + // undeclared by the imported package. + // + // Example: + // import "go/types" + // + // var _ = types.NotAnActualIdentifier + UndeclaredImportedName + + // UnexportedName occurs when a selector refers to an unexported identifier + // of an imported package. + // + // Example: + // import "reflect" + // + // type _ reflect.flag + UnexportedName + + // UndeclaredName occurs when an identifier is not declared in the current + // scope. + // + // Example: + // var x T + UndeclaredName + + // MissingFieldOrMethod occurs when a selector references a field or method + // that does not exist. + // + // Example: + // type T struct {} + // + // var x = T{}.f + MissingFieldOrMethod + + /* exprs > ... */ + + // BadDotDotDotSyntax occurs when a "..." occurs in a context where it is + // not valid. + // + // Example: + // var _ = map[int][...]int{0: {}} + BadDotDotDotSyntax + + // NonVariadicDotDotDot occurs when a "..." is used on the final argument to + // a non-variadic function. + // + // Example: + // func printArgs(s []string) { + // for _, a := range s { + // println(a) + // } + // } + // + // func f() { + // s := []string{"a", "b", "c"} + // printArgs(s...) + // } + NonVariadicDotDotDot + + // MisplacedDotDotDot occurs when a "..." is used somewhere other than the + // final argument to a function call. + // + // Example: + // func printArgs(args ...int) { + // for _, a := range args { + // println(a) + // } + // } + // + // func f() { + // a := []int{1,2,3} + // printArgs(0, a...) + // } + MisplacedDotDotDot + + // InvalidDotDotDotOperand occurs when a "..." operator is applied to a + // single-valued operand. + // + // Example: + // func printArgs(args ...int) { + // for _, a := range args { + // println(a) + // } + // } + // + // func f() { + // a := 1 + // printArgs(a...) + // } + // + // Example: + // func args() (int, int) { + // return 1, 2 + // } + // + // func printArgs(args ...int) { + // for _, a := range args { + // println(a) + // } + // } + // + // func g() { + // printArgs(args()...) + // } + InvalidDotDotDotOperand + + // InvalidDotDotDot occurs when a "..." is used in a non-variadic built-in + // function. + // + // Example: + // var s = []int{1, 2, 3} + // var l = len(s...) + InvalidDotDotDot + + /* exprs > built-in */ + + // UncalledBuiltin occurs when a built-in function is used as a + // function-valued expression, instead of being called. + // + // Per the spec: + // "The built-in functions do not have standard Go types, so they can only + // appear in call expressions; they cannot be used as function values." + // + // Example: + // var _ = copy + UncalledBuiltin + + // InvalidAppend occurs when append is called with a first argument that is + // not a slice. + // + // Example: + // var _ = append(1, 2) + InvalidAppend + + // InvalidCap occurs when an argument to the cap built-in function is not of + // supported type. + // + // See https://golang.org/ref/spec#Lengthand_capacity for information on + // which underlying types are supported as arguments to cap and len. + // + // Example: + // var s = 2 + // var x = cap(s) + InvalidCap + + // InvalidClose occurs when close(...) is called with an argument that is + // not of channel type, or that is a receive-only channel. + // + // Example: + // func f() { + // var x int + // close(x) + // } + InvalidClose + + // InvalidCopy occurs when the arguments are not of slice type or do not + // have compatible type. + // + // See https://golang.org/ref/spec#Appendingand_copying_slices for more + // information on the type requirements for the copy built-in. + // + // Example: + // func f() { + // var x []int + // y := []int64{1,2,3} + // copy(x, y) + // } + InvalidCopy + + // InvalidComplex occurs when the complex built-in function is called with + // arguments with incompatible types. + // + // Example: + // var _ = complex(float32(1), float64(2)) + InvalidComplex + + // InvalidDelete occurs when the delete built-in function is called with a + // first argument that is not a map. + // + // Example: + // func f() { + // m := "hello" + // delete(m, "e") + // } + InvalidDelete + + // InvalidImag occurs when the imag built-in function is called with an + // argument that does not have complex type. + // + // Example: + // var _ = imag(int(1)) + InvalidImag + + // InvalidLen occurs when an argument to the len built-in function is not of + // supported type. + // + // See https://golang.org/ref/spec#Lengthand_capacity for information on + // which underlying types are supported as arguments to cap and len. + // + // Example: + // var s = 2 + // var x = len(s) + InvalidLen + + // SwappedMakeArgs occurs when make is called with three arguments, and its + // length argument is larger than its capacity argument. + // + // Example: + // var x = make([]int, 3, 2) + SwappedMakeArgs + + // InvalidMake occurs when make is called with an unsupported type argument. + // + // See https://golang.org/ref/spec#Makingslices_maps_and_channels for + // information on the types that may be created using make. + // + // Example: + // var x = make(int) + InvalidMake + + // InvalidReal occurs when the real built-in function is called with an + // argument that does not have complex type. + // + // Example: + // var _ = real(int(1)) + InvalidReal + + /* exprs > assertion */ + + // InvalidAssert occurs when a type assertion is applied to a + // value that is not of interface type. + // + // Example: + // var x = 1 + // var _ = x.(float64) + InvalidAssert + + // ImpossibleAssert occurs for a type assertion x.(T) when the value x of + // interface cannot have dynamic type T, due to a missing or mismatching + // method on T. + // + // Example: + // type T int + // + // func (t *T) m() int { return int(*t) } + // + // type I interface { m() int } + // + // var x I + // var _ = x.(T) + ImpossibleAssert + + /* exprs > conversion */ + + // InvalidConversion occurs when the argument type cannot be converted to the + // target. + // + // See https://golang.org/ref/spec#Conversions for the rules of + // convertibility. + // + // Example: + // var x float64 + // var _ = string(x) + InvalidConversion + + // InvalidUntypedConversion occurs when an there is no valid implicit + // conversion from an untyped value satisfying the type constraints of the + // context in which it is used. + // + // Example: + // var _ = 1 + "" + InvalidUntypedConversion + + /* offsetof */ + + // BadOffsetofSyntax occurs when unsafe.Offsetof is called with an argument + // that is not a selector expression. + // + // Example: + // import "unsafe" + // + // var x int + // var _ = unsafe.Offsetof(x) + BadOffsetofSyntax + + // InvalidOffsetof occurs when unsafe.Offsetof is called with a method + // selector, rather than a field selector, or when the field is embedded via + // a pointer. + // + // Per the spec: + // + // "If f is an embedded field, it must be reachable without pointer + // indirections through fields of the struct. " + // + // Example: + // import "unsafe" + // + // type T struct { f int } + // type S struct { *T } + // var s S + // var _ = unsafe.Offsetof(s.f) + // + // Example: + // import "unsafe" + // + // type S struct{} + // + // func (S) m() {} + // + // var s S + // var _ = unsafe.Offsetof(s.m) + InvalidOffsetof + + /* control flow > scope */ + + // UnusedExpr occurs when a side-effect free expression is used as a + // statement. Such a statement has no effect. + // + // Example: + // func f(i int) { + // i*i + // } + UnusedExpr + + // UnusedVar occurs when a variable is declared but unused. + // + // Example: + // func f() { + // x := 1 + // } + UnusedVar + + // MissingReturn occurs when a function with results is missing a return + // statement. + // + // Example: + // func f() int {} + MissingReturn + + // WrongResultCount occurs when a return statement returns an incorrect + // number of values. + // + // Example: + // func ReturnOne() int { + // return 1, 2 + // } + WrongResultCount + + // OutOfScopeResult occurs when the name of a value implicitly returned by + // an empty return statement is shadowed in a nested scope. + // + // Example: + // func factor(n int) (i int) { + // for i := 2; i < n; i++ { + // if n%i == 0 { + // return + // } + // } + // return 0 + // } + OutOfScopeResult + + /* control flow > if */ + + // InvalidCond occurs when an if condition is not a boolean expression. + // + // Example: + // func checkReturn(i int) { + // if i { + // panic("non-zero return") + // } + // } + InvalidCond + + /* control flow > for */ + + // InvalidPostDecl occurs when there is a declaration in a for-loop post + // statement. + // + // Example: + // func f() { + // for i := 0; i < 10; j := 0 {} + // } + InvalidPostDecl + + // InvalidChanRange occurs when a send-only channel used in a range + // expression. + // + // Example: + // func sum(c chan<- int) { + // s := 0 + // for i := range c { + // s += i + // } + // } + InvalidChanRange + + // InvalidIterVar occurs when two iteration variables are used while ranging + // over a channel. + // + // Example: + // func f(c chan int) { + // for k, v := range c { + // println(k, v) + // } + // } + InvalidIterVar + + // InvalidRangeExpr occurs when the type of a range expression is not array, + // slice, string, map, or channel. + // + // Example: + // func f(i int) { + // for j := range i { + // println(j) + // } + // } + InvalidRangeExpr + + /* control flow > switch */ + + // MisplacedBreak occurs when a break statement is not within a for, switch, + // or select statement of the innermost function definition. + // + // Example: + // func f() { + // break + // } + MisplacedBreak + + // MisplacedContinue occurs when a continue statement is not within a for + // loop of the innermost function definition. + // + // Example: + // func sumeven(n int) int { + // proceed := func() { + // continue + // } + // sum := 0 + // for i := 1; i <= n; i++ { + // if i % 2 != 0 { + // proceed() + // } + // sum += i + // } + // return sum + // } + MisplacedContinue + + // MisplacedFallthrough occurs when a fallthrough statement is not within an + // expression switch. + // + // Example: + // func typename(i interface{}) string { + // switch i.(type) { + // case int64: + // fallthrough + // case int: + // return "int" + // } + // return "unsupported" + // } + MisplacedFallthrough + + // DuplicateCase occurs when a type or expression switch has duplicate + // cases. + // + // Example: + // func printInt(i int) { + // switch i { + // case 1: + // println("one") + // case 1: + // println("One") + // } + // } + DuplicateCase + + // DuplicateDefault occurs when a type or expression switch has multiple + // default clauses. + // + // Example: + // func printInt(i int) { + // switch i { + // case 1: + // println("one") + // default: + // println("One") + // default: + // println("1") + // } + // } + DuplicateDefault + + // BadTypeKeyword occurs when a .(type) expression is used anywhere other + // than a type switch. + // + // Example: + // type I interface { + // m() + // } + // var t I + // var _ = t.(type) + BadTypeKeyword + + // InvalidTypeSwitch occurs when .(type) is used on an expression that is + // not of interface type. + // + // Example: + // func f(i int) { + // switch x := i.(type) {} + // } + InvalidTypeSwitch + + /* control flow > select */ + + // InvalidSelectCase occurs when a select case is not a channel send or + // receive. + // + // Example: + // func checkChan(c <-chan int) bool { + // select { + // case c: + // return true + // default: + // return false + // } + // } + InvalidSelectCase + + /* control flow > labels and jumps */ + + // UndeclaredLabel occurs when an undeclared label is jumped to. + // + // Example: + // func f() { + // goto L + // } + UndeclaredLabel + + // DuplicateLabel occurs when a label is declared more than once. + // + // Example: + // func f() int { + // L: + // L: + // return 1 + // } + DuplicateLabel + + // MisplacedLabel occurs when a break or continue label is not on a for, + // switch, or select statement. + // + // Example: + // func f() { + // L: + // a := []int{1,2,3} + // for _, e := range a { + // if e > 10 { + // break L + // } + // println(a) + // } + // } + MisplacedLabel + + // UnusedLabel occurs when a label is declared but not used. + // + // Example: + // func f() { + // L: + // } + UnusedLabel + + // JumpOverDecl occurs when a label jumps over a variable declaration. + // + // Example: + // func f() int { + // goto L + // x := 2 + // L: + // x++ + // return x + // } + JumpOverDecl + + // JumpIntoBlock occurs when a forward jump goes to a label inside a nested + // block. + // + // Example: + // func f(x int) { + // goto L + // if x > 0 { + // L: + // print("inside block") + // } + // } + JumpIntoBlock + + /* control flow > calls */ + + // InvalidMethodExpr occurs when a pointer method is called but the argument + // is not addressable. + // + // Example: + // type T struct {} + // + // func (*T) m() int { return 1 } + // + // var _ = T.m(T{}) + InvalidMethodExpr + + // WrongArgCount occurs when too few or too many arguments are passed by a + // function call. + // + // Example: + // func f(i int) {} + // var x = f() + WrongArgCount + + // InvalidCall occurs when an expression is called that is not of function + // type. + // + // Example: + // var x = "x" + // var y = x() + InvalidCall + + /* control flow > suspended */ + + // UnusedResults occurs when a restricted expression-only built-in function + // is suspended via go or defer. Such a suspension discards the results of + // these side-effect free built-in functions, and therefore is ineffectual. + // + // Example: + // func f(a []int) int { + // defer len(a) + // return i + // } + UnusedResults + + // InvalidDefer occurs when a deferred expression is not a function call, + // for example if the expression is a type conversion. + // + // Example: + // func f(i int) int { + // defer int32(i) + // return i + // } + InvalidDefer + + // InvalidGo occurs when a go expression is not a function call, for example + // if the expression is a type conversion. + // + // Example: + // func f(i int) int { + // go int32(i) + // return i + // } + InvalidGo +) diff --git a/vendor/golang.org/x/tools/internal/typesinternal/errorcode_string.go b/vendor/golang.org/x/tools/internal/typesinternal/errorcode_string.go new file mode 100644 index 000000000..97f3ec891 --- /dev/null +++ b/vendor/golang.org/x/tools/internal/typesinternal/errorcode_string.go @@ -0,0 +1,152 @@ +// Code generated by "stringer -type=ErrorCode"; DO NOT EDIT. + +package typesinternal + +import "strconv" + +func _() { + // An "invalid array index" compiler error signifies that the constant values have changed. + // Re-run the stringer command to generate them again. + var x [1]struct{} + _ = x[Test-1] + _ = x[BlankPkgName-2] + _ = x[MismatchedPkgName-3] + _ = x[InvalidPkgUse-4] + _ = x[BadImportPath-5] + _ = x[BrokenImport-6] + _ = x[ImportCRenamed-7] + _ = x[UnusedImport-8] + _ = x[InvalidInitCycle-9] + _ = x[DuplicateDecl-10] + _ = x[InvalidDeclCycle-11] + _ = x[InvalidTypeCycle-12] + _ = x[InvalidConstInit-13] + _ = x[InvalidConstVal-14] + _ = x[InvalidConstType-15] + _ = x[UntypedNil-16] + _ = x[WrongAssignCount-17] + _ = x[UnassignableOperand-18] + _ = x[NoNewVar-19] + _ = x[MultiValAssignOp-20] + _ = x[InvalidIfaceAssign-21] + _ = x[InvalidChanAssign-22] + _ = x[IncompatibleAssign-23] + _ = x[UnaddressableFieldAssign-24] + _ = x[NotAType-25] + _ = x[InvalidArrayLen-26] + _ = x[BlankIfaceMethod-27] + _ = x[IncomparableMapKey-28] + _ = x[InvalidIfaceEmbed-29] + _ = x[InvalidPtrEmbed-30] + _ = x[BadRecv-31] + _ = x[InvalidRecv-32] + _ = x[DuplicateFieldAndMethod-33] + _ = x[DuplicateMethod-34] + _ = x[InvalidBlank-35] + _ = x[InvalidIota-36] + _ = x[MissingInitBody-37] + _ = x[InvalidInitSig-38] + _ = x[InvalidInitDecl-39] + _ = x[InvalidMainDecl-40] + _ = x[TooManyValues-41] + _ = x[NotAnExpr-42] + _ = x[TruncatedFloat-43] + _ = x[NumericOverflow-44] + _ = x[UndefinedOp-45] + _ = x[MismatchedTypes-46] + _ = x[DivByZero-47] + _ = x[NonNumericIncDec-48] + _ = x[UnaddressableOperand-49] + _ = x[InvalidIndirection-50] + _ = x[NonIndexableOperand-51] + _ = x[InvalidIndex-52] + _ = x[SwappedSliceIndices-53] + _ = x[NonSliceableOperand-54] + _ = x[InvalidSliceExpr-55] + _ = x[InvalidShiftCount-56] + _ = x[InvalidShiftOperand-57] + _ = x[InvalidReceive-58] + _ = x[InvalidSend-59] + _ = x[DuplicateLitKey-60] + _ = x[MissingLitKey-61] + _ = x[InvalidLitIndex-62] + _ = x[OversizeArrayLit-63] + _ = x[MixedStructLit-64] + _ = x[InvalidStructLit-65] + _ = x[MissingLitField-66] + _ = x[DuplicateLitField-67] + _ = x[UnexportedLitField-68] + _ = x[InvalidLitField-69] + _ = x[UntypedLit-70] + _ = x[InvalidLit-71] + _ = x[AmbiguousSelector-72] + _ = x[UndeclaredImportedName-73] + _ = x[UnexportedName-74] + _ = x[UndeclaredName-75] + _ = x[MissingFieldOrMethod-76] + _ = x[BadDotDotDotSyntax-77] + _ = x[NonVariadicDotDotDot-78] + _ = x[MisplacedDotDotDot-79] + _ = x[InvalidDotDotDotOperand-80] + _ = x[InvalidDotDotDot-81] + _ = x[UncalledBuiltin-82] + _ = x[InvalidAppend-83] + _ = x[InvalidCap-84] + _ = x[InvalidClose-85] + _ = x[InvalidCopy-86] + _ = x[InvalidComplex-87] + _ = x[InvalidDelete-88] + _ = x[InvalidImag-89] + _ = x[InvalidLen-90] + _ = x[SwappedMakeArgs-91] + _ = x[InvalidMake-92] + _ = x[InvalidReal-93] + _ = x[InvalidAssert-94] + _ = x[ImpossibleAssert-95] + _ = x[InvalidConversion-96] + _ = x[InvalidUntypedConversion-97] + _ = x[BadOffsetofSyntax-98] + _ = x[InvalidOffsetof-99] + _ = x[UnusedExpr-100] + _ = x[UnusedVar-101] + _ = x[MissingReturn-102] + _ = x[WrongResultCount-103] + _ = x[OutOfScopeResult-104] + _ = x[InvalidCond-105] + _ = x[InvalidPostDecl-106] + _ = x[InvalidChanRange-107] + _ = x[InvalidIterVar-108] + _ = x[InvalidRangeExpr-109] + _ = x[MisplacedBreak-110] + _ = x[MisplacedContinue-111] + _ = x[MisplacedFallthrough-112] + _ = x[DuplicateCase-113] + _ = x[DuplicateDefault-114] + _ = x[BadTypeKeyword-115] + _ = x[InvalidTypeSwitch-116] + _ = x[InvalidSelectCase-117] + _ = x[UndeclaredLabel-118] + _ = x[DuplicateLabel-119] + _ = x[MisplacedLabel-120] + _ = x[UnusedLabel-121] + _ = x[JumpOverDecl-122] + _ = x[JumpIntoBlock-123] + _ = x[InvalidMethodExpr-124] + _ = x[WrongArgCount-125] + _ = x[InvalidCall-126] + _ = x[UnusedResults-127] + _ = x[InvalidDefer-128] + _ = x[InvalidGo-129] +} + +const _ErrorCode_name = "TestBlankPkgNameMismatchedPkgNameInvalidPkgUseBadImportPathBrokenImportImportCRenamedUnusedImportInvalidInitCycleDuplicateDeclInvalidDeclCycleInvalidTypeCycleInvalidConstInitInvalidConstValInvalidConstTypeUntypedNilWrongAssignCountUnassignableOperandNoNewVarMultiValAssignOpInvalidIfaceAssignInvalidChanAssignIncompatibleAssignUnaddressableFieldAssignNotATypeInvalidArrayLenBlankIfaceMethodIncomparableMapKeyInvalidIfaceEmbedInvalidPtrEmbedBadRecvInvalidRecvDuplicateFieldAndMethodDuplicateMethodInvalidBlankInvalidIotaMissingInitBodyInvalidInitSigInvalidInitDeclInvalidMainDeclTooManyValuesNotAnExprTruncatedFloatNumericOverflowUndefinedOpMismatchedTypesDivByZeroNonNumericIncDecUnaddressableOperandInvalidIndirectionNonIndexableOperandInvalidIndexSwappedSliceIndicesNonSliceableOperandInvalidSliceExprInvalidShiftCountInvalidShiftOperandInvalidReceiveInvalidSendDuplicateLitKeyMissingLitKeyInvalidLitIndexOversizeArrayLitMixedStructLitInvalidStructLitMissingLitFieldDuplicateLitFieldUnexportedLitFieldInvalidLitFieldUntypedLitInvalidLitAmbiguousSelectorUndeclaredImportedNameUnexportedNameUndeclaredNameMissingFieldOrMethodBadDotDotDotSyntaxNonVariadicDotDotDotMisplacedDotDotDotInvalidDotDotDotOperandInvalidDotDotDotUncalledBuiltinInvalidAppendInvalidCapInvalidCloseInvalidCopyInvalidComplexInvalidDeleteInvalidImagInvalidLenSwappedMakeArgsInvalidMakeInvalidRealInvalidAssertImpossibleAssertInvalidConversionInvalidUntypedConversionBadOffsetofSyntaxInvalidOffsetofUnusedExprUnusedVarMissingReturnWrongResultCountOutOfScopeResultInvalidCondInvalidPostDeclInvalidChanRangeInvalidIterVarInvalidRangeExprMisplacedBreakMisplacedContinueMisplacedFallthroughDuplicateCaseDuplicateDefaultBadTypeKeywordInvalidTypeSwitchInvalidSelectCaseUndeclaredLabelDuplicateLabelMisplacedLabelUnusedLabelJumpOverDeclJumpIntoBlockInvalidMethodExprWrongArgCountInvalidCallUnusedResultsInvalidDeferInvalidGo" + +var _ErrorCode_index = [...]uint16{0, 4, 16, 33, 46, 59, 71, 85, 97, 113, 126, 142, 158, 174, 189, 205, 215, 231, 250, 258, 274, 292, 309, 327, 351, 359, 374, 390, 408, 425, 440, 447, 458, 481, 496, 508, 519, 534, 548, 563, 578, 591, 600, 614, 629, 640, 655, 664, 680, 700, 718, 737, 749, 768, 787, 803, 820, 839, 853, 864, 879, 892, 907, 923, 937, 953, 968, 985, 1003, 1018, 1028, 1038, 1055, 1077, 1091, 1105, 1125, 1143, 1163, 1181, 1204, 1220, 1235, 1248, 1258, 1270, 1281, 1295, 1308, 1319, 1329, 1344, 1355, 1366, 1379, 1395, 1412, 1436, 1453, 1468, 1478, 1487, 1500, 1516, 1532, 1543, 1558, 1574, 1588, 1604, 1618, 1635, 1655, 1668, 1684, 1698, 1715, 1732, 1747, 1761, 1775, 1786, 1798, 1811, 1828, 1841, 1852, 1865, 1877, 1886} + +func (i ErrorCode) String() string { + i -= 1 + if i < 0 || i >= ErrorCode(len(_ErrorCode_index)-1) { + return "ErrorCode(" + strconv.FormatInt(int64(i+1), 10) + ")" + } + return _ErrorCode_name[_ErrorCode_index[i]:_ErrorCode_index[i+1]] +} diff --git a/vendor/modules.txt b/vendor/modules.txt index 5483adef6..425e03269 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -708,7 +708,7 @@ golang.org/x/mobile/event/key # golang.org/x/mod v0.3.0 golang.org/x/mod/module golang.org/x/mod/semver -# golang.org/x/net v0.0.0-20200904194848-62affa334b73 +# golang.org/x/net v0.0.0-20201021035429-f5854403a974 golang.org/x/net/context golang.org/x/net/context/ctxhttp golang.org/x/net/html @@ -731,10 +731,10 @@ golang.org/x/oauth2/google golang.org/x/oauth2/internal golang.org/x/oauth2/jws golang.org/x/oauth2/jwt -# golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208 +# golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9 golang.org/x/sync/errgroup golang.org/x/sync/semaphore -# golang.org/x/sys v0.0.0-20200918174421-af09f7315aff +# golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f golang.org/x/sys/cpu golang.org/x/sys/internal/unsafeheader golang.org/x/sys/unix @@ -762,7 +762,7 @@ golang.org/x/text/unicode/bidi golang.org/x/text/unicode/norm # golang.org/x/time v0.0.0-20191024005414-555d28b269f0 golang.org/x/time/rate -# golang.org/x/tools v0.0.0-20200918232735-d647fc253266 +# golang.org/x/tools v0.0.0-20201111133315-69daaf961d65 golang.org/x/tools/cmd/goimports golang.org/x/tools/go/ast/astutil golang.org/x/tools/go/gcexportdata diff --git a/website/pages/docs/builders/cloudstack.mdx b/website/pages/docs/builders/cloudstack.mdx index 0557dedde..8dacb901f 100644 --- a/website/pages/docs/builders/cloudstack.mdx +++ b/website/pages/docs/builders/cloudstack.mdx @@ -215,11 +215,11 @@ The available variables are: ## Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' ### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ## Basic Example diff --git a/website/pages/docs/builders/hyperv/iso.mdx b/website/pages/docs/builders/hyperv/iso.mdx index af78850d4..39ecb2293 100644 --- a/website/pages/docs/builders/hyperv/iso.mdx +++ b/website/pages/docs/builders/hyperv/iso.mdx @@ -49,15 +49,15 @@ power off the VM. ## ISO Configuration Reference -@include 'common/ISOConfig.mdx' +@include 'common/commonsteps/ISOConfig.mdx' ### Required: -@include 'common/ISOConfig-required.mdx' +@include 'common/commonsteps/ISOConfig-required.mdx' ### Optional: -@include 'common/ISOConfig-not-required.mdx' +@include 'common/commonsteps/ISOConfig-not-required.mdx' ## Configuration Reference @@ -85,11 +85,11 @@ builder. ## Http directory configuration reference -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' ### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ## Shutdown configuration reference @@ -99,15 +99,15 @@ builder. ## Floppy configuration reference -@include 'common/FloppyConfig.mdx' +@include 'common/commonsteps/FloppyConfig.mdx' ### Optional: -@include 'common/FloppyConfig-not-required.mdx' +@include 'common/commonsteps/FloppyConfig-not-required.mdx' ### CD configuration reference -@include 'common/CDConfig-not-required.mdx' +@include 'common/commonsteps/CDConfig-not-required.mdx' ## Communicator configuration reference diff --git a/website/pages/docs/builders/hyperv/vmcx.mdx b/website/pages/docs/builders/hyperv/vmcx.mdx index 6ee142587..4ff8ac9a0 100644 --- a/website/pages/docs/builders/hyperv/vmcx.mdx +++ b/website/pages/docs/builders/hyperv/vmcx.mdx @@ -72,15 +72,15 @@ builder. ## ISO Configuration Reference -@include 'common/ISOConfig.mdx' +@include 'common/commonsteps/ISOConfig.mdx' ### Required: -@include 'common/ISOConfig-required.mdx' +@include 'common/commonsteps/ISOConfig-required.mdx' ### Optional: -@include 'common/ISOConfig-not-required.mdx' +@include 'common/commonsteps/ISOConfig-not-required.mdx' ### Required for virtual machine import: @@ -121,11 +121,11 @@ builder. ### CD configuration -@include 'common/CDConfig.mdx' +@include 'common/commonsteps/CDConfig.mdx' #### Optional: -@include 'common/CDConfig-not-required.mdx' +@include 'common/commonsteps/CDConfig-not-required.mdx' ## Boot Command @@ -165,11 +165,11 @@ For more examples of various boot commands, see the sample projects from our ## Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' ### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ## Integration Services diff --git a/website/pages/docs/builders/parallels/iso.mdx b/website/pages/docs/builders/parallels/iso.mdx index ed5d0e519..ac825c1ce 100644 --- a/website/pages/docs/builders/parallels/iso.mdx +++ b/website/pages/docs/builders/parallels/iso.mdx @@ -62,15 +62,15 @@ can also be supplied to override the typical auto-generated key: ## ISO Configuration Reference -@include 'common/ISOConfig.mdx' +@include 'common/commonsteps/ISOConfig.mdx' ### Required: -@include 'common/ISOConfig-required.mdx' +@include 'common/commonsteps/ISOConfig-required.mdx' ### Optional: -@include 'common/ISOConfig-not-required.mdx' +@include 'common/commonsteps/ISOConfig-not-required.mdx' ### Required: diff --git a/website/pages/docs/builders/proxmox/iso.mdx b/website/pages/docs/builders/proxmox/iso.mdx index d97d1f6e2..c2c3de194 100644 --- a/website/pages/docs/builders/proxmox/iso.mdx +++ b/website/pages/docs/builders/proxmox/iso.mdx @@ -297,11 +297,11 @@ For more examples of various boot commands, see the sample projects from our ## Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' ### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ## Example: Fedora with kickstart diff --git a/website/pages/docs/builders/qemu.mdx b/website/pages/docs/builders/qemu.mdx index d81fb3e50..b8dfa5ef5 100644 --- a/website/pages/docs/builders/qemu.mdx +++ b/website/pages/docs/builders/qemu.mdx @@ -118,39 +118,39 @@ necessary for this build to succeed and can be found further down the page. ## ISO Configuration -@include 'common/ISOConfig.mdx' +@include 'common/commonsteps/ISOConfig.mdx' ### Required: -@include 'common/ISOConfig-required.mdx' +@include 'common/commonsteps/ISOConfig-required.mdx' ### Optional: -@include 'common/ISOConfig-not-required.mdx' +@include 'common/commonsteps/ISOConfig-not-required.mdx' ## Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' ### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ## Floppy configuration -@include 'common/FloppyConfig.mdx' +@include 'common/commonsteps/FloppyConfig.mdx' ### Optional: -@include 'common/FloppyConfig-not-required.mdx' +@include 'common/commonsteps/FloppyConfig-not-required.mdx' ### CD configuration -@include 'common/CDConfig.mdx' +@include 'common/commonsteps/CDConfig.mdx' #### Optional: -@include 'common/CDConfig-not-required.mdx' +@include 'common/commonsteps/CDConfig-not-required.mdx' ## Shutdown configuration diff --git a/website/pages/docs/builders/virtualbox/iso.mdx b/website/pages/docs/builders/virtualbox/iso.mdx index 0aac5181e..ac0f13bd6 100644 --- a/website/pages/docs/builders/virtualbox/iso.mdx +++ b/website/pages/docs/builders/virtualbox/iso.mdx @@ -95,39 +95,39 @@ necessary for this build to succeed and can be found further down the page. ### ISO Configuration -@include 'common/ISOConfig.mdx' +@include 'common/commonsteps/ISOConfig.mdx' #### Required: -@include 'common/ISOConfig-required.mdx' +@include 'common/commonsteps/ISOConfig-required.mdx' #### Optional: -@include 'common/ISOConfig-not-required.mdx' +@include 'common/commonsteps/ISOConfig-not-required.mdx' ### Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' #### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ### Floppy configuration -@include 'common/FloppyConfig.mdx' +@include 'common/commonsteps/FloppyConfig.mdx' #### Optional: -@include 'common/FloppyConfig-not-required.mdx' +@include 'common/commonsteps/FloppyConfig-not-required.mdx' ### CD configuration -@include 'common/CDConfig.mdx' +@include 'common/commonsteps/CDConfig.mdx' #### Optional: -@include 'common/CDConfig-not-required.mdx' +@include 'common/commonsteps/CDConfig-not-required.mdx' ### Export configuration diff --git a/website/pages/docs/builders/virtualbox/ovf.mdx b/website/pages/docs/builders/virtualbox/ovf.mdx index 21eade0e9..11e1809e7 100644 --- a/website/pages/docs/builders/virtualbox/ovf.mdx +++ b/website/pages/docs/builders/virtualbox/ovf.mdx @@ -109,27 +109,27 @@ necessary for this build to succeed and can be found further down the page. ### Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' #### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ### Floppy configuration -@include 'common/FloppyConfig.mdx' +@include 'common/commonsteps/FloppyConfig.mdx' #### Optional: -@include 'common/FloppyConfig-not-required.mdx' +@include 'common/commonsteps/FloppyConfig-not-required.mdx' ### CD configuration -@include 'common/CDConfig.mdx' +@include 'common/commonsteps/CDConfig.mdx' #### Optional: -@include 'common/CDConfig-not-required.mdx' +@include 'common/commonsteps/CDConfig-not-required.mdx' ### Export configuration diff --git a/website/pages/docs/builders/virtualbox/vm.mdx b/website/pages/docs/builders/virtualbox/vm.mdx index f189e0a68..c520e20c7 100644 --- a/website/pages/docs/builders/virtualbox/vm.mdx +++ b/website/pages/docs/builders/virtualbox/vm.mdx @@ -120,27 +120,27 @@ builder. ### Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' #### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ### Floppy configuration -@include 'common/FloppyConfig.mdx' +@include 'common/commonsteps/FloppyConfig.mdx' #### Optional: -@include 'common/FloppyConfig-not-required.mdx' +@include 'common/commonsteps/FloppyConfig-not-required.mdx' ### CD configuration -@include 'common/CDConfig.mdx' +@include 'common/commonsteps/CDConfig.mdx' #### Optional: -@include 'common/CDConfig-not-required.mdx' +@include 'common/commonsteps/CDConfig-not-required.mdx' ### Export configuration diff --git a/website/pages/docs/builders/vmware/iso.mdx b/website/pages/docs/builders/vmware/iso.mdx index ea21ed1bb..126052bbf 100644 --- a/website/pages/docs/builders/vmware/iso.mdx +++ b/website/pages/docs/builders/vmware/iso.mdx @@ -104,34 +104,34 @@ necessary for this build to succeed and can be found further down the page. ### ISO Configuration -@include 'common/ISOConfig.mdx' +@include 'common/commonsteps/ISOConfig.mdx' #### Required: -@include 'common/ISOConfig-required.mdx' +@include 'common/commonsteps/ISOConfig-required.mdx' #### Optional: -@include 'common/ISOConfig-not-required.mdx' +@include 'common/commonsteps/ISOConfig-not-required.mdx' ### Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' #### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ### Floppy configuration -@include 'common/FloppyConfig.mdx' +@include 'common/commonsteps/FloppyConfig.mdx' #### Optional: -@include 'common/FloppyConfig-not-required.mdx' +@include 'common/commonsteps/FloppyConfig-not-required.mdx' ### CD configuration -@include 'common/CDConfig-not-required.mdx' +@include 'common/commonsteps/CDConfig-not-required.mdx' ### Shutdown configuration diff --git a/website/pages/docs/builders/vmware/vmx.mdx b/website/pages/docs/builders/vmware/vmx.mdx index f7efbc017..6ad72a3f8 100644 --- a/website/pages/docs/builders/vmware/vmx.mdx +++ b/website/pages/docs/builders/vmware/vmx.mdx @@ -105,27 +105,27 @@ necessary for this build to succeed and can be found further down the page. ### Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' #### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ### Floppy configuration -@include 'common/FloppyConfig.mdx' +@include 'common/commonsteps/FloppyConfig.mdx' #### Optional: -@include 'common/FloppyConfig-not-required.mdx' +@include 'common/commonsteps/FloppyConfig-not-required.mdx' ### CD configuration -@include 'common/CDConfig.mdx' +@include 'common/commonsteps/CDConfig.mdx' #### Optional: -@include 'common/CDConfig-not-required.mdx' +@include 'common/commonsteps/CDConfig-not-required.mdx' ### Export configuration diff --git a/website/pages/docs/builders/vmware/vsphere-clone.mdx b/website/pages/docs/builders/vmware/vsphere-clone.mdx index ba7d26ba0..6201a9ace 100644 --- a/website/pages/docs/builders/vmware/vsphere-clone.mdx +++ b/website/pages/docs/builders/vmware/vsphere-clone.mdx @@ -162,11 +162,11 @@ can be done via environment variable: ### Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' #### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ### Floppy configuration @@ -198,11 +198,11 @@ can be done via environment variable: ### CDRom Configuration -@include 'common/CDConfig.mdx' +@include 'common/commonsteps/CDConfig.mdx' #### Optional: -@include 'common/CDConfig-not-required.mdx' +@include 'common/commonsteps/CDConfig-not-required.mdx' @include 'builder/vsphere/common/CDRomConfig-not-required.mdx' diff --git a/website/pages/docs/builders/vmware/vsphere-iso.mdx b/website/pages/docs/builders/vmware/vsphere-iso.mdx index 92b0287c4..c7df57f17 100644 --- a/website/pages/docs/builders/vmware/vsphere-iso.mdx +++ b/website/pages/docs/builders/vmware/vsphere-iso.mdx @@ -89,11 +89,11 @@ source "vsphere-iso" "example" { ### Http directory configuration -@include 'common/HTTPConfig.mdx' +@include 'common/commonsteps/HTTPConfig.mdx' #### Optional: -@include 'common/HTTPConfig-not-required.mdx' +@include 'common/commonsteps/HTTPConfig-not-required.mdx' ### Floppy configuration @@ -125,15 +125,15 @@ source "vsphere-iso" "example" { ### ISO Configuration -@include 'common/ISOConfig.mdx' +@include 'common/commonsteps/ISOConfig.mdx' #### Required: -@include 'common/ISOConfig-required.mdx' +@include 'common/commonsteps/ISOConfig-required.mdx' #### Optional: -@include 'common/ISOConfig-not-required.mdx' +@include 'common/commonsteps/ISOConfig-not-required.mdx' ### CDRom Configuration @@ -176,11 +176,11 @@ iso_paths = [ @include 'builder/vsphere/common/RemoveCDRomConfig-not-required.mdx' -@include 'common/CDConfig.mdx' +@include 'common/commonsteps/CDConfig.mdx' #### Optional: -@include 'common/CDConfig-not-required.mdx' +@include 'common/commonsteps/CDConfig-not-required.mdx' ### Create Configuration diff --git a/website/pages/partials/common/CDConfig-not-required.mdx b/website/pages/partials/common/commonsteps/CDConfig-not-required.mdx similarity index 96% rename from website/pages/partials/common/CDConfig-not-required.mdx rename to website/pages/partials/common/commonsteps/CDConfig-not-required.mdx index 11e4b8fc6..9fc2cdc23 100644 --- a/website/pages/partials/common/CDConfig-not-required.mdx +++ b/website/pages/partials/common/commonsteps/CDConfig-not-required.mdx @@ -1,4 +1,4 @@ - + - `cd_files` ([]string) - A list of files to place onto a CD that is attached when the VM is booted. This can include either files or directories; any directories diff --git a/website/pages/partials/common/CDConfig.mdx b/website/pages/partials/common/commonsteps/CDConfig.mdx similarity index 87% rename from website/pages/partials/common/CDConfig.mdx rename to website/pages/partials/common/commonsteps/CDConfig.mdx index b234df3eb..a139db6a4 100644 --- a/website/pages/partials/common/CDConfig.mdx +++ b/website/pages/partials/common/commonsteps/CDConfig.mdx @@ -1,4 +1,4 @@ - + An iso (CD) containing custom files can be made available for your build. diff --git a/website/pages/partials/common/FloppyConfig-not-required.mdx b/website/pages/partials/common/commonsteps/FloppyConfig-not-required.mdx similarity index 93% rename from website/pages/partials/common/FloppyConfig-not-required.mdx rename to website/pages/partials/common/commonsteps/FloppyConfig-not-required.mdx index 9c6fcda8a..c81d3f61f 100644 --- a/website/pages/partials/common/FloppyConfig-not-required.mdx +++ b/website/pages/partials/common/commonsteps/FloppyConfig-not-required.mdx @@ -1,4 +1,4 @@ - + - `floppy_files` ([]string) - A list of files to place onto a floppy disk that is attached when the VM is booted. Currently, no support exists for creating sub-directories on diff --git a/website/pages/partials/common/FloppyConfig.mdx b/website/pages/partials/common/commonsteps/FloppyConfig.mdx similarity index 90% rename from website/pages/partials/common/FloppyConfig.mdx rename to website/pages/partials/common/commonsteps/FloppyConfig.mdx index bca819832..8db59da19 100644 --- a/website/pages/partials/common/FloppyConfig.mdx +++ b/website/pages/partials/common/commonsteps/FloppyConfig.mdx @@ -1,4 +1,4 @@ - + A floppy can be made available for your build. This is most useful for unattended Windows installs, which look for an Autounattend.xml file on diff --git a/website/pages/partials/common/HTTPConfig-not-required.mdx b/website/pages/partials/common/commonsteps/HTTPConfig-not-required.mdx similarity index 94% rename from website/pages/partials/common/HTTPConfig-not-required.mdx rename to website/pages/partials/common/commonsteps/HTTPConfig-not-required.mdx index 4a3238ad4..aece4b6de 100644 --- a/website/pages/partials/common/HTTPConfig-not-required.mdx +++ b/website/pages/partials/common/commonsteps/HTTPConfig-not-required.mdx @@ -1,4 +1,4 @@ - + - `http_directory` (string) - Path to a directory to serve using an HTTP server. The files in this directory will be available over HTTP that will be requestable from the diff --git a/website/pages/partials/common/HTTPConfig.mdx b/website/pages/partials/common/commonsteps/HTTPConfig.mdx similarity index 85% rename from website/pages/partials/common/HTTPConfig.mdx rename to website/pages/partials/common/commonsteps/HTTPConfig.mdx index 27c79796b..f841432a8 100644 --- a/website/pages/partials/common/HTTPConfig.mdx +++ b/website/pages/partials/common/commonsteps/HTTPConfig.mdx @@ -1,4 +1,4 @@ - + Packer will create an http server serving `http_directory` when it is set, a random free port will be selected and the architecture of the directory diff --git a/website/pages/partials/common/ISOConfig-not-required.mdx b/website/pages/partials/common/commonsteps/ISOConfig-not-required.mdx similarity index 92% rename from website/pages/partials/common/ISOConfig-not-required.mdx rename to website/pages/partials/common/commonsteps/ISOConfig-not-required.mdx index b93fdafd5..9d0744786 100644 --- a/website/pages/partials/common/ISOConfig-not-required.mdx +++ b/website/pages/partials/common/commonsteps/ISOConfig-not-required.mdx @@ -1,4 +1,4 @@ - + - `iso_urls` ([]string) - Multiple URLs for the ISO to download. Packer will try these in order. If anything goes wrong attempting to download or while downloading a diff --git a/website/pages/partials/common/ISOConfig-required.mdx b/website/pages/partials/common/commonsteps/ISOConfig-required.mdx similarity index 95% rename from website/pages/partials/common/ISOConfig-required.mdx rename to website/pages/partials/common/commonsteps/ISOConfig-required.mdx index 1611af8ca..a2c27df83 100644 --- a/website/pages/partials/common/ISOConfig-required.mdx +++ b/website/pages/partials/common/commonsteps/ISOConfig-required.mdx @@ -1,4 +1,4 @@ - + - `iso_checksum` (string) - The checksum for the ISO file or virtual hard drive file. The type of the checksum is specified within the checksum field as a prefix, ex: diff --git a/website/pages/partials/common/ISOConfig.mdx b/website/pages/partials/common/commonsteps/ISOConfig.mdx similarity index 96% rename from website/pages/partials/common/ISOConfig.mdx rename to website/pages/partials/common/commonsteps/ISOConfig.mdx index 4dfbd19f2..548bffa0b 100644 --- a/website/pages/partials/common/ISOConfig.mdx +++ b/website/pages/partials/common/commonsteps/ISOConfig.mdx @@ -1,4 +1,4 @@ - + By default, Packer will symlink, download or copy image files to the Packer cache into a "`hash($iso_url+$iso_checksum).$iso_target_extension`" file.