diff --git a/builder/alicloud/ecs/builder.go b/builder/alicloud/ecs/builder.go index 106ac4287..d0ab061bb 100644 --- a/builder/alicloud/ecs/builder.go +++ b/builder/alicloud/ecs/builder.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -81,7 +80,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { client, err := b.config.Client() if err != nil { diff --git a/builder/amazon/chroot/builder.go b/builder/amazon/chroot/builder.go index 79a99c43f..cf3ed4dae 100644 --- a/builder/amazon/chroot/builder.go +++ b/builder/amazon/chroot/builder.go @@ -15,7 +15,6 @@ import ( "github.com/aws/aws-sdk-go/service/ec2" "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/chroot" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -346,7 +345,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { if runtime.GOOS != "linux" { return nil, errors.New("The amazon-chroot builder only works on Linux environments.") } diff --git a/builder/amazon/ebs/builder.go b/builder/amazon/ebs/builder.go index 17edd4744..72a22c291 100644 --- a/builder/amazon/ebs/builder.go +++ b/builder/amazon/ebs/builder.go @@ -17,7 +17,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -151,7 +150,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { diff --git a/builder/amazon/ebssurrogate/builder.go b/builder/amazon/ebssurrogate/builder.go index 030255413..565cd6875 100644 --- a/builder/amazon/ebssurrogate/builder.go +++ b/builder/amazon/ebssurrogate/builder.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -174,7 +173,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/ebsvolume/builder.go b/builder/amazon/ebsvolume/builder.go index b7e872ad9..fce769a0a 100644 --- a/builder/amazon/ebsvolume/builder.go +++ b/builder/amazon/ebsvolume/builder.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -165,7 +164,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/instance/builder.go b/builder/amazon/instance/builder.go index a06fd4656..278eed4f9 100644 --- a/builder/amazon/instance/builder.go +++ b/builder/amazon/instance/builder.go @@ -17,7 +17,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" awscommon "github.com/hashicorp/packer/builder/amazon/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -234,7 +233,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return generatedData, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { session, err := b.config.Session() if err != nil { return nil, err diff --git a/builder/amazon/instance/step_bundle_volume.go b/builder/amazon/instance/step_bundle_volume.go index 043f4f096..e4721d06c 100644 --- a/builder/amazon/instance/step_bundle_volume.go +++ b/builder/amazon/instance/step_bundle_volume.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/aws/aws-sdk-go/service/ec2" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -26,7 +25,7 @@ type StepBundleVolume struct { } func (s *StepBundleVolume) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) config := state.Get("config").(*Config) instance := state.Get("instance").(*ec2.Instance) ui := state.Get("ui").(packersdk.Ui) @@ -53,7 +52,7 @@ func (s *StepBundleVolume) Run(ctx context.Context, state multistep.StateBag) mu } ui.Say("Bundling the volume...") - cmd := new(packer.RemoteCmd) + cmd := new(packersdk.RemoteCmd) cmd.Command = config.BundleVolCommand if s.Debug { diff --git a/builder/amazon/instance/step_upload_bundle.go b/builder/amazon/instance/step_upload_bundle.go index 6a8dd3186..dd278df49 100644 --- a/builder/amazon/instance/step_upload_bundle.go +++ b/builder/amazon/instance/step_upload_bundle.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -25,7 +24,7 @@ type StepUploadBundle struct { } func (s *StepUploadBundle) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) config := state.Get("config").(*Config) manifestName := state.Get("manifest_name").(string) manifestPath := state.Get("manifest_path").(string) @@ -64,7 +63,7 @@ func (s *StepUploadBundle) Run(ctx context.Context, state multistep.StateBag) mu } ui.Say("Uploading the bundle...") - cmd := &packer.RemoteCmd{Command: config.BundleUploadCommand} + cmd := &packersdk.RemoteCmd{Command: config.BundleUploadCommand} if s.Debug { ui.Say(fmt.Sprintf("Running: %s", config.BundleUploadCommand)) diff --git a/builder/amazon/instance/step_upload_x509_cert.go b/builder/amazon/instance/step_upload_x509_cert.go index a46eb024f..9eda67877 100644 --- a/builder/amazon/instance/step_upload_x509_cert.go +++ b/builder/amazon/instance/step_upload_x509_cert.go @@ -5,7 +5,6 @@ import ( "fmt" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -13,7 +12,7 @@ import ( type StepUploadX509Cert struct{} func (s *StepUploadX509Cert) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) config := state.Get("config").(*Config) ui := state.Get("ui").(packersdk.Ui) @@ -41,7 +40,7 @@ func (s *StepUploadX509Cert) Run(ctx context.Context, state multistep.StateBag) func (s *StepUploadX509Cert) Cleanup(multistep.StateBag) {} -func (s *StepUploadX509Cert) uploadSingle(comm packer.Communicator, dst, src string) error { +func (s *StepUploadX509Cert) uploadSingle(comm packersdk.Communicator, dst, src string) error { f, err := os.Open(src) if err != nil { return err diff --git a/builder/azure/arm/builder.go b/builder/azure/arm/builder.go index aef35af43..505df319e 100644 --- a/builder/azure/arm/builder.go +++ b/builder/azure/arm/builder.go @@ -19,7 +19,6 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" "github.com/hashicorp/packer/builder/azure/common/lin" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -52,7 +51,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, errs } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { ui.Say("Running builder ...") diff --git a/builder/azure/chroot/builder.go b/builder/azure/chroot/builder.go index ab3b74346..e546bb08f 100644 --- a/builder/azure/chroot/builder.go +++ b/builder/azure/chroot/builder.go @@ -393,7 +393,7 @@ func checkHyperVGeneration(s string) interface{} { s, compute.PossibleHyperVGenerationValues()) } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { switch runtime.GOOS { case "linux", "freebsd": break diff --git a/builder/azure/dtl/builder.go b/builder/azure/dtl/builder.go index 28303b8c2..fd21634f0 100644 --- a/builder/azure/dtl/builder.go +++ b/builder/azure/dtl/builder.go @@ -18,7 +18,6 @@ import ( "github.com/hashicorp/packer/builder/azure/common/constants" "github.com/hashicorp/packer/builder/azure/common/lin" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -52,7 +51,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, errs } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { ui.Say("Running builder ...") diff --git a/builder/cloudstack/builder.go b/builder/cloudstack/builder.go index 2850dec13..f60354e44 100644 --- a/builder/cloudstack/builder.go +++ b/builder/cloudstack/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Run implements the packer.Builder interface. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { b.ui = ui // Create a CloudStack API client. diff --git a/builder/digitalocean/builder.go b/builder/digitalocean/builder.go index f9ac5fd5b..366980f7c 100644 --- a/builder/digitalocean/builder.go +++ b/builder/digitalocean/builder.go @@ -12,7 +12,6 @@ import ( "github.com/digitalocean/godo" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -38,7 +37,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { client := godo.NewClient(oauth2.NewClient(context.TODO(), &apiTokenSource{ AccessToken: b.config.APIToken, })) diff --git a/builder/docker/builder.go b/builder/docker/builder.go index 7e785cbcc..d77e7c9d1 100644 --- a/builder/docker/builder.go +++ b/builder/docker/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -36,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { }, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { driver := &DockerDriver{Ctx: &b.config.ctx, Ui: ui} if err := driver.Verify(); err != nil { return nil, err diff --git a/builder/docker/communicator.go b/builder/docker/communicator.go index 0b612e25f..360ac92d3 100644 --- a/builder/docker/communicator.go +++ b/builder/docker/communicator.go @@ -15,7 +15,7 @@ import ( "syscall" "github.com/hashicorp/go-version" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Communicator struct { @@ -29,9 +29,9 @@ type Communicator struct { EntryPoint []string } -var _ packer.Communicator = new(Communicator) +var _ packersdk.Communicator = new(Communicator) -func (c *Communicator) Start(ctx context.Context, remote *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, remote *packersdk.RemoteCmd) error { dockerArgs := []string{ "exec", "-i", @@ -274,7 +274,7 @@ func (c *Communicator) DownloadDir(src string, dst string, exclude []string) err } // Runs the given command and blocks until completion -func (c *Communicator) run(cmd *exec.Cmd, remote *packer.RemoteCmd, stdin io.WriteCloser, stdout, stderr io.ReadCloser) { +func (c *Communicator) run(cmd *exec.Cmd, remote *packersdk.RemoteCmd, stdin io.WriteCloser, stdout, stderr io.ReadCloser) { // For Docker, remote communication must be serialized since it // only supports single execution. c.lock.Lock() diff --git a/builder/docker/communicator_test.go b/builder/docker/communicator_test.go index 6abba8cd5..fefbc7f54 100644 --- a/builder/docker/communicator_test.go +++ b/builder/docker/communicator_test.go @@ -10,6 +10,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" "github.com/hashicorp/packer/provisioner/file" "github.com/hashicorp/packer/provisioner/shell" @@ -60,10 +61,10 @@ func TestUploadDownload(t *testing.T) { defer os.Remove("my-strawberry-cake") // Add hooks so the provisioners run during the build - hooks := map[string][]packer.Hook{} - hooks[packer.HookProvision] = []packer.Hook{ + hooks := map[string][]packersdk.Hook{} + hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packer.HookedProvisioner{ + Provisioners: []*packersdk.HookedProvisioner{ {Provisioner: upload, Config: nil, TypeName: ""}, {Provisioner: download, Config: nil, TypeName: ""}, }, @@ -148,10 +149,10 @@ func TestLargeDownload(t *testing.T) { defer os.Remove("bigcake") // Add hooks so the provisioners run during the build - hooks := map[string][]packer.Hook{} - hooks[packer.HookProvision] = []packer.Hook{ + hooks := map[string][]packersdk.Hook{} + hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packer.HookedProvisioner{ + Provisioners: []*packersdk.HookedProvisioner{ {Provisioner: shell, Config: nil, TypeName: ""}, {Provisioner: downloadCupcake, Config: nil, TypeName: ""}, {Provisioner: downloadBigcake, Config: nil, TypeName: ""}, @@ -256,10 +257,10 @@ func TestFixUploadOwner(t *testing.T) { } // Add hooks so the provisioners run during the build - hooks := map[string][]packer.Hook{} - hooks[packer.HookProvision] = []packer.Hook{ + hooks := map[string][]packersdk.Hook{} + hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packer.HookedProvisioner{ + Provisioners: []*packersdk.HookedProvisioner{ {Provisioner: fileProvisioner, Config: nil, TypeName: ""}, {Provisioner: dirProvisioner, Config: nil, TypeName: ""}, {Provisioner: shellProvisioner, Config: nil, TypeName: ""}, diff --git a/builder/docker/windows_container_communicator.go b/builder/docker/windows_container_communicator.go index c12177e34..ee4fd5dbb 100644 --- a/builder/docker/windows_container_communicator.go +++ b/builder/docker/windows_container_communicator.go @@ -10,7 +10,7 @@ import ( "os" "path/filepath" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // Windows containers are a special beast in Docker; you can't use docker cp @@ -46,7 +46,7 @@ func (c *WindowsContainerCommunicator) Upload(dst string, src io.Reader, fi *os. // Copy the file into place by copying the temporary file we put // into the shared folder into the proper location in the container - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("Copy-Item -Path %s/%s -Destination %s", c.ContainerDir, filepath.Base(tempfile.Name()), dst), } @@ -132,7 +132,7 @@ func (c *WindowsContainerCommunicator) UploadDir(dst string, src string, exclude } // Make the directory, then copy into it - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("Copy-Item %s -Destination %s -Recurse", containerSrc, containerDst), } @@ -156,7 +156,7 @@ func (c *WindowsContainerCommunicator) Download(src string, dst io.Writer) error log.Printf("Downloading file from container: %s:%s", c.ContainerID, src) // Copy file onto temp file on mounted volume inside container var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("Copy-Item -Path %s -Destination %s/%s", src, c.ContainerDir, filepath.Base(src)), Stdout: &stdout, diff --git a/builder/file/builder.go b/builder/file/builder.go index 62561abea..062557389 100644 --- a/builder/file/builder.go +++ b/builder/file/builder.go @@ -14,7 +14,6 @@ import ( "path/filepath" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -38,7 +37,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } // Run is where the actual build should take place. It takes a Build and a Ui. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { artifact := new(FileArtifact) // Create all directories leading to target @@ -81,7 +80,7 @@ func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (p } if hook != nil { - if err := hook.Run(ctx, packer.HookProvision, ui, new(packer.MockCommunicator), nil); err != nil { + if err := hook.Run(ctx, packersdk.HookProvision, ui, new(packersdk.MockCommunicator), nil); err != nil { return nil, err } } diff --git a/builder/googlecompute/builder.go b/builder/googlecompute/builder.go index 9cd7e557b..4d3f4d605 100644 --- a/builder/googlecompute/builder.go +++ b/builder/googlecompute/builder.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -36,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a googlecompute Packer build and returns a packersdk.Artifact // representing a GCE machine image. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { cfg := GCEDriverConfig{ Ui: ui, ProjectId: b.config.ProjectId, diff --git a/builder/hcloud/builder.go b/builder/hcloud/builder.go index 413451755..f2b0d5a83 100644 --- a/builder/hcloud/builder.go +++ b/builder/hcloud/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -35,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { opts := []hcloud.ClientOption{ hcloud.WithToken(b.config.HCloudToken), hcloud.WithEndpoint(b.config.Endpoint), diff --git a/builder/hyperone/builder.go b/builder/hyperone/builder.go index f123a19c5..8b33308ce 100644 --- a/builder/hyperone/builder.go +++ b/builder/hyperone/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -52,7 +51,7 @@ type wrappedCommandTemplate struct { Command string } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { wrappedCommand := func(command string) (string, error) { ictx := b.config.ctx ictx.Data = &wrappedCommandTemplate{Command: command} diff --git a/builder/hyperone/chroot_communicator.go b/builder/hyperone/chroot_communicator.go index a8c64f377..de63f0fc8 100644 --- a/builder/hyperone/chroot_communicator.go +++ b/builder/hyperone/chroot_communicator.go @@ -8,7 +8,7 @@ import ( "path/filepath" "strconv" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type CommandWrapper func(string) (string, error) @@ -18,10 +18,10 @@ type CommandWrapper func(string) (string, error) type ChrootCommunicator struct { Chroot string CmdWrapper CommandWrapper - Wrapped packer.Communicator + Wrapped packersdk.Communicator } -func (c *ChrootCommunicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *ChrootCommunicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { command := strconv.Quote(cmd.Command) chrootCommand, err := c.CmdWrapper( fmt.Sprintf("sudo chroot %s /bin/sh -c %s", c.Chroot, command)) diff --git a/builder/hyperone/step_chroot_provision.go b/builder/hyperone/step_chroot_provision.go index 7efa606ed..6f353d96f 100644 --- a/builder/hyperone/step_chroot_provision.go +++ b/builder/hyperone/step_chroot_provision.go @@ -3,9 +3,9 @@ package hyperone import ( "context" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type stepChrootProvision struct{} @@ -13,7 +13,7 @@ type stepChrootProvision struct{} func (s *stepChrootProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { config := state.Get("config").(*Config) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) - sshCommunicator := state.Get("communicator").(packer.Communicator) + sshCommunicator := state.Get("communicator").(packersdk.Communicator) comm := &ChrootCommunicator{ Chroot: config.ChrootMountPath, diff --git a/builder/hyperone/utils.go b/builder/hyperone/utils.go index a2526e1cd..fa6e9df46 100644 --- a/builder/hyperone/utils.go +++ b/builder/hyperone/utils.go @@ -7,7 +7,6 @@ import ( "log" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -27,7 +26,7 @@ func runCommands(commands []string, ictx interpolate.Context, state multistep.St ctx := context.TODO() ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) for _, rawCmd := range commands { intCmd, err := interpolate.Render(rawCmd, &ictx) @@ -40,7 +39,7 @@ func runCommands(commands []string, ictx interpolate.Context, state multistep.St return fmt.Errorf("error wrapping command: %s", err) } - remoteCmd := &packer.RemoteCmd{ + remoteCmd := &packersdk.RemoteCmd{ Command: command, } @@ -63,10 +62,10 @@ func runCommands(commands []string, ictx interpolate.Context, state multistep.St func captureOutput(command string, state multistep.StateBag) (string, error) { ctx := context.TODO() - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) var stdout bytes.Buffer - remoteCmd := &packer.RemoteCmd{ + remoteCmd := &packersdk.RemoteCmd{ Command: command, Stdout: &stdout, } diff --git a/builder/hyperv/common/step_shutdown.go b/builder/hyperv/common/step_shutdown.go index 9a9dfef54..4033be990 100644 --- a/builder/hyperv/common/step_shutdown.go +++ b/builder/hyperv/common/step_shutdown.go @@ -8,7 +8,6 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -17,7 +16,7 @@ import ( // but ultimately forcefully shuts it down if that fails. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // driver Driver // ui packersdk.Ui // vmName string @@ -31,7 +30,7 @@ type StepShutdown struct { func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) @@ -41,7 +40,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis log.Printf("Executing shutdown command: %s", s.Command) var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: s.Command, Stdout: &stdout, Stderr: &stderr, diff --git a/builder/hyperv/iso/builder.go b/builder/hyperv/iso/builder.go index 41b7e3c2e..a3e1a7f39 100644 --- a/builder/hyperv/iso/builder.go +++ b/builder/hyperv/iso/builder.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" hypervcommon "github.com/hashicorp/packer/builder/hyperv/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -177,7 +176,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a Hyperv appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Hyperv driver, err := hypervcommon.NewHypervPS4Driver() if err != nil { diff --git a/builder/hyperv/vmcx/builder.go b/builder/hyperv/vmcx/builder.go index 80f6ea3e7..cf09d2811 100644 --- a/builder/hyperv/vmcx/builder.go +++ b/builder/hyperv/vmcx/builder.go @@ -14,7 +14,6 @@ import ( hypervcommon "github.com/hashicorp/packer/builder/hyperv/common" powershell "github.com/hashicorp/packer/builder/hyperv/common/powershell" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -217,7 +216,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a Hyperv appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Hyperv driver, err := hypervcommon.NewHypervPS4Driver() if err != nil { diff --git a/builder/jdcloud/builder.go b/builder/jdcloud/builder.go index dee0cd225..25e0c7df1 100644 --- a/builder/jdcloud/builder.go +++ b/builder/jdcloud/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -43,7 +42,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("hook", hook) diff --git a/builder/linode/builder.go b/builder/linode/builder.go index 2ae84f3c9..e89c7cf8f 100644 --- a/builder/linode/builder.go +++ b/builder/linode/builder.go @@ -12,7 +12,6 @@ import ( "github.com/linode/linodego" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -37,7 +36,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (ret packersdk.Artifact, err error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (ret packersdk.Artifact, err error) { ui.Say("Running builder ...") client := newLinodeClient(b.config.PersonalAccessToken) diff --git a/builder/lxc/builder.go b/builder/lxc/builder.go index 3a350effc..b2f6fadb8 100644 --- a/builder/lxc/builder.go +++ b/builder/lxc/builder.go @@ -6,7 +6,6 @@ import ( "path/filepath" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -36,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { wrappedCommand := func(command string) (string, error) { b.config.ctx.Data = &wrappedCommandTemplate{Command: command} return interpolate.Render(b.config.CommandWrapper, &b.config.ctx) diff --git a/builder/lxc/communicator.go b/builder/lxc/communicator.go index b91d811d0..809c5b3cf 100644 --- a/builder/lxc/communicator.go +++ b/builder/lxc/communicator.go @@ -12,7 +12,7 @@ import ( "strings" "syscall" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -23,7 +23,7 @@ type LxcAttachCommunicator struct { CmdWrapper CommandWrapper } -func (c *LxcAttachCommunicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *LxcAttachCommunicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { localCmd, err := c.Execute(cmd.Command) if err != nil { diff --git a/builder/lxc/communicator_test.go b/builder/lxc/communicator_test.go index 4a81a36a7..cf555fd5c 100644 --- a/builder/lxc/communicator_test.go +++ b/builder/lxc/communicator_test.go @@ -3,13 +3,13 @@ package lxc import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicator_ImplementsCommunicator(t *testing.T) { var raw interface{} raw = &LxcAttachCommunicator{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("Communicator should be a communicator") } } diff --git a/builder/lxc/step_provision.go b/builder/lxc/step_provision.go index c9ca5c812..a98283394 100644 --- a/builder/lxc/step_provision.go +++ b/builder/lxc/step_provision.go @@ -4,7 +4,6 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -14,7 +13,7 @@ import ( type StepProvision struct{} func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - hook := state.Get("hook").(packer.Hook) + hook := state.Get("hook").(packersdk.Hook) config := state.Get("config").(*Config) mountPath := state.Get("mount_path").(string) ui := state.Get("ui").(packersdk.Ui) @@ -37,7 +36,7 @@ func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multi // Provision log.Println("Running the provision hook") - if err := hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil { + if err := hook.Run(ctx, packersdk.HookProvision, ui, comm, hookData); err != nil { state.Put("error", err) return multistep.ActionHalt } diff --git a/builder/lxd/builder.go b/builder/lxd/builder.go index 8306f4bca..9fc618d50 100644 --- a/builder/lxd/builder.go +++ b/builder/lxd/builder.go @@ -4,7 +4,6 @@ import ( "context" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { wrappedCommand := func(command string) (string, error) { b.config.ctx.Data = &wrappedCommandTemplate{Command: command} return interpolate.Render(b.config.CommandWrapper, &b.config.ctx) diff --git a/builder/lxd/communicator.go b/builder/lxd/communicator.go index db118bcaa..d505e534f 100644 --- a/builder/lxd/communicator.go +++ b/builder/lxd/communicator.go @@ -10,7 +10,7 @@ import ( "path/filepath" "syscall" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Communicator struct { @@ -18,7 +18,7 @@ type Communicator struct { CmdWrapper CommandWrapper } -func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { localCmd, err := c.Execute(cmd.Command) if err != nil { @@ -61,7 +61,7 @@ func (c *Communicator) Upload(dst string, r io.Reader, fi *os.FileInfo) error { fileDestination := filepath.Join(c.ContainerName, dst) // find out if the place we are pushing to is a directory testDirectoryCommand := fmt.Sprintf(`test -d "%s"`, dst) - cmd := &packer.RemoteCmd{Command: testDirectoryCommand} + cmd := &packersdk.RemoteCmd{Command: testDirectoryCommand} err := c.Start(ctx, cmd) if err != nil { diff --git a/builder/lxd/communicator_test.go b/builder/lxd/communicator_test.go index 972a5dc18..2eaf87122 100644 --- a/builder/lxd/communicator_test.go +++ b/builder/lxd/communicator_test.go @@ -3,13 +3,13 @@ package lxd import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicator_ImplementsCommunicator(t *testing.T) { var raw interface{} raw = &Communicator{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("Communicator should be a communicator") } } diff --git a/builder/lxd/step_provision.go b/builder/lxd/step_provision.go index 5670dfbaf..a4d2f0d21 100644 --- a/builder/lxd/step_provision.go +++ b/builder/lxd/step_provision.go @@ -4,7 +4,6 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -14,7 +13,7 @@ import ( type StepProvision struct{} func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - hook := state.Get("hook").(packer.Hook) + hook := state.Get("hook").(packersdk.Hook) config := state.Get("config").(*Config) ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) @@ -34,7 +33,7 @@ func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multi // Provision log.Println("Running the provision hook") - if err := hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil { + if err := hook.Run(ctx, packersdk.HookProvision, ui, comm, hookData); err != nil { state.Put("error", err) return multistep.ActionHalt } diff --git a/builder/ncloud/builder.go b/builder/ncloud/builder.go index a690230f5..c3cabe03a 100644 --- a/builder/ncloud/builder.go +++ b/builder/ncloud/builder.go @@ -6,7 +6,6 @@ import ( "github.com/NaverCloudPlatform/ncloud-sdk-go-v2/services/server" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -32,7 +31,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { ui.Message("Creating Naver Cloud Platform Connection ...") config := Config{ AccessKey: b.config.AccessKey, diff --git a/builder/null/builder.go b/builder/null/builder.go index cc4f9ea9c..762277f1a 100644 --- a/builder/null/builder.go +++ b/builder/null/builder.go @@ -5,7 +5,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -29,7 +28,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { steps := []multistep.Step{} steps = append(steps, diff --git a/builder/oneandone/builder.go b/builder/oneandone/builder.go index f6a67ff7e..30ad23338 100644 --- a/builder/oneandone/builder.go +++ b/builder/oneandone/builder.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -31,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) diff --git a/builder/openstack/builder.go b/builder/openstack/builder.go index 17ee636a3..08ce7ad20 100644 --- a/builder/openstack/builder.go +++ b/builder/openstack/builder.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -73,7 +72,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { if b.config.PackerDebug { b.config.enableDebug(ui) } diff --git a/builder/oracle/classic/builder.go b/builder/oracle/classic/builder.go index f927259ff..52aaf7cb1 100644 --- a/builder/oracle/classic/builder.go +++ b/builder/oracle/classic/builder.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" ocommon "github.com/hashicorp/packer/builder/oracle/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -46,7 +45,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { loggingEnabled := os.Getenv("PACKER_OCI_CLASSIC_LOGGING") != "" httpClient := cleanhttp.DefaultClient() config := &opc.Config{ diff --git a/builder/oracle/classic/step_upload_image.go b/builder/oracle/classic/step_upload_image.go index a8519462a..061c28d38 100644 --- a/builder/oracle/classic/step_upload_image.go +++ b/builder/oracle/classic/step_upload_image.go @@ -6,7 +6,6 @@ import ( "log" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -27,7 +26,7 @@ type uploadCmdData struct { func (s *stepUploadImage) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packersdk.Ui) - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) config := state.Get("config").(*Config) runID := state.Get("run_id").(string) @@ -64,7 +63,7 @@ func (s *stepUploadImage) Run(ctx context.Context, state multistep.StateBag) mul dest := "/tmp/create-packer-diskimage.sh" comm.Upload(dest, strings.NewReader(command), nil) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("sudo /bin/sh %s", dest), } if err := cmd.RunWithUi(ctx, comm, ui); err != nil { diff --git a/builder/oracle/oci/builder.go b/builder/oracle/oci/builder.go index 93caea3b5..8bab1f151 100644 --- a/builder/oracle/oci/builder.go +++ b/builder/oracle/oci/builder.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" ocommon "github.com/hashicorp/packer/builder/oracle/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -39,7 +38,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { driver, err := NewDriverOCI(&b.config) if err != nil { return nil, err diff --git a/builder/osc/bsu/builder.go b/builder/osc/bsu/builder.go index 8498936e1..2694c5697 100644 --- a/builder/osc/bsu/builder.go +++ b/builder/osc/bsu/builder.go @@ -14,7 +14,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -85,7 +84,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { oscConn := b.config.NewOSCClient() // Setup the state bag and initial state for the steps diff --git a/builder/osc/bsusurrogate/builder.go b/builder/osc/bsusurrogate/builder.go index f3877cc06..bb3379a61 100644 --- a/builder/osc/bsusurrogate/builder.go +++ b/builder/osc/bsusurrogate/builder.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -103,7 +102,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { oscConn := b.config.NewOSCClient() // Setup the state bag and initial state for the steps diff --git a/builder/osc/bsuvolume/builder.go b/builder/osc/bsuvolume/builder.go index 9509be632..76ed194e9 100644 --- a/builder/osc/bsuvolume/builder.go +++ b/builder/osc/bsuvolume/builder.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -88,7 +87,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // clientConfig, err := b.config.Config() // if err != nil { // return nil, err diff --git a/builder/osc/chroot/builder.go b/builder/osc/chroot/builder.go index 7a72943d7..3aa0715ee 100644 --- a/builder/osc/chroot/builder.go +++ b/builder/osc/chroot/builder.go @@ -13,7 +13,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" osccommon "github.com/hashicorp/packer/builder/osc/common" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -188,7 +187,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warns, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { if runtime.GOOS != "linux" { return nil, errors.New("The outscale-chroot builder only works on Linux environments.") } diff --git a/builder/osc/chroot/communicator.go b/builder/osc/chroot/communicator.go index 8fc79163e..0389c55cf 100644 --- a/builder/osc/chroot/communicator.go +++ b/builder/osc/chroot/communicator.go @@ -13,7 +13,7 @@ import ( "strings" "syscall" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -24,7 +24,7 @@ type Communicator struct { CmdWrapper CommandWrapper } -func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { // need extra escapes for the command since we're wrapping it in quotes cmd.Command = strconv.Quote(cmd.Command) command, err := c.CmdWrapper( diff --git a/builder/osc/chroot/communicator_test.go b/builder/osc/chroot/communicator_test.go index 43995b79a..284782eb0 100644 --- a/builder/osc/chroot/communicator_test.go +++ b/builder/osc/chroot/communicator_test.go @@ -3,13 +3,13 @@ package chroot import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicator_ImplementsCommunicator(t *testing.T) { var raw interface{} raw = &Communicator{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("Communicator should be a communicator") } } diff --git a/builder/osc/chroot/run_local_commands.go b/builder/osc/chroot/run_local_commands.go index 0220db88d..fb96e1eb3 100644 --- a/builder/osc/chroot/run_local_commands.go +++ b/builder/osc/chroot/run_local_commands.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -27,7 +26,7 @@ func RunLocalCommands(commands []string, wrappedCommand CommandWrapper, ictx int comm := &sl.Communicator{ ExecuteCommand: []string{"sh", "-c", command}, } - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return fmt.Errorf("Error executing command: %s", err) } diff --git a/builder/osc/chroot/step_chroot_provision.go b/builder/osc/chroot/step_chroot_provision.go index 607c68306..68fc8d5f0 100644 --- a/builder/osc/chroot/step_chroot_provision.go +++ b/builder/osc/chroot/step_chroot_provision.go @@ -4,7 +4,6 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -15,7 +14,7 @@ type StepChrootProvision struct { } func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - hook := state.Get("hook").(packer.Hook) + hook := state.Get("hook").(packersdk.Hook) mountPath := state.Get("mount_path").(string) ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(CommandWrapper) @@ -35,7 +34,7 @@ func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) // Provision log.Println("Running the provision hook") - if err := hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil { + if err := hook.Run(ctx, packersdk.HookProvision, ui, comm, hookData); err != nil { state.Put("error", err) return multistep.ActionHalt } diff --git a/builder/parallels/common/step_shutdown.go b/builder/parallels/common/step_shutdown.go index 20c06a39a..7f6666e18 100644 --- a/builder/parallels/common/step_shutdown.go +++ b/builder/parallels/common/step_shutdown.go @@ -8,7 +8,6 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -17,7 +16,7 @@ import ( // so gracefully, but ultimately forcefully shuts it down if that fails. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // driver Driver // ui packersdk.Ui // vmName string @@ -31,7 +30,7 @@ type StepShutdown struct { // Run shuts down the VM. func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) @@ -41,7 +40,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis log.Printf("Executing shutdown command: %s", s.Command) var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: s.Command, Stdout: &stdout, Stderr: &stderr, diff --git a/builder/parallels/common/step_upload_parallels_tools.go b/builder/parallels/common/step_upload_parallels_tools.go index e50ca8923..3a6d93563 100644 --- a/builder/parallels/common/step_upload_parallels_tools.go +++ b/builder/parallels/common/step_upload_parallels_tools.go @@ -6,7 +6,6 @@ import ( "log" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -15,7 +14,7 @@ import ( // This step uploads the Parallels Tools ISO to the virtual machine. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // parallels_tools_path string // ui packersdk.Ui // @@ -28,7 +27,7 @@ type toolsPathTemplate struct { // to the VM. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // parallels_tools_path string // ui packersdk.Ui type StepUploadParallelsTools struct { @@ -40,7 +39,7 @@ type StepUploadParallelsTools struct { // Run uploads the Parallels Tools ISO to the VM. func (s *StepUploadParallelsTools) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) ui := state.Get("ui").(packersdk.Ui) // If we're attaching then don't do this, since we attached. diff --git a/builder/parallels/common/step_upload_version.go b/builder/parallels/common/step_upload_version.go index a42d6257d..d32480a3d 100644 --- a/builder/parallels/common/step_upload_version.go +++ b/builder/parallels/common/step_upload_version.go @@ -6,7 +6,6 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -15,7 +14,7 @@ import ( // Parallels Desktop, which can be useful for various provisioning reasons. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // driver Driver // ui packersdk.Ui type StepUploadVersion struct { @@ -24,7 +23,7 @@ type StepUploadVersion struct { // Run uploads a file containing the version of Parallels Desktop. func (s *StepUploadVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) diff --git a/builder/parallels/iso/builder.go b/builder/parallels/iso/builder.go index 3c4cdd769..f724bc9ff 100644 --- a/builder/parallels/iso/builder.go +++ b/builder/parallels/iso/builder.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -181,7 +180,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Parallels driver, err := parallelscommon.NewDriver() if err != nil { diff --git a/builder/parallels/pvm/builder.go b/builder/parallels/pvm/builder.go index 1235cc97b..6e9aad514 100644 --- a/builder/parallels/pvm/builder.go +++ b/builder/parallels/pvm/builder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" parallelscommon "github.com/hashicorp/packer/builder/parallels/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a Parallels appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Parallels driver, err := parallelscommon.NewDriver() if err != nil { diff --git a/builder/profitbricks/builder.go b/builder/profitbricks/builder.go index aa805f978..8f5585a04 100644 --- a/builder/profitbricks/builder.go +++ b/builder/profitbricks/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -30,7 +29,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("config", &b.config) diff --git a/builder/proxmox/clone/builder.go b/builder/proxmox/clone/builder.go index aeb675d22..45be41a9d 100644 --- a/builder/proxmox/clone/builder.go +++ b/builder/proxmox/clone/builder.go @@ -28,7 +28,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return b.config.Prepare(raws...) } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("clone-config", &b.config) diff --git a/builder/proxmox/common/builder.go b/builder/proxmox/common/builder.go index b61be22e7..467ce0def 100644 --- a/builder/proxmox/common/builder.go +++ b/builder/proxmox/common/builder.go @@ -8,7 +8,6 @@ import ( "github.com/Telmate/proxmox-api-go/proxmox" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ type Builder struct { vmCreator ProxmoxVMCreator } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook, state multistep.StateBag) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook, state multistep.StateBag) (packersdk.Artifact, error) { var err error tlsConfig := &tls.Config{ InsecureSkipVerify: b.config.SkipCertValidation, diff --git a/builder/proxmox/iso/builder.go b/builder/proxmox/iso/builder.go index da1050b2e..3eadef1f1 100644 --- a/builder/proxmox/iso/builder.go +++ b/builder/proxmox/iso/builder.go @@ -30,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { const downloadPathKey = "downloaded_iso_path" -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("iso-config", &b.config) diff --git a/builder/qemu/builder.go b/builder/qemu/builder.go index bf3482d2f..b810e5339 100644 --- a/builder/qemu/builder.go +++ b/builder/qemu/builder.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -35,7 +34,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with Qemu driver, err := b.newDriver(b.config.QemuBinary) if err != nil { diff --git a/builder/qemu/step_shutdown.go b/builder/qemu/step_shutdown.go index 594c8b3ff..862071b1a 100644 --- a/builder/qemu/step_shutdown.go +++ b/builder/qemu/step_shutdown.go @@ -8,7 +8,6 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -17,7 +16,7 @@ import ( // but ultimately forcefully shuts it down if that fails. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // config *config // driver Driver // ui packersdk.Ui @@ -53,10 +52,10 @@ func (s *stepShutdown) Run(ctx context.Context, state multistep.StateBag) multis } if s.ShutdownCommand != "" { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) ui.Say("Gracefully halting virtual machine...") log.Printf("Executing shutdown command: %s", s.ShutdownCommand) - cmd := &packer.RemoteCmd{Command: s.ShutdownCommand} + cmd := &packersdk.RemoteCmd{Command: s.ShutdownCommand} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { err := fmt.Errorf("Failed to send shutdown command: %s", err) state.Put("error", err) diff --git a/builder/scaleway/builder.go b/builder/scaleway/builder.go index e05bc805f..960aba889 100644 --- a/builder/scaleway/builder.go +++ b/builder/scaleway/builder.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -36,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { scwZone, err := scw.ParseZone(b.config.Zone) if err != nil { ui.Error(err.Error()) diff --git a/builder/tencentcloud/cvm/builder.go b/builder/tencentcloud/cvm/builder.go index 2f2a8acb0..de94e04a7 100644 --- a/builder/tencentcloud/cvm/builder.go +++ b/builder/tencentcloud/cvm/builder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -65,7 +64,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { cvmClient, vpcClient, err := b.config.Client() if err != nil { return nil, err diff --git a/builder/triton/builder.go b/builder/triton/builder.go index acbba7182..5aa6987fb 100644 --- a/builder/triton/builder.go +++ b/builder/triton/builder.go @@ -6,7 +6,6 @@ import ( "github.com/hashicorp/go-multierror" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -50,7 +49,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, errs.ErrorOrNil() } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { config := b.config driver, err := NewDriverTriton(ui, config) diff --git a/builder/ucloud/uhost/builder.go b/builder/ucloud/uhost/builder.go index 02a9da6cd..491f1e76d 100644 --- a/builder/ucloud/uhost/builder.go +++ b/builder/ucloud/uhost/builder.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" ucloudcommon "github.com/hashicorp/packer/builder/ucloud/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -68,7 +67,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, nil, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { client, err := b.config.Client() if err != nil { diff --git a/builder/vagrant/builder.go b/builder/vagrant/builder.go index 2e2398268..9499f0df7 100644 --- a/builder/vagrant/builder.go +++ b/builder/vagrant/builder.go @@ -15,7 +15,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -274,7 +273,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox VagrantCWD, err := filepath.Abs(b.config.OutputDir) if err != nil { diff --git a/builder/virtualbox/common/step_shutdown.go b/builder/virtualbox/common/step_shutdown.go index ce980847f..1c36b53cb 100644 --- a/builder/virtualbox/common/step_shutdown.go +++ b/builder/virtualbox/common/step_shutdown.go @@ -7,7 +7,6 @@ import ( "log" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -16,7 +15,7 @@ import ( // but ultimately forcefully shuts it down if that fails. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // driver Driver // ui packersdk.Ui // vmName string @@ -32,7 +31,7 @@ type StepShutdown struct { } func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) vmName := state.Get("vmName").(string) @@ -49,7 +48,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis if s.Command != "" { ui.Say("Gracefully halting virtual machine...") log.Printf("Executing shutdown command: %s", s.Command) - cmd := &packer.RemoteCmd{Command: s.Command} + cmd := &packersdk.RemoteCmd{Command: s.Command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { err := fmt.Errorf("Failed to send shutdown command: %s", err) state.Put("error", err) diff --git a/builder/virtualbox/common/step_upload_guest_additions.go b/builder/virtualbox/common/step_upload_guest_additions.go index ea7b6ef37..3dc2fbad7 100644 --- a/builder/virtualbox/common/step_upload_guest_additions.go +++ b/builder/virtualbox/common/step_upload_guest_additions.go @@ -6,7 +6,6 @@ import ( "log" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -24,7 +23,7 @@ type StepUploadGuestAdditions struct { } func (s *StepUploadGuestAdditions) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) diff --git a/builder/virtualbox/common/step_upload_version.go b/builder/virtualbox/common/step_upload_version.go index 46da0e6f1..7f2aa3860 100644 --- a/builder/virtualbox/common/step_upload_version.go +++ b/builder/virtualbox/common/step_upload_version.go @@ -6,7 +6,6 @@ import ( "fmt" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -18,7 +17,7 @@ type StepUploadVersion struct { } func (s *StepUploadVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) diff --git a/builder/virtualbox/iso/builder.go b/builder/virtualbox/iso/builder.go index d92a21bef..b284e0600 100644 --- a/builder/virtualbox/iso/builder.go +++ b/builder/virtualbox/iso/builder.go @@ -11,7 +11,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/bootcommand" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" @@ -231,7 +230,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/virtualbox/ovf/builder.go b/builder/virtualbox/ovf/builder.go index 6e0c311b0..098570d3e 100644 --- a/builder/virtualbox/ovf/builder.go +++ b/builder/virtualbox/ovf/builder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/virtualbox/vm/builder.go b/builder/virtualbox/vm/builder.go index 61828aa89..8e5f9ef71 100644 --- a/builder/virtualbox/vm/builder.go +++ b/builder/virtualbox/vm/builder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vboxcommon "github.com/hashicorp/packer/builder/virtualbox/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -34,7 +33,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a VirtualBox appliance. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { // Create the driver that we'll use to communicate with VirtualBox driver, err := vboxcommon.NewDriver() if err != nil { diff --git a/builder/vmware/common/driver_esx5.go b/builder/vmware/common/driver_esx5.go index 448698987..f40b496e9 100644 --- a/builder/vmware/common/driver_esx5.go +++ b/builder/vmware/common/driver_esx5.go @@ -30,7 +30,6 @@ import ( "github.com/hashicorp/go-getter/v2" "github.com/hashicorp/packer/helper/communicator" helperssh "github.com/hashicorp/packer/helper/communicator/ssh" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/ssh" @@ -57,7 +56,7 @@ type ESX5Driver struct { client *govmomi.Client finder *find.Finder - comm packer.Communicator + comm packersdk.Communicator outputDir string vmId string } @@ -865,7 +864,7 @@ func (d *ESX5Driver) ssh(command string, stdin io.Reader) (*bytes.Buffer, error) ctx := context.TODO() var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, Stdout: &stdout, Stderr: &stderr, diff --git a/builder/vmware/common/step_shutdown.go b/builder/vmware/common/step_shutdown.go index b1187672f..b78e355eb 100644 --- a/builder/vmware/common/step_shutdown.go +++ b/builder/vmware/common/step_shutdown.go @@ -10,7 +10,6 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -19,7 +18,7 @@ import ( // but ultimately forcefully shuts it down if that fails. // // Uses: -// communicator packer.Communicator +// communicator packersdk.Communicator // dir OutputDir // driver Driver // ui packersdk.Ui @@ -36,7 +35,7 @@ type StepShutdown struct { } func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) dir := state.Get("dir").(OutputDir) driver := state.Get("driver").(Driver) ui := state.Get("ui").(packersdk.Ui) @@ -47,7 +46,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis log.Printf("Executing shutdown command: %s", s.Command) var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: s.Command, Stdout: &stdout, Stderr: &stderr, diff --git a/builder/vmware/common/step_upload_tools.go b/builder/vmware/common/step_upload_tools.go index bd5063625..8fafa6193 100644 --- a/builder/vmware/common/step_upload_tools.go +++ b/builder/vmware/common/step_upload_tools.go @@ -5,7 +5,6 @@ import ( "fmt" "os" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -36,7 +35,7 @@ func (c *StepUploadTools) Run(ctx context.Context, state multistep.StateBag) mul return multistep.ActionContinue } - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) tools_source := state.Get("tools_upload_source").(string) ui := state.Get("ui").(packersdk.Ui) diff --git a/builder/vmware/iso/builder.go b/builder/vmware/iso/builder.go index 20bc1b9e2..4de29eb15 100644 --- a/builder/vmware/iso/builder.go +++ b/builder/vmware/iso/builder.go @@ -9,7 +9,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -31,7 +30,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, b.config.VMName) if err != nil { return nil, fmt.Errorf("Failed creating VMware driver: %s", err) diff --git a/builder/vmware/iso/step_create_vmx_test.go b/builder/vmware/iso/step_create_vmx_test.go index 9982998f8..80a216ad0 100644 --- a/builder/vmware/iso/step_create_vmx_test.go +++ b/builder/vmware/iso/step_create_vmx_test.go @@ -16,6 +16,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" "github.com/hashicorp/packer/provisioner/shell" ) @@ -140,7 +141,7 @@ func setupVMwareBuild(t *testing.T, builderConfig map[string]string, provisioner BuilderStore: packer.MapOfBuilder{ "vmware-iso": func() (packer.Builder, error) { return &Builder{}, nil }, }, - Hook: func(n string) (packer.Hook, error) { + Hook: func(n string) (packersdk.Hook, error) { return &packer.DispatchHook{}, nil }, ProvisionerStore: packer.MapOfProvisioner{ diff --git a/builder/vmware/vmx/builder.go b/builder/vmware/vmx/builder.go index c0542d3e4..e36c2711b 100644 --- a/builder/vmware/vmx/builder.go +++ b/builder/vmware/vmx/builder.go @@ -10,7 +10,6 @@ import ( "github.com/hashicorp/hcl/v2/hcldec" vmwcommon "github.com/hashicorp/packer/builder/vmware/common" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -36,7 +35,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a Packer build and returns a packersdk.Artifact representing // a VMware image. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { driver, err := vmwcommon.NewDriver(&b.config.DriverConfig, &b.config.SSHConfig, b.config.VMName) if err != nil { return nil, fmt.Errorf("Failed creating VMware driver: %s", err) diff --git a/builder/vsphere/clone/builder.go b/builder/vsphere/clone/builder.go index f9c993779..7f06a27f8 100644 --- a/builder/vsphere/clone/builder.go +++ b/builder/vsphere/clone/builder.go @@ -8,7 +8,6 @@ import ( "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -30,7 +29,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("debug", b.config.PackerDebug) state.Put("hook", hook) diff --git a/builder/vsphere/common/step_shutdown.go b/builder/vsphere/common/step_shutdown.go index 73f8594b7..501c71b59 100644 --- a/builder/vsphere/common/step_shutdown.go +++ b/builder/vsphere/common/step_shutdown.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -62,7 +61,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis return multistep.ActionContinue } - comm, _ := state.Get("communicator").(packer.Communicator) + comm, _ := state.Get("communicator").(packersdk.Communicator) if comm == nil { msg := fmt.Sprintf("Please shutdown virtual machine within %s.", s.Config.Timeout) @@ -77,7 +76,7 @@ func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multis log.Printf("Shutdown command: %s", s.Config.Command) var stdout, stderr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: s.Config.Command, Stdout: &stdout, Stderr: &stderr, diff --git a/builder/vsphere/iso/builder.go b/builder/vsphere/iso/builder.go index 1bd53675e..2a0fcf88b 100644 --- a/builder/vsphere/iso/builder.go +++ b/builder/vsphere/iso/builder.go @@ -7,7 +7,6 @@ import ( "github.com/hashicorp/packer/builder/vsphere/common" "github.com/hashicorp/packer/builder/vsphere/driver" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -29,7 +28,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { return nil, warnings, nil } -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { state := new(multistep.BasicStateBag) state.Put("debug", b.config.PackerDebug) state.Put("hook", hook) diff --git a/builder/yandex/builder.go b/builder/yandex/builder.go index be09ab378..88a13e372 100644 --- a/builder/yandex/builder.go +++ b/builder/yandex/builder.go @@ -7,7 +7,6 @@ import ( "github.com/google/uuid" "github.com/hashicorp/hcl/v2/hcldec" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -50,7 +49,7 @@ func (b *Builder) Prepare(raws ...interface{}) ([]string, []string, error) { // Run executes a yandex Packer build and returns a packersdk.Artifact // representing a Yandex.Cloud compute image. -func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *Builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { driver, err := NewDriverYC(ui, &b.config.AccessConfig) ctx = requestid.ContextWithClientTraceID(ctx, uuid.New().String()) diff --git a/command/build_parallel_test.go b/command/build_parallel_test.go index 27fc23272..16980b234 100644 --- a/command/build_parallel_test.go +++ b/command/build_parallel_test.go @@ -37,7 +37,7 @@ func (b *ParallelTestBuilder) Prepare(raws ...interface{}) ([]string, []string, return nil, nil, nil } -func (b *ParallelTestBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *ParallelTestBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { ui.Say("building") b.wg.Done() return nil, nil @@ -52,7 +52,7 @@ func (b *LockedBuilder) Prepare(raws ...interface{}) ([]string, []string, error) return nil, nil, nil } -func (b *LockedBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *LockedBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { ui.Say("locking build") select { case <-b.unlock: diff --git a/config.go b/config.go index 5ca68a193..5c54f8e80 100644 --- a/config.go +++ b/config.go @@ -14,6 +14,7 @@ import ( "github.com/hashicorp/packer/command" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer/plugin" ) @@ -187,8 +188,8 @@ func (c *config) StartBuilder(name string) (packer.Builder, error) { } // This is a proper implementation of packer.HookFunc that can be used -// to load packer.Hook implementations from the defined plugins. -func (c *config) StarHook(name string) (packer.Hook, error) { +// to load packersdk.Hook implementations from the defined plugins. +func (c *config) StarHook(name string) (packersdk.Hook, error) { log.Printf("Loading hook: %s\n", name) return c.pluginClient(name).Hook() } diff --git a/hcl2template/internal/mock.go b/hcl2template/internal/mock.go index f55ce6fb7..0bc620e54 100644 --- a/hcl2template/internal/mock.go +++ b/hcl2template/internal/mock.go @@ -78,7 +78,7 @@ func (b *MockBuilder) Prepare(raws ...interface{}) ([]string, []string, error) { return []string{"ID"}, nil, b.Config.Prepare(raws...) } -func (b *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { return nil, nil } @@ -100,7 +100,7 @@ func (b *MockProvisioner) Prepare(raws ...interface{}) error { return b.Config.Prepare(raws...) } -func (b *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (b *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { return nil } @@ -132,10 +132,10 @@ func (b *MockPostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, a type MockCommunicator struct { Config MockConfig - packer.Communicator + packersdk.Communicator } -var _ packer.ConfigurableCommunicator = new(MockCommunicator) +var _ packersdk.ConfigurableCommunicator = new(MockCommunicator) func (b *MockCommunicator) ConfigSpec() hcldec.ObjectSpec { return b.Config.FlatMapstructure().HCL2Spec() diff --git a/hcl2template/types.hcl_provisioner.go b/hcl2template/types.hcl_provisioner.go index dff9b31b5..d7cfcbd80 100644 --- a/hcl2template/types.hcl_provisioner.go +++ b/hcl2template/types.hcl_provisioner.go @@ -67,7 +67,7 @@ func (p *HCL2Provisioner) Prepare(args ...interface{}) error { return p.Provisioner.Prepare(args...) } -func (p *HCL2Provisioner) Provision(ctx context.Context, ui packersdk.Ui, c packer.Communicator, vars map[string]interface{}) error { +func (p *HCL2Provisioner) Provision(ctx context.Context, ui packersdk.Ui, c packersdk.Communicator, vars map[string]interface{}) error { err := p.HCL2Prepare(vars) if err != nil { return err diff --git a/helper/communicator/config.go b/helper/communicator/config.go index 0dcc21bbc..5a61b8482 100644 --- a/helper/communicator/config.go +++ b/helper/communicator/config.go @@ -15,6 +15,7 @@ import ( helperssh "github.com/hashicorp/packer/helper/communicator/ssh" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" packerssh "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/ssh" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -257,8 +258,8 @@ func (c *WinRM) Configure(raws ...interface{}) ([]string, error) { } var ( - _ packer.ConfigurableCommunicator = new(SSH) - _ packer.ConfigurableCommunicator = new(WinRM) + _ packersdk.ConfigurableCommunicator = new(SSH) + _ packersdk.ConfigurableCommunicator = new(WinRM) ) type SSHInterface struct { diff --git a/helper/communicator/step_connect_ssh.go b/helper/communicator/step_connect_ssh.go index 4b9e6b8c4..74ae42b32 100644 --- a/helper/communicator/step_connect_ssh.go +++ b/helper/communicator/step_connect_ssh.go @@ -37,7 +37,7 @@ type StepConnectSSH struct { func (s *StepConnectSSH) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packersdk.Ui) - var comm packer.Communicator + var comm packersdk.Communicator var err error subCtx, cancel := context.WithCancel(ctx) @@ -85,7 +85,7 @@ func (s *StepConnectSSH) Run(ctx context.Context, state multistep.StateBag) mult func (s *StepConnectSSH) Cleanup(multistep.StateBag) { } -func (s *StepConnectSSH) waitForSSH(state multistep.StateBag, ctx context.Context) (packer.Communicator, error) { +func (s *StepConnectSSH) waitForSSH(state multistep.StateBag, ctx context.Context) (packersdk.Communicator, error) { // Determine if we're using a bastion host, and if so, retrieve // that configuration. This configuration doesn't change so we // do this one before entering the retry loop. @@ -118,7 +118,7 @@ func (s *StepConnectSSH) waitForSSH(state multistep.StateBag, ctx context.Contex handshakeAttempts := 0 - var comm packer.Communicator + var comm packersdk.Communicator first := true for { // Don't check for cancel or wait on first iteration diff --git a/helper/communicator/step_connect_winrm.go b/helper/communicator/step_connect_winrm.go index 7452687b3..36630894a 100644 --- a/helper/communicator/step_connect_winrm.go +++ b/helper/communicator/step_connect_winrm.go @@ -13,7 +13,6 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/sdk-internals/communicator/winrm" @@ -29,7 +28,7 @@ import ( // ui packersdk.Ui // // Produces: -// communicator packer.Communicator +// communicator packersdk.Communicator type StepConnectWinRM struct { // All the fields below are documented on StepConnect Config *Config @@ -41,7 +40,7 @@ type StepConnectWinRM struct { func (s *StepConnectWinRM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packersdk.Ui) - var comm packer.Communicator + var comm packersdk.Communicator var err error subCtx, cancel := context.WithCancel(ctx) @@ -88,8 +87,8 @@ func (s *StepConnectWinRM) Run(ctx context.Context, state multistep.StateBag) mu func (s *StepConnectWinRM) Cleanup(multistep.StateBag) { } -func (s *StepConnectWinRM) waitForWinRM(state multistep.StateBag, ctx context.Context) (packer.Communicator, error) { - var comm packer.Communicator +func (s *StepConnectWinRM) waitForWinRM(state multistep.StateBag, ctx context.Context) (packersdk.Communicator, error) { + var comm packersdk.Communicator first := true for { // Don't check for cancel or wait on first iteration @@ -170,7 +169,7 @@ func (s *StepConnectWinRM) waitForWinRM(state multistep.StateBag, ctx context.Co var retryableSleep = 5 * time.Second // run an "echo" command to make sure that the winrm is connected for { - cmd := &packer.RemoteCmd{Command: connectCheckCommand} + cmd := &packersdk.RemoteCmd{Command: connectCheckCommand} var buf, buf2 bytes.Buffer cmd.Stdout = &buf cmd.Stdout = io.MultiWriter(cmd.Stdout, &buf2) diff --git a/packer-plugin-sdk/adapter/adapter.go b/packer-plugin-sdk/adapter/adapter.go index 230ffd34a..84c102ebf 100644 --- a/packer-plugin-sdk/adapter/adapter.go +++ b/packer-plugin-sdk/adapter/adapter.go @@ -12,23 +12,22 @@ import ( "strings" "github.com/google/shlex" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) // An adapter satisfies SSH requests (from an Ansible client) by delegating SSH -// exec and subsystem commands to a packer.Communicator. +// exec and subsystem commands to a packersdk.Communicator. type Adapter struct { done <-chan struct{} l net.Listener config *ssh.ServerConfig sftpCmd string ui packersdk.Ui - comm packer.Communicator + comm packersdk.Communicator } -func NewAdapter(done <-chan struct{}, l net.Listener, config *ssh.ServerConfig, sftpCmd string, ui packersdk.Ui, comm packer.Communicator) *Adapter { +func NewAdapter(done <-chan struct{}, l net.Listener, config *ssh.ServerConfig, sftpCmd string, ui packersdk.Ui, comm packersdk.Communicator) *Adapter { return &Adapter{ done: done, l: l, @@ -229,7 +228,7 @@ func (c *Adapter) scpExec(args string, in io.Reader, out io.Writer) error { } func (c *Adapter) remoteExec(command string, in io.Reader, out io.Writer, err io.Writer) int { - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Stdin: in, Stdout: out, Stderr: err, diff --git a/packer-plugin-sdk/adapter/adapter_test.go b/packer-plugin-sdk/adapter/adapter_test.go index bc3c03e4b..bfc3e7d3d 100644 --- a/packer-plugin-sdk/adapter/adapter_test.go +++ b/packer-plugin-sdk/adapter/adapter_test.go @@ -11,6 +11,7 @@ import ( "time" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -96,7 +97,7 @@ func (a addr) String() string { type communicator struct{} -func (c communicator) Start(context.Context, *packer.RemoteCmd) error { +func (c communicator) Start(context.Context, *packersdk.RemoteCmd) error { return errors.New("communicator not supported") } diff --git a/packer-plugin-sdk/adapter/scp.go b/packer-plugin-sdk/adapter/scp.go index 5fe6e45b2..100270aef 100644 --- a/packer-plugin-sdk/adapter/scp.go +++ b/packer-plugin-sdk/adapter/scp.go @@ -12,7 +12,7 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -36,7 +36,7 @@ well. send a 0 byte after file contents. */ -func scpUploadSession(opts []byte, rest string, in io.Reader, out io.Writer, comm packer.Communicator) error { +func scpUploadSession(opts []byte, rest string, in io.Reader, out io.Writer, comm packersdk.Communicator) error { rest = strings.TrimSpace(rest) if len(rest) == 0 { fmt.Fprintf(out, scpEmptyError) @@ -61,7 +61,7 @@ func scpUploadSession(opts []byte, rest string, in io.Reader, out io.Writer, com return state.Protocol(bufio.NewReader(in), out) } -func scpDownloadSession(opts []byte, rest string, in io.Reader, out io.Writer, comm packer.Communicator) error { +func scpDownloadSession(opts []byte, rest string, in io.Reader, out io.Writer, comm packersdk.Communicator) error { rest = strings.TrimSpace(rest) if len(rest) == 0 { fmt.Fprintf(out, scpEmptyError) @@ -121,7 +121,7 @@ func (state *scpDownloadState) FileProtocol(path string, info os.FileInfo, in *b } type scpUploadState struct { - comm packer.Communicator + comm packersdk.Communicator target string // target is the directory on the target srcRoot string // srcRoot is the directory on the host mtime time.Time diff --git a/packer-plugin-sdk/chroot/communicator.go b/packer-plugin-sdk/chroot/communicator.go index 33a6c4598..24ccc4277 100644 --- a/packer-plugin-sdk/chroot/communicator.go +++ b/packer-plugin-sdk/chroot/communicator.go @@ -13,8 +13,8 @@ import ( "strings" "syscall" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" ) @@ -25,7 +25,7 @@ type Communicator struct { CmdWrapper common.CommandWrapper } -func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { // need extra escapes for the command since we're wrapping it in quotes cmd.Command = strconv.Quote(cmd.Command) command, err := c.CmdWrapper( diff --git a/packer-plugin-sdk/chroot/communicator_test.go b/packer-plugin-sdk/chroot/communicator_test.go index 43995b79a..284782eb0 100644 --- a/packer-plugin-sdk/chroot/communicator_test.go +++ b/packer-plugin-sdk/chroot/communicator_test.go @@ -3,13 +3,13 @@ package chroot import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicator_ImplementsCommunicator(t *testing.T) { var raw interface{} raw = &Communicator{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("Communicator should be a communicator") } } diff --git a/packer-plugin-sdk/chroot/run_local_commands.go b/packer-plugin-sdk/chroot/run_local_commands.go index fce3d5154..e8b34a78d 100644 --- a/packer-plugin-sdk/chroot/run_local_commands.go +++ b/packer-plugin-sdk/chroot/run_local_commands.go @@ -4,7 +4,6 @@ import ( "context" "fmt" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" @@ -28,7 +27,7 @@ func RunLocalCommands(commands []string, wrappedCommand common.CommandWrapper, i comm := &sl.Communicator{ ExecuteCommand: []string{"sh", "-c", command}, } - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return fmt.Errorf("Error executing command: %s", err) } diff --git a/packer-plugin-sdk/chroot/step_chroot_provision.go b/packer-plugin-sdk/chroot/step_chroot_provision.go index 60f2c3a17..b22fefa04 100644 --- a/packer-plugin-sdk/chroot/step_chroot_provision.go +++ b/packer-plugin-sdk/chroot/step_chroot_provision.go @@ -4,7 +4,6 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" @@ -16,7 +15,7 @@ type StepChrootProvision struct { } func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - hook := state.Get("hook").(packer.Hook) + hook := state.Get("hook").(packersdk.Hook) mountPath := state.Get("mount_path").(string) ui := state.Get("ui").(packersdk.Ui) wrappedCommand := state.Get("wrappedCommand").(common.CommandWrapper) @@ -36,7 +35,7 @@ func (s *StepChrootProvision) Run(ctx context.Context, state multistep.StateBag) // Provision log.Println("Running the provision hook") - if err := hook.Run(ctx, packer.HookProvision, ui, comm, hookData); err != nil { + if err := hook.Run(ctx, packersdk.HookProvision, ui, comm, hookData); err != nil { state.Put("error", err) return multistep.ActionHalt } diff --git a/packer-plugin-sdk/guestexec/elevated.go b/packer-plugin-sdk/guestexec/elevated.go index 4abfc99af..9dca69717 100644 --- a/packer-plugin-sdk/guestexec/elevated.go +++ b/packer-plugin-sdk/guestexec/elevated.go @@ -8,12 +8,12 @@ import ( "strings" "text/template" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/uuid" ) type ElevatedProvisioner interface { - Communicator() packer.Communicator + Communicator() packersdk.Communicator ElevatedUser() string ElevatedPassword() string } diff --git a/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go b/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go index aa9924797..207515e5c 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_cleanup_temp_keys.go @@ -6,7 +6,6 @@ import ( "log" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -32,10 +31,10 @@ func (s *StepCleanupTempKeys) Run(ctx context.Context, state multistep.StateBag) return multistep.ActionContinue } - comm := state.Get("communicator").(packer.Communicator) + comm := state.Get("communicator").(packersdk.Communicator) ui := state.Get("ui").(packersdk.Ui) - cmd := new(packer.RemoteCmd) + cmd := new(packersdk.RemoteCmd) ui.Say("Trying to remove ephemeral keys from authorized_keys files") @@ -60,7 +59,7 @@ func (s *StepCleanupTempKeys) Run(ctx context.Context, state multistep.StateBag) if err := cmd.RunWithUi(ctx, comm, ui); err != nil { log.Printf("Error cleaning up ~/.ssh/authorized_keys; please clean up keys manually: %s", err) } - cmd = new(packer.RemoteCmd) + cmd = new(packersdk.RemoteCmd) cmd.Command = fmt.Sprintf("sudo sed -i.bak '/ %s$/d' /root/.ssh/authorized_keys; sudo rm /root/.ssh/authorized_keys.bak", s.Comm.SSHTemporaryKeyPairName) if err := cmd.RunWithUi(ctx, comm, ui); err != nil { log.Printf("Error cleaning up /root/.ssh/authorized_keys; please clean up keys manually: %s", err) diff --git a/packer-plugin-sdk/multistep/commonsteps/step_provision.go b/packer-plugin-sdk/multistep/commonsteps/step_provision.go index a7118b84c..3a78d5d73 100644 --- a/packer-plugin-sdk/multistep/commonsteps/step_provision.go +++ b/packer-plugin-sdk/multistep/commonsteps/step_provision.go @@ -9,7 +9,6 @@ import ( "time" "github.com/hashicorp/packer/helper/communicator" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -17,8 +16,8 @@ import ( // StepProvision runs the provisioners. // // Uses: -// communicator packer.Communicator -// hook packer.Hook +// communicator packersdk.Communicator +// hook packersdk.Hook // ui packersdk.Ui // // Produces: @@ -96,20 +95,20 @@ func PopulateProvisionHookData(state multistep.StateBag) map[string]interface{} } type StepProvision struct { - Comm packer.Communicator + Comm packersdk.Communicator } func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBag, hooktype string) multistep.StepAction { - // hooktype will be either packer.HookProvision or packer.HookCleanupProvision + // hooktype will be either packersdk.HookProvision or packersdk.HookCleanupProvision comm := s.Comm if comm == nil { - raw, ok := state.Get("communicator").(packer.Communicator) + raw, ok := state.Get("communicator").(packersdk.Communicator) if ok { - comm = raw.(packer.Communicator) + comm = raw.(packersdk.Communicator) } } - hook := state.Get("hook").(packer.Hook) + hook := state.Get("hook").(packersdk.Hook) ui := state.Get("ui").(packersdk.Ui) hookData := PopulateProvisionHookData(state) @@ -120,9 +119,9 @@ func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBa // Run the provisioner in a goroutine so we can continually check // for cancellations... - if hooktype == packer.HookProvision { + if hooktype == packersdk.HookProvision { log.Println("Running the provision hook") - } else if hooktype == packer.HookCleanupProvision { + } else if hooktype == packersdk.HookCleanupProvision { ui.Say("Provisioning step had errors: Running the cleanup provisioner, if present...") } errCh := make(chan error, 1) @@ -134,11 +133,11 @@ func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBa select { case err := <-errCh: if err != nil { - if hooktype == packer.HookProvision { + if hooktype == packersdk.HookProvision { // We don't overwrite the error if it's a cleanup // provisioner being run. state.Put("error", err) - } else if hooktype == packer.HookCleanupProvision { + } else if hooktype == packersdk.HookCleanupProvision { origErr := state.Get("error").(error) state.Put("error", fmt.Errorf("Cleanup failed: %s. "+ "Original Provisioning error: %s", err, origErr)) @@ -160,7 +159,7 @@ func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBa } func (s *StepProvision) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { - return s.runWithHook(ctx, state, packer.HookProvision) + return s.runWithHook(ctx, state, packersdk.HookProvision) } func (s *StepProvision) Cleanup(state multistep.StateBag) { @@ -168,6 +167,6 @@ func (s *StepProvision) Cleanup(state multistep.StateBag) { // which we only call if there's an error during the provision run and // the "error-cleanup-provisioner" is defined. if _, ok := state.GetOk("error"); ok { - s.runWithHook(context.Background(), state, packer.HookCleanupProvision) + s.runWithHook(context.Background(), state, packersdk.HookCleanupProvision) } } diff --git a/packer/communicator.go b/packer-plugin-sdk/packer/communicator.go similarity index 98% rename from packer/communicator.go rename to packer-plugin-sdk/packer/communicator.go index 6bf76e86a..026737d4b 100644 --- a/packer/communicator.go +++ b/packer-plugin-sdk/packer/communicator.go @@ -8,7 +8,6 @@ import ( "sync" "unicode" - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/mitchellh/iochan" ) @@ -89,7 +88,7 @@ type ConfigurableCommunicator interface { // RunWithUi runs the remote command and streams the output to any configured // Writers for stdout/stderr, while also writing each line as it comes to a Ui. // RunWithUi will not return until the command finishes or is cancelled. -func (r *RemoteCmd) RunWithUi(ctx context.Context, c Communicator, ui packersdk.Ui) error { +func (r *RemoteCmd) RunWithUi(ctx context.Context, c Communicator, ui Ui) error { r.initchan() stdout_r, stdout_w := io.Pipe() diff --git a/packer/communicator_mock.go b/packer-plugin-sdk/packer/communicator_mock.go similarity index 100% rename from packer/communicator_mock.go rename to packer-plugin-sdk/packer/communicator_mock.go diff --git a/packer/communicator_mock_test.go b/packer-plugin-sdk/packer/communicator_mock_test.go similarity index 100% rename from packer/communicator_mock_test.go rename to packer-plugin-sdk/packer/communicator_mock_test.go diff --git a/packer/communicator_test.go b/packer-plugin-sdk/packer/communicator_test.go similarity index 100% rename from packer/communicator_test.go rename to packer-plugin-sdk/packer/communicator_test.go diff --git a/packer/hcl2spec.go b/packer-plugin-sdk/packer/hcl2spec.go similarity index 100% rename from packer/hcl2spec.go rename to packer-plugin-sdk/packer/hcl2spec.go diff --git a/packer/hook.go b/packer-plugin-sdk/packer/hook.go similarity index 88% rename from packer/hook.go rename to packer-plugin-sdk/packer/hook.go index 583fcb706..ee8104ac9 100644 --- a/packer/hook.go +++ b/packer-plugin-sdk/packer/hook.go @@ -2,8 +2,6 @@ package packer import ( "context" - - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // This is the hook that should be fired for provisioners to run. @@ -24,7 +22,7 @@ const HookCleanupProvision = "packer_cleanup_provision" // must be race-free. Cancel should attempt to cancel the hook in the quickest, // safest way possible. type Hook interface { - Run(context.Context, string, packersdk.Ui, Communicator, interface{}) error + Run(context.Context, string, Ui, Communicator, interface{}) error } // A Hook implementation that dispatches based on an internal mapping. @@ -35,7 +33,7 @@ type DispatchHook struct { // Runs the hook with the given name by dispatching it to the proper // hooks if a mapping exists. If a mapping doesn't exist, then nothing // happens. -func (h *DispatchHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm Communicator, data interface{}) error { +func (h *DispatchHook) Run(ctx context.Context, name string, ui Ui, comm Communicator, data interface{}) error { hooks, ok := h.Mapping[name] if !ok { // No hooks for that name. No problem. diff --git a/packer/hook_mock.go b/packer-plugin-sdk/packer/hook_mock.go similarity index 66% rename from packer/hook_mock.go rename to packer-plugin-sdk/packer/hook_mock.go index f6243f988..16571f1fe 100644 --- a/packer/hook_mock.go +++ b/packer-plugin-sdk/packer/hook_mock.go @@ -2,8 +2,6 @@ package packer import ( "context" - - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) // MockHook is an implementation of Hook that can be used for tests. @@ -14,10 +12,10 @@ type MockHook struct { RunComm Communicator RunData interface{} RunName string - RunUi packersdk.Ui + RunUi Ui } -func (t *MockHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm Communicator, data interface{}) error { +func (t *MockHook) Run(ctx context.Context, name string, ui Ui, comm Communicator, data interface{}) error { t.RunCalled = true t.RunComm = comm diff --git a/packer/hook_test.go b/packer-plugin-sdk/packer/hook_test.go similarity index 88% rename from packer/hook_test.go rename to packer-plugin-sdk/packer/hook_test.go index 8bbbb943e..efe0f0fd0 100644 --- a/packer/hook_test.go +++ b/packer-plugin-sdk/packer/hook_test.go @@ -3,8 +3,6 @@ package packer import ( "context" "testing" - - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestDispatchHook_Implements(t *testing.T) { @@ -42,7 +40,7 @@ type CancelHook struct { cancel func() } -func (h *CancelHook) Run(ctx context.Context, _ string, _ packersdk.Ui, _ Communicator, _ interface{}) error { +func (h *CancelHook) Run(ctx context.Context, _ string, _ Ui, _ Communicator, _ interface{}) error { h.cancel() <-ctx.Done() return ctx.Err() diff --git a/packer-plugin-sdk/sdk-internals/communicator/none/communicator.go b/packer-plugin-sdk/sdk-internals/communicator/none/communicator.go index ac8fb1c12..63780ac5a 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/none/communicator.go +++ b/packer-plugin-sdk/sdk-internals/communicator/none/communicator.go @@ -6,14 +6,14 @@ import ( "io" "os" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type comm struct { config string } -// Creates a null packer.Communicator implementation. This takes +// Creates a null packersdk.Communicator implementation. This takes // an already existing configuration. func New(config string) (result *comm, err error) { // Establish an initial connection and connect @@ -24,7 +24,7 @@ func New(config string) (result *comm, err error) { return } -func (c *comm) Start(ctx context.Context, cmd *packer.RemoteCmd) (err error) { +func (c *comm) Start(ctx context.Context, cmd *packersdk.RemoteCmd) (err error) { cmd.SetExited(0) return } diff --git a/packer-plugin-sdk/sdk-internals/communicator/none/communicator_test.go b/packer-plugin-sdk/sdk-internals/communicator/none/communicator_test.go index 081fbfe77..1c22a08ec 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/none/communicator_test.go +++ b/packer-plugin-sdk/sdk-internals/communicator/none/communicator_test.go @@ -3,13 +3,13 @@ package none import ( "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommIsCommunicator(t *testing.T) { var raw interface{} raw = &comm{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("comm must be a communicator") } } diff --git a/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator.go b/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator.go index 03250953d..c351fd0c0 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator.go +++ b/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator.go @@ -16,7 +16,7 @@ import ( "strings" "time" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/tmp" "github.com/pkg/sftp" "golang.org/x/crypto/ssh" @@ -86,7 +86,7 @@ type Config struct { Tunnels []TunnelSpec } -// Creates a new packer.Communicator implementation over SSH. This takes +// Creates a new packersdk.Communicator implementation over SSH. This takes // an already existing TCP connection and SSH configuration. func New(address string, config *Config) (result *comm, err error) { // Establish an initial connection and connect @@ -103,7 +103,7 @@ func New(address string, config *Config) (result *comm, err error) { return } -func (c *comm) Start(ctx context.Context, cmd *packer.RemoteCmd) (err error) { +func (c *comm) Start(ctx context.Context, cmd *packersdk.RemoteCmd) (err error) { session, err := c.newSession() if err != nil { return @@ -161,7 +161,7 @@ func (c *comm) Start(ctx context.Context, cmd *packer.RemoteCmd) (err error) { log.Printf("[ERROR] Remote command exited with '%d': %s", exitStatus, cmd.Command) case *ssh.ExitMissingError: log.Printf("[ERROR] Remote command exited without exit status or exit signal.") - exitStatus = packer.CmdDisconnect + exitStatus = packersdk.CmdDisconnect default: log.Printf("[ERROR] Error occurred waiting for ssh session: %s", err.Error()) } diff --git a/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator_test.go b/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator_test.go index c985d6082..d84097567 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator_test.go +++ b/packer-plugin-sdk/sdk-internals/communicator/ssh/communicator_test.go @@ -10,7 +10,7 @@ import ( "testing" "time" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "golang.org/x/crypto/ssh" ) @@ -122,7 +122,7 @@ func newMockBrokenServer(t *testing.T) string { func TestCommIsCommunicator(t *testing.T) { var raw interface{} raw = &comm{} - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatalf("comm must be a communicator") } } @@ -184,7 +184,7 @@ func TestStart(t *testing.T) { t.Fatalf("error connecting to SSH: %s", err) } - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: "echo foo", Stdout: new(bytes.Buffer), } diff --git a/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator.go b/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator.go index 1e543dceb..6739e1957 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator.go +++ b/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator.go @@ -12,7 +12,7 @@ import ( "strings" "sync" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/masterzen/winrm" "github.com/packer-community/winrmcp/winrmcp" ) @@ -75,7 +75,7 @@ func New(config *Config) (*Communicator, error) { } // Start implementation of communicator.Communicator interface -func (c *Communicator) Start(ctx context.Context, rc *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, rc *packersdk.RemoteCmd) error { shell, err := c.client.CreateShell() if err != nil { return err @@ -91,7 +91,7 @@ func (c *Communicator) Start(ctx context.Context, rc *packer.RemoteCmd) error { return nil } -func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packer.RemoteCmd) { +func runCommand(shell *winrm.Shell, cmd *winrm.Command, rc *packersdk.RemoteCmd) { defer shell.Close() var wg sync.WaitGroup diff --git a/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator_test.go b/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator_test.go index b7bc78304..061cef724 100644 --- a/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator_test.go +++ b/packer-plugin-sdk/sdk-internals/communicator/winrm/communicator_test.go @@ -9,7 +9,7 @@ import ( "time" "github.com/dylanmei/winrmtest" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) const PAYLOAD = "stuff" @@ -74,7 +74,7 @@ func TestStart(t *testing.T) { t.Fatalf("error creating communicator: %s", err) } - var cmd packer.RemoteCmd + var cmd packersdk.RemoteCmd stdout := new(bytes.Buffer) cmd.Command = "echo foo" cmd.Stdout = stdout diff --git a/packer-plugin-sdk/shell-local/communicator.go b/packer-plugin-sdk/shell-local/communicator.go index 9b99b38bb..bc4e66e5b 100644 --- a/packer-plugin-sdk/shell-local/communicator.go +++ b/packer-plugin-sdk/shell-local/communicator.go @@ -9,14 +9,14 @@ import ( "os/exec" "syscall" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type Communicator struct { ExecuteCommand []string } -func (c *Communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *Communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { if len(c.ExecuteCommand) == 0 { return fmt.Errorf("Error launching command via shell-local communicator: No ExecuteCommand provided") } diff --git a/packer-plugin-sdk/shell-local/communicator_test.go b/packer-plugin-sdk/shell-local/communicator_test.go index bc544a2ca..1e62a0c3b 100644 --- a/packer-plugin-sdk/shell-local/communicator_test.go +++ b/packer-plugin-sdk/shell-local/communicator_test.go @@ -7,11 +7,11 @@ import ( "strings" "testing" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicator_impl(t *testing.T) { - var _ packer.Communicator = new(Communicator) + var _ packersdk.Communicator = new(Communicator) } func TestCommunicator(t *testing.T) { @@ -25,7 +25,7 @@ func TestCommunicator(t *testing.T) { } var buf bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Stdout: &buf, } diff --git a/packer-plugin-sdk/shell-local/run.go b/packer-plugin-sdk/shell-local/run.go index 9b7a0b961..eae6dedfa 100644 --- a/packer-plugin-sdk/shell-local/run.go +++ b/packer-plugin-sdk/shell-local/run.go @@ -11,7 +11,6 @@ import ( "sort" "strings" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/interpolate" @@ -97,7 +96,7 @@ func Run(ctx context.Context, ui packersdk.Ui, config *Config, generatedData map // the other communicators; ultimately, this command is just used for // buffers and for reading the final exit status. flattenedCmd := strings.Join(interpolatedCmds, " ") - cmd := &packer.RemoteCmd{Command: flattenedCmd} + cmd := &packersdk.RemoteCmd{Command: flattenedCmd} log.Printf("[INFO] (shell-local): starting local command: %s", flattenedCmd) if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return false, fmt.Errorf( diff --git a/packer/build.go b/packer/build.go index ba6ee5419..5eb4213db 100644 --- a/packer/build.go +++ b/packer/build.go @@ -98,7 +98,7 @@ type CoreBuild struct { Builder Builder BuilderConfig interface{} BuilderType string - hooks map[string][]Hook + hooks map[string][]packersdk.Hook Provisioners []CoreBuildProvisioner PostProcessors [][]CoreBuildPostProcessor CleanupProvisioner CoreBuildProvisioner @@ -238,9 +238,9 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packers } // Copy the hooks - hooks := make(map[string][]Hook) + hooks := make(map[string][]packersdk.Hook) for hookName, hookList := range b.hooks { - hooks[hookName] = make([]Hook, len(hookList)) + hooks[hookName] = make([]packersdk.Hook, len(hookList)) copy(hooks[hookName], hookList) } @@ -267,11 +267,11 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packers } } - if _, ok := hooks[HookProvision]; !ok { - hooks[HookProvision] = make([]Hook, 0, 1) + if _, ok := hooks[packersdk.HookProvision]; !ok { + hooks[packersdk.HookProvision] = make([]packersdk.Hook, 0, 1) } - hooks[HookProvision] = append(hooks[HookProvision], &ProvisionHook{ + hooks[packersdk.HookProvision] = append(hooks[packersdk.HookProvision], &ProvisionHook{ Provisioners: hookedProvisioners, }) } @@ -282,12 +282,12 @@ func (b *CoreBuild) Run(ctx context.Context, originalUi packersdk.Ui) ([]packers b.CleanupProvisioner.config, b.CleanupProvisioner.PType, } - hooks[HookCleanupProvision] = []Hook{&ProvisionHook{ + hooks[packersdk.HookCleanupProvision] = []packersdk.Hook{&ProvisionHook{ Provisioners: []*HookedProvisioner{hookedCleanupProvisioner}, }} } - hook := &DispatchHook{Mapping: hooks} + hook := &packersdk.DispatchHook{Mapping: hooks} artifacts := make([]packersdk.Artifact, 0, 1) // The builder just has a normal Ui, but targeted diff --git a/packer/builder.go b/packer/builder.go index b189dd6e8..586ae4a4e 100644 --- a/packer/builder.go +++ b/packer/builder.go @@ -17,7 +17,7 @@ import ( // parallelism is strictly disabled, so it is safe to request input from // stdin and so on. type Builder interface { - HCL2Speccer + packersdk.HCL2Speccer // Prepare is responsible for configuring the builder and validating // that configuration. Any setup should be done in this method. Note that @@ -37,5 +37,5 @@ type Builder interface { Prepare(...interface{}) ([]string, []string, error) // Run is where the actual build should take place. It takes a Build and a Ui. - Run(context.Context, packersdk.Ui, Hook) (packersdk.Artifact, error) + Run(context.Context, packersdk.Ui, packersdk.Hook) (packersdk.Artifact, error) } diff --git a/packer/builder_mock.go b/packer/builder_mock.go index 7802d8d3b..6a7f03c7d 100644 --- a/packer/builder_mock.go +++ b/packer/builder_mock.go @@ -22,7 +22,7 @@ type MockBuilder struct { PrepareCalled bool PrepareConfig []interface{} RunCalled bool - RunHook Hook + RunHook packersdk.Hook RunUi packersdk.Ui CancelCalled bool RunFn func(ctx context.Context) @@ -40,7 +40,7 @@ func (tb *MockBuilder) Prepare(config ...interface{}) ([]string, []string, error return tb.GeneratedVars, tb.PrepareWarnings, nil } -func (tb *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, h Hook) (packersdk.Artifact, error) { +func (tb *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, h packersdk.Hook) (packersdk.Artifact, error) { tb.RunCalled = true tb.RunHook = h tb.RunUi = ui @@ -57,7 +57,7 @@ func (tb *MockBuilder) Run(ctx context.Context, ui packersdk.Ui, h Hook) (packer } if h != nil { - if err := h.Run(ctx, HookProvision, ui, new(MockCommunicator), nil); err != nil { + if err := h.Run(ctx, packersdk.HookProvision, ui, new(packersdk.MockCommunicator), nil); err != nil { return nil, err } } diff --git a/packer/builder_mock.hcl2spec.go b/packer/builder_mock.hcl2spec.go index e7c7f85ba..0dfe58a08 100644 --- a/packer/builder_mock.hcl2spec.go +++ b/packer/builder_mock.hcl2spec.go @@ -2,10 +2,8 @@ package packer import ( - "io" - "github.com/hashicorp/hcl/v2/hcldec" - packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" + "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/zclconf/go-cty/cty" ) @@ -19,8 +17,8 @@ type FlatMockBuilder struct { PrepareCalled *bool `cty:"prepare_called" hcl:"prepare_called"` PrepareConfig []interface{} `cty:"prepare_config" hcl:"prepare_config"` RunCalled *bool `cty:"run_called" hcl:"run_called"` - RunHook Hook `cty:"run_hook" hcl:"run_hook"` - RunUi packersdk.Ui `cty:"run_ui" hcl:"run_ui"` + RunHook packer.Hook `cty:"run_hook" hcl:"run_hook"` + RunUi packer.Ui `cty:"run_ui" hcl:"run_ui"` CancelCalled *bool `cty:"cancel_called" hcl:"cancel_called"` GeneratedVars []string `cty:"generated_vars" hcl:"generated_vars"` } @@ -52,76 +50,19 @@ func (*FlatMockBuilder) HCL2Spec() map[string]hcldec.Spec { return s } -// FlatMockCommunicator is an auto-generated flat version of MockCommunicator. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatMockCommunicator struct { - StartCalled *bool `cty:"start_called" hcl:"start_called"` - StartCmd *FlatRemoteCmd `cty:"start_cmd" hcl:"start_cmd"` - StartStderr *string `cty:"start_stderr" hcl:"start_stderr"` - StartStdout *string `cty:"start_stdout" hcl:"start_stdout"` - StartStdin *string `cty:"start_stdin" hcl:"start_stdin"` - StartExitStatus *int `cty:"start_exit_status" hcl:"start_exit_status"` - UploadCalled *bool `cty:"upload_called" hcl:"upload_called"` - UploadPath *string `cty:"upload_path" hcl:"upload_path"` - UploadData *string `cty:"upload_data" hcl:"upload_data"` - UploadDirDst *string `cty:"upload_dir_dst" hcl:"upload_dir_dst"` - UploadDirSrc *string `cty:"upload_dir_src" hcl:"upload_dir_src"` - UploadDirExclude []string `cty:"upload_dir_exclude" hcl:"upload_dir_exclude"` - DownloadDirDst *string `cty:"download_dir_dst" hcl:"download_dir_dst"` - DownloadDirSrc *string `cty:"download_dir_src" hcl:"download_dir_src"` - DownloadDirExclude []string `cty:"download_dir_exclude" hcl:"download_dir_exclude"` - DownloadCalled *bool `cty:"download_called" hcl:"download_called"` - DownloadPath *string `cty:"download_path" hcl:"download_path"` - DownloadData *string `cty:"download_data" hcl:"download_data"` -} - -// FlatMapstructure returns a new FlatMockCommunicator. -// FlatMockCommunicator is an auto-generated flat version of MockCommunicator. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*MockCommunicator) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatMockCommunicator) -} - -// HCL2Spec returns the hcl spec of a MockCommunicator. -// This spec is used by HCL to read the fields of MockCommunicator. -// The decoded values from this spec will then be applied to a FlatMockCommunicator. -func (*FlatMockCommunicator) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "start_called": &hcldec.AttrSpec{Name: "start_called", Type: cty.Bool, Required: false}, - "start_cmd": &hcldec.BlockSpec{TypeName: "start_cmd", Nested: hcldec.ObjectSpec((*FlatRemoteCmd)(nil).HCL2Spec())}, - "start_stderr": &hcldec.AttrSpec{Name: "start_stderr", Type: cty.String, Required: false}, - "start_stdout": &hcldec.AttrSpec{Name: "start_stdout", Type: cty.String, Required: false}, - "start_stdin": &hcldec.AttrSpec{Name: "start_stdin", Type: cty.String, Required: false}, - "start_exit_status": &hcldec.AttrSpec{Name: "start_exit_status", Type: cty.Number, Required: false}, - "upload_called": &hcldec.AttrSpec{Name: "upload_called", Type: cty.Bool, Required: false}, - "upload_path": &hcldec.AttrSpec{Name: "upload_path", Type: cty.String, Required: false}, - "upload_data": &hcldec.AttrSpec{Name: "upload_data", Type: cty.String, Required: false}, - "upload_dir_dst": &hcldec.AttrSpec{Name: "upload_dir_dst", Type: cty.String, Required: false}, - "upload_dir_src": &hcldec.AttrSpec{Name: "upload_dir_src", Type: cty.String, Required: false}, - "upload_dir_exclude": &hcldec.AttrSpec{Name: "upload_dir_exclude", Type: cty.List(cty.String), Required: false}, - "download_dir_dst": &hcldec.AttrSpec{Name: "download_dir_dst", Type: cty.String, Required: false}, - "download_dir_src": &hcldec.AttrSpec{Name: "download_dir_src", Type: cty.String, Required: false}, - "download_dir_exclude": &hcldec.AttrSpec{Name: "download_dir_exclude", Type: cty.List(cty.String), Required: false}, - "download_called": &hcldec.AttrSpec{Name: "download_called", Type: cty.Bool, Required: false}, - "download_path": &hcldec.AttrSpec{Name: "download_path", Type: cty.String, Required: false}, - "download_data": &hcldec.AttrSpec{Name: "download_data", Type: cty.String, Required: false}, - } - return s -} - // FlatMockPostProcessor is an auto-generated flat version of MockPostProcessor. // Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. type FlatMockPostProcessor struct { - ArtifactId *string `cty:"artifact_id" hcl:"artifact_id"` - Keep *bool `cty:"keep" hcl:"keep"` - ForceOverride *bool `cty:"force_override" hcl:"force_override"` - Error error `cty:"error" hcl:"error"` - ConfigureCalled *bool `cty:"configure_called" hcl:"configure_called"` - ConfigureConfigs []interface{} `cty:"configure_configs" hcl:"configure_configs"` - ConfigureError error `cty:"configure_error" hcl:"configure_error"` - PostProcessCalled *bool `cty:"post_process_called" hcl:"post_process_called"` - PostProcessArtifact packersdk.Artifact `cty:"post_process_artifact" hcl:"post_process_artifact"` - PostProcessUi packersdk.Ui `cty:"post_process_ui" hcl:"post_process_ui"` + ArtifactId *string `cty:"artifact_id" hcl:"artifact_id"` + Keep *bool `cty:"keep" hcl:"keep"` + ForceOverride *bool `cty:"force_override" hcl:"force_override"` + Error error `cty:"error" hcl:"error"` + ConfigureCalled *bool `cty:"configure_called" hcl:"configure_called"` + ConfigureConfigs []interface{} `cty:"configure_configs" hcl:"configure_configs"` + ConfigureError error `cty:"configure_error" hcl:"configure_error"` + PostProcessCalled *bool `cty:"post_process_called" hcl:"post_process_called"` + PostProcessArtifact packer.Artifact `cty:"post_process_artifact" hcl:"post_process_artifact"` + PostProcessUi packer.Ui `cty:"post_process_ui" hcl:"post_process_ui"` } // FlatMapstructure returns a new FlatMockPostProcessor. @@ -153,12 +94,12 @@ func (*FlatMockPostProcessor) HCL2Spec() map[string]hcldec.Spec { // FlatMockProvisioner is an auto-generated flat version of MockProvisioner. // Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. type FlatMockProvisioner struct { - PrepCalled *bool `cty:"prep_called" hcl:"prep_called"` - PrepConfigs []interface{} `cty:"prep_configs" hcl:"prep_configs"` - ProvCalled *bool `cty:"prov_called" hcl:"prov_called"` - ProvRetried *bool `cty:"prov_retried" hcl:"prov_retried"` - ProvCommunicator Communicator `cty:"prov_communicator" hcl:"prov_communicator"` - ProvUi packersdk.Ui `cty:"prov_ui" hcl:"prov_ui"` + PrepCalled *bool `cty:"prep_called" hcl:"prep_called"` + PrepConfigs []interface{} `cty:"prep_configs" hcl:"prep_configs"` + ProvCalled *bool `cty:"prov_called" hcl:"prov_called"` + ProvRetried *bool `cty:"prov_retried" hcl:"prov_retried"` + ProvCommunicator *packer.Communicator `cty:"prov_communicator" hcl:"prov_communicator"` + ProvUi packer.Ui `cty:"prov_ui" hcl:"prov_ui"` } // FlatMapstructure returns a new FlatMockProvisioner. @@ -177,37 +118,8 @@ func (*FlatMockProvisioner) HCL2Spec() map[string]hcldec.Spec { "prep_configs": &hcldec.AttrSpec{Name: "prep_configs", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ "prov_called": &hcldec.AttrSpec{Name: "prov_called", Type: cty.Bool, Required: false}, "prov_retried": &hcldec.AttrSpec{Name: "prov_retried", Type: cty.Bool, Required: false}, - "prov_communicator": &hcldec.AttrSpec{Name: "prov_communicator", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ - "prov_ui": &hcldec.AttrSpec{Name: "prov_ui", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ - } - return s -} - -// FlatRemoteCmd is an auto-generated flat version of RemoteCmd. -// Where the contents of a field with a `mapstructure:,squash` tag are bubbled up. -type FlatRemoteCmd struct { - Command *string `cty:"command" hcl:"command"` - Stdin io.Reader `cty:"stdin" hcl:"stdin"` - Stdout io.Writer `cty:"stdout" hcl:"stdout"` - Stderr io.Writer `cty:"stderr" hcl:"stderr"` -} - -// FlatMapstructure returns a new FlatRemoteCmd. -// FlatRemoteCmd is an auto-generated flat version of RemoteCmd. -// Where the contents a fields with a `mapstructure:,squash` tag are bubbled up. -func (*RemoteCmd) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec } { - return new(FlatRemoteCmd) -} - -// HCL2Spec returns the hcl spec of a RemoteCmd. -// This spec is used by HCL to read the fields of RemoteCmd. -// The decoded values from this spec will then be applied to a FlatRemoteCmd. -func (*FlatRemoteCmd) HCL2Spec() map[string]hcldec.Spec { - s := map[string]hcldec.Spec{ - "command": &hcldec.AttrSpec{Name: "command", Type: cty.String, Required: false}, - "stdin": &hcldec.AttrSpec{Name: "stdin", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ - "stdout": &hcldec.AttrSpec{Name: "stdout", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ - "stderr": &hcldec.AttrSpec{Name: "stderr", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ + "prov_communicator": &hcldec.AttrSpec{Name: "prov_communicator", Type: cty.String, Required: false}, + "prov_ui": &hcldec.AttrSpec{Name: "prov_ui", Type: cty.Bool, Required: false}, /* TODO(azr): could not find type */ } return s } diff --git a/packer/core.go b/packer/core.go index 0c2759f01..07d0841d1 100644 --- a/packer/core.go +++ b/packer/core.go @@ -53,7 +53,7 @@ type CoreConfig struct { type BuilderFunc func(name string) (Builder, error) // The function type used to lookup Hook implementations. -type HookFunc func(name string) (Hook, error) +type HookFunc func(name string) (packersdk.Hook, error) // The function type used to lookup PostProcessor implementations. type PostProcessorFunc func(name string) (PostProcessor, error) diff --git a/packer/plugin/builder.go b/packer/plugin/builder.go index 5ec142d6d..9778b58fa 100644 --- a/packer/plugin/builder.go +++ b/packer/plugin/builder.go @@ -32,7 +32,7 @@ func (b *cmdBuilder) Prepare(config ...interface{}) ([]string, []string, error) return b.builder.Prepare(config...) } -func (b *cmdBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *cmdBuilder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { defer func() { r := recover() b.checkExit(r, nil) diff --git a/packer/plugin/client.go b/packer/plugin/client.go index 33fcf7f75..a8b1f8b1a 100644 --- a/packer/plugin/client.go +++ b/packer/plugin/client.go @@ -17,6 +17,7 @@ import ( "unicode" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" packrpc "github.com/hashicorp/packer/packer/rpc" ) @@ -141,7 +142,7 @@ func (c *Client) Builder() (packer.Builder, error) { // Returns a hook implementation that is communicating over this // client. If the client hasn't been started, this will start it. -func (c *Client) Hook() (packer.Hook, error) { +func (c *Client) Hook() (packersdk.Hook, error) { client, err := c.packrpcClient() if err != nil { return nil, err diff --git a/packer/plugin/hook.go b/packer/plugin/hook.go index 92da9cb18..808b67f75 100644 --- a/packer/plugin/hook.go +++ b/packer/plugin/hook.go @@ -4,16 +4,15 @@ import ( "context" "log" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type cmdHook struct { - hook packer.Hook + hook packersdk.Hook client *Client } -func (c *cmdHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packer.Communicator, data interface{}) error { +func (c *cmdHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packersdk.Communicator, data interface{}) error { defer func() { r := recover() c.checkExit(r, nil) diff --git a/packer/plugin/provisioner.go b/packer/plugin/provisioner.go index 8602b7ad1..9d502b9ff 100644 --- a/packer/plugin/provisioner.go +++ b/packer/plugin/provisioner.go @@ -32,7 +32,7 @@ func (c *cmdProvisioner) Prepare(configs ...interface{}) error { return c.p.Prepare(configs...) } -func (c *cmdProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (c *cmdProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { defer func() { r := recover() c.checkExit(r, nil) diff --git a/packer/post_processor.go b/packer/post_processor.go index 32fe23f1f..cd47e297c 100644 --- a/packer/post_processor.go +++ b/packer/post_processor.go @@ -12,7 +12,7 @@ import ( // the result of a build, compresses it, and returns a new artifact containing // a single file of the prior artifact compressed. type PostProcessor interface { - HCL2Speccer + packersdk.HCL2Speccer // Configure is responsible for setting up configuration, storing // the state for later, and returning and errors, such as validation diff --git a/packer/provisioner.go b/packer/provisioner.go index 0fa22fb42..b1ac9c005 100644 --- a/packer/provisioner.go +++ b/packer/provisioner.go @@ -15,7 +15,7 @@ import ( // A provisioner is responsible for installing and configuring software // on a machine prior to building the actual image. type Provisioner interface { - HCL2Speccer + packersdk.HCL2Speccer // Prepare is called with a set of configurations to setup the // internal state of the provisioner. The multiple configurations @@ -26,7 +26,7 @@ type Provisioner interface { // given for cancellation, a UI is given to communicate with the user, and // a communicator is given that is guaranteed to be connected to some // machine so that provisioning can be done. - Provision(context.Context, packersdk.Ui, Communicator, map[string]interface{}) error + Provision(context.Context, packersdk.Ui, packersdk.Communicator, map[string]interface{}) error } // A HookedProvisioner represents a provisioner and information describing it @@ -120,7 +120,7 @@ func CastDataToMap(data interface{}) map[string]interface{} { } // Runs the provisioners in order. -func (h *ProvisionHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm Communicator, data interface{}) error { +func (h *ProvisionHook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packersdk.Communicator, data interface{}) error { // Shortcut if len(h.Provisioners) == 0 { return nil @@ -160,7 +160,7 @@ func (p *PausedProvisioner) Prepare(raws ...interface{}) error { return p.Provisioner.Prepare(raws...) } -func (p *PausedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { +func (p *PausedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { // Use a select to determine if we get cancelled during the wait ui.Say(fmt.Sprintf("Pausing %s before the next provisioner...", p.PauseBefore)) @@ -186,7 +186,7 @@ func (r *RetriedProvisioner) Prepare(raws ...interface{}) error { return r.Provisioner.Prepare(raws...) } -func (r *RetriedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { +func (r *RetriedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { if ctx.Err() != nil { // context was cancelled return ctx.Err() } @@ -231,7 +231,7 @@ func (p *DebuggedProvisioner) Prepare(raws ...interface{}) error { return p.Provisioner.Prepare(raws...) } -func (p *DebuggedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { +func (p *DebuggedProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { // Use a select to determine if we get cancelled during the wait message := "Pausing before the next provisioner . Press enter to continue." diff --git a/packer/provisioner_mock.go b/packer/provisioner_mock.go index 1353c0d49..b4fc829b8 100644 --- a/packer/provisioner_mock.go +++ b/packer/provisioner_mock.go @@ -16,7 +16,7 @@ type MockProvisioner struct { PrepConfigs []interface{} ProvCalled bool ProvRetried bool - ProvCommunicator Communicator + ProvCommunicator packersdk.Communicator ProvUi packersdk.Ui } @@ -30,7 +30,7 @@ func (t *MockProvisioner) Prepare(configs ...interface{}) error { return nil } -func (t *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { +func (t *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { if t.ProvCalled { t.ProvRetried = true return nil @@ -47,7 +47,7 @@ func (t *MockProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm C return t.ProvFunc(ctx) } -func (t *MockProvisioner) Communicator() Communicator { +func (t *MockProvisioner) Communicator() packersdk.Communicator { return t.ProvCommunicator } diff --git a/packer/provisioner_timeout.go b/packer/provisioner_timeout.go index 14050a52d..6b2b5649c 100644 --- a/packer/provisioner_timeout.go +++ b/packer/provisioner_timeout.go @@ -15,7 +15,7 @@ type TimeoutProvisioner struct { Timeout time.Duration } -func (p *TimeoutProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm Communicator, generatedData map[string]interface{}) error { +func (p *TimeoutProvisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ctx, cancel := context.WithTimeout(ctx, p.Timeout) defer cancel() diff --git a/packer/rpc/builder.go b/packer/rpc/builder.go index 8f6d5ed6b..dc962675f 100644 --- a/packer/rpc/builder.go +++ b/packer/rpc/builder.go @@ -52,7 +52,7 @@ func (b *builder) Prepare(config ...interface{}) ([]string, []string, error) { return resp.GeneratedVars, resp.Warnings, err } -func (b *builder) Run(ctx context.Context, ui packersdk.Ui, hook packer.Hook) (packersdk.Artifact, error) { +func (b *builder) Run(ctx context.Context, ui packersdk.Ui, hook packersdk.Hook) (packersdk.Artifact, error) { nextId := b.mux.NextId() server := newServerWithMux(b.mux, nextId) server.RegisterHook(hook) diff --git a/packer/rpc/client.go b/packer/rpc/client.go index 5bf4e4c94..93bf76fd6 100644 --- a/packer/rpc/client.go +++ b/packer/rpc/client.go @@ -99,7 +99,7 @@ func (c *Client) Builder() packer.Builder { } } -func (c *Client) Communicator() packer.Communicator { +func (c *Client) Communicator() packersdk.Communicator { return &communicator{ commonClient: commonClient{ endpoint: DefaultCommunicatorEndpoint, @@ -109,7 +109,7 @@ func (c *Client) Communicator() packer.Communicator { } } -func (c *Client) Hook() packer.Hook { +func (c *Client) Hook() packersdk.Hook { return &hook{ commonClient: commonClient{ endpoint: DefaultHookEndpoint, diff --git a/packer/rpc/communicator.go b/packer/rpc/communicator.go index 55da58f24..062708c24 100644 --- a/packer/rpc/communicator.go +++ b/packer/rpc/communicator.go @@ -9,20 +9,20 @@ import ( "os" "sync" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -// An implementation of packer.Communicator where the communicator is actually +// An implementation of packersdk.Communicator where the communicator is actually // executed over an RPC connection. type communicator struct { commonClient } -// CommunicatorServer wraps a packer.Communicator implementation and makes +// CommunicatorServer wraps a packersdk.Communicator implementation and makes // it exportable as part of a Golang RPC server. type CommunicatorServer struct { commonServer - c packer.Communicator + c packersdk.Communicator } type CommandFinished struct { @@ -69,7 +69,7 @@ func Communicator(client *rpc.Client) *communicator { } } -func (c *communicator) Start(ctx context.Context, cmd *packer.RemoteCmd) (err error) { +func (c *communicator) Start(ctx context.Context, cmd *packersdk.RemoteCmd) (err error) { var args CommunicatorStartArgs args.Command = cmd.Command @@ -210,7 +210,7 @@ func (c *CommunicatorServer) Start(args *CommunicatorStartArgs, reply *interface // Build the RemoteCmd on this side so that it all pipes over // to the remote side. - var cmd packer.RemoteCmd + var cmd packersdk.RemoteCmd cmd.Command = args.Command // Create a channel to signal we're done so that we can close diff --git a/packer/rpc/communicator_test.go b/packer/rpc/communicator_test.go index a109a1a4d..9e8f298d6 100644 --- a/packer/rpc/communicator_test.go +++ b/packer/rpc/communicator_test.go @@ -8,6 +8,7 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestCommunicatorRPC(t *testing.T) { @@ -26,7 +27,7 @@ func TestCommunicatorRPC(t *testing.T) { stdout_r, stdout_w := io.Pipe() stderr_r, stderr_w := io.Pipe() - var cmd packer.RemoteCmd + var cmd packersdk.RemoteCmd cmd.Command = "foo" cmd.Stdin = stdin_r cmd.Stdout = stdout_w @@ -163,7 +164,7 @@ func TestCommunicatorRPC(t *testing.T) { func TestCommunicator_ImplementsCommunicator(t *testing.T) { var raw interface{} raw = Communicator(nil) - if _, ok := raw.(packer.Communicator); !ok { + if _, ok := raw.(packersdk.Communicator); !ok { t.Fatal("should be a Communicator") } } diff --git a/packer/rpc/hook.go b/packer/rpc/hook.go index 55de54a91..a670a8902 100644 --- a/packer/rpc/hook.go +++ b/packer/rpc/hook.go @@ -5,23 +5,22 @@ import ( "log" "sync" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) -// An implementation of packer.Hook where the hook is actually executed +// An implementation of packersdk.Hook where the hook is actually executed // over an RPC connection. type hook struct { commonClient } -// HookServer wraps a packer.Hook implementation and makes it exportable +// HookServer wraps a packersdk.Hook implementation and makes it exportable // as part of a Golang RPC server. type HookServer struct { context context.Context contextCancel func() - hook packer.Hook + hook packersdk.Hook lock sync.Mutex mux *muxBroker } @@ -32,7 +31,7 @@ type HookRunArgs struct { StreamId uint32 } -func (h *hook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packer.Communicator, data interface{}) error { +func (h *hook) Run(ctx context.Context, name string, ui packersdk.Ui, comm packersdk.Communicator, data interface{}) error { nextId := h.mux.NextId() server := newServerWithMux(h.mux, nextId) server.RegisterCommunicator(comm) diff --git a/packer/rpc/hook_test.go b/packer/rpc/hook_test.go index 700feda65..ef28eeb4c 100644 --- a/packer/rpc/hook_test.go +++ b/packer/rpc/hook_test.go @@ -5,10 +5,11 @@ import ( "testing" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func TestHook_Implements(t *testing.T) { - var _ packer.Hook = new(hook) + var _ packersdk.Hook = new(hook) } func TestHook_cancelWhileRun(t *testing.T) { diff --git a/packer/rpc/provisioner.go b/packer/rpc/provisioner.go index f1de8e0fc..8337cf6db 100644 --- a/packer/rpc/provisioner.go +++ b/packer/rpc/provisioner.go @@ -42,7 +42,7 @@ type ProvisionerProvisionArgs struct { StreamID uint32 } -func (p *provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { nextId := p.mux.NextId() server := newServerWithMux(p.mux, nextId) server.RegisterCommunicator(comm) diff --git a/packer/rpc/server.go b/packer/rpc/server.go index 48a37ab49..07ebf70f9 100644 --- a/packer/rpc/server.go +++ b/packer/rpc/server.go @@ -87,7 +87,7 @@ func (s *Server) RegisterBuilder(b packer.Builder) error { }) } -func (s *Server) RegisterCommunicator(c packer.Communicator) error { +func (s *Server) RegisterCommunicator(c packersdk.Communicator) error { return s.server.RegisterName(DefaultCommunicatorEndpoint, &CommunicatorServer{ c: c, commonServer: commonServer{ @@ -96,7 +96,7 @@ func (s *Server) RegisterCommunicator(c packer.Communicator) error { }) } -func (s *Server) RegisterHook(h packer.Hook) error { +func (s *Server) RegisterHook(h packersdk.Hook) error { return s.server.RegisterName(DefaultHookEndpoint, &HookServer{ hook: h, mux: s.mux, diff --git a/post-processor/vsphere/post-processor.go b/post-processor/vsphere/post-processor.go index 0c15aa400..e0102b5cb 100644 --- a/post-processor/vsphere/post-processor.go +++ b/post-processor/vsphere/post-processor.go @@ -15,7 +15,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" shelllocal "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" @@ -201,7 +200,7 @@ func (p *PostProcessor) PostProcess(ctx context.Context, ui packersdk.Ui, artifa ExecuteCommand: commandAndArgs, } flattenedCmd := strings.Join(commandAndArgs, " ") - cmd := &packer.RemoteCmd{Command: flattenedCmd} + cmd := &packersdk.RemoteCmd{Command: flattenedCmd} log.Printf("[INFO] (vsphere): starting ovftool command: %s", flattenedCmd) if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return nil, false, false, fmt.Errorf( diff --git a/provisioner/ansible-local/communicator_mock.go b/provisioner/ansible-local/communicator_mock.go index 8ba3a9195..054b76b02 100644 --- a/provisioner/ansible-local/communicator_mock.go +++ b/provisioner/ansible-local/communicator_mock.go @@ -5,7 +5,7 @@ import ( "io" "os" - "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) type communicatorMock struct { @@ -13,7 +13,7 @@ type communicatorMock struct { uploadDestination []string } -func (c *communicatorMock) Start(ctx context.Context, cmd *packer.RemoteCmd) error { +func (c *communicatorMock) Start(ctx context.Context, cmd *packersdk.RemoteCmd) error { c.startCommand = append(c.startCommand, cmd.Command) cmd.SetExited(0) return nil diff --git a/provisioner/ansible-local/provisioner.go b/provisioner/ansible-local/provisioner.go index 2e44ffbb6..0dd55c9bf 100644 --- a/provisioner/ansible-local/provisioner.go +++ b/provisioner/ansible-local/provisioner.go @@ -10,7 +10,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -194,7 +193,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Ansible...") p.generatedData = generatedData @@ -318,7 +317,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) provisionPlaybookFiles(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) provisionPlaybookFiles(ui packersdk.Ui, comm packersdk.Communicator) error { var playbookDir string if p.config.PlaybookDir != "" { var err error @@ -339,7 +338,7 @@ func (p *Provisioner) provisionPlaybookFiles(ui packersdk.Ui, comm packer.Commun return nil } -func (p *Provisioner) provisionPlaybookFile(ui packersdk.Ui, comm packer.Communicator, playbookFile string) error { +func (p *Provisioner) provisionPlaybookFile(ui packersdk.Ui, comm packersdk.Communicator, playbookFile string) error { ui.Message(fmt.Sprintf("Uploading playbook file: %s", playbookFile)) remoteDir := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Dir(playbookFile))) @@ -356,7 +355,7 @@ func (p *Provisioner) provisionPlaybookFile(ui packersdk.Ui, comm packer.Communi return nil } -func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packersdk.Communicator) error { ctx := context.TODO() rolesDir := filepath.ToSlash(filepath.Join(p.config.StagingDir, "roles")) galaxyFile := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Base(p.config.GalaxyFile))) @@ -365,7 +364,7 @@ func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) e command := fmt.Sprintf("cd %s && %s install -r %s -p %s", p.config.StagingDir, p.config.GalaxyCommand, galaxyFile, rolesDir) ui.Message(fmt.Sprintf("Executing Ansible Galaxy: %s", command)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } if err := cmd.RunWithUi(ctx, comm, ui); err != nil { @@ -378,7 +377,7 @@ func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) e return nil } -func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packersdk.Communicator) error { inventory := filepath.ToSlash(filepath.Join(p.config.StagingDir, filepath.Base(p.config.InventoryFile))) extraArgs := fmt.Sprintf(" --extra-vars \"packer_build_name=%s packer_builder_type=%s packer_http_addr=%s -o IdentitiesOnly=yes\" ", @@ -411,14 +410,14 @@ func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packer.Communicator) } func (p *Provisioner) executeAnsiblePlaybook( - ui packersdk.Ui, comm packer.Communicator, playbookFile, extraArgs, inventory string, + ui packersdk.Ui, comm packersdk.Communicator, playbookFile, extraArgs, inventory string, ) error { ctx := context.TODO() command := fmt.Sprintf("cd %s && %s %s%s -c local -i %s", p.config.StagingDir, p.config.Command, playbookFile, extraArgs, inventory, ) ui.Message(fmt.Sprintf("Executing Ansible: %s", command)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } if err := cmd.RunWithUi(ctx, comm, ui); err != nil { @@ -461,7 +460,7 @@ func validateFileConfig(name string, config string, req bool) error { return nil } -func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst, src string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packersdk.Communicator, dst, src string) error { f, err := os.Open(src) if err != nil { return fmt.Errorf("Error opening: %s", err) @@ -474,9 +473,9 @@ func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst, return nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("mkdir -p '%s'", dir), } @@ -491,9 +490,9 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("rm -rf '%s'", dir), } @@ -508,7 +507,7 @@ func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) uploadDir(ui packersdk.Ui, comm packer.Communicator, dst, src string) error { +func (p *Provisioner) uploadDir(ui packersdk.Ui, comm packersdk.Communicator, dst, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } diff --git a/provisioner/ansible-local/provisioner_test.go b/provisioner/ansible-local/provisioner_test.go index 9d55d549d..a1785df73 100644 --- a/provisioner/ansible-local/provisioner_test.go +++ b/provisioner/ansible-local/provisioner_test.go @@ -13,6 +13,7 @@ import ( "github.com/hashicorp/packer/builder/docker" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template" "github.com/hashicorp/packer/provisioner/file" ) @@ -364,10 +365,10 @@ func testProvisionerProvisionDockerWithPlaybookFiles(t *testing.T, templateStrin } // Add hooks so the provisioners run during the build - hooks := map[string][]packer.Hook{} - hooks[packer.HookProvision] = []packer.Hook{ + hooks := map[string][]packersdk.Hook{} + hooks[packersdk.HookProvision] = []packersdk.Hook{ &packer.ProvisionHook{ - Provisioners: []*packer.HookedProvisioner{ + Provisioners: []*packersdk.HookedProvisioner{ {Provisioner: ansible, Config: nil, TypeName: ""}, {Provisioner: download, Config: nil, TypeName: ""}, }, diff --git a/provisioner/ansible/mock_ansible.go b/provisioner/ansible/mock_ansible.go index db1a57ba6..c17668dcb 100644 --- a/provisioner/ansible/mock_ansible.go +++ b/provisioner/ansible/mock_ansible.go @@ -5,7 +5,6 @@ package ansible import ( "fmt" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) @@ -15,7 +14,7 @@ type provisionLogicTracker struct { happyPath bool } -func (l *provisionLogicTracker) setupAdapter(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (l *provisionLogicTracker) setupAdapter(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { l.setupAdapterCalled = true if l.happyPath { return "fakeKeyString", nil @@ -23,7 +22,7 @@ func (l *provisionLogicTracker) setupAdapter(ui packersdk.Ui, comm packer.Commun return "", fmt.Errorf("chose sadpath") } -func (l *provisionLogicTracker) executeAnsible(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error { +func (l *provisionLogicTracker) executeAnsible(ui packersdk.Ui, comm packersdk.Communicator, privKeyFile string) error { l.executeAnsibleCalled = true if l.happyPath { return fmt.Errorf("Chose sadpath") diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index c58c99b51..b1568fe51 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -215,8 +215,8 @@ type Provisioner struct { ansibleMajVersion uint generatedData map[string]interface{} - setupAdapterFunc func(ui packersdk.Ui, comm packer.Communicator) (string, error) - executeAnsibleFunc func(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error + setupAdapterFunc func(ui packersdk.Ui, comm packersdk.Communicator) (string, error) + executeAnsibleFunc func(ui packersdk.Ui, comm packersdk.Communicator, privKeyFile string) error } func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } @@ -362,7 +362,7 @@ func (p *Provisioner) getVersion() error { return nil } -func (p *Provisioner) setupAdapter(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) setupAdapter(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { ui.Message("Setting up proxy adapter for Ansible....") k, err := newUserKey(p.config.SSHAuthorizedKeyFile) @@ -503,7 +503,7 @@ func (p *Provisioner) createInventoryFile() error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Ansible...") // Interpolate env vars to check for generated values like password and port p.generatedData = generatedData @@ -628,7 +628,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packersdk.Communicator) error { galaxyFile := filepath.ToSlash(p.config.GalaxyFile) // ansible-galaxy install -r requirements.yml @@ -677,7 +677,7 @@ func (p *Provisioner) executeGalaxy(ui packersdk.Ui, comm packer.Communicator) e } // Intended to be invoked from p.executeGalaxy depending on the Ansible Galaxy parameters passed to Packer -func (p *Provisioner) invokeGalaxyCommand(args []string, ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) invokeGalaxyCommand(args []string, ui packersdk.Ui, comm packersdk.Communicator) error { ui.Message(fmt.Sprintf("Executing Ansible Galaxy")) cmd := exec.Command(p.config.GalaxyCommand, args...) @@ -782,7 +782,7 @@ func (p *Provisioner) createCmdArgs(httpAddr, inventory, playbook, privKeyFile s return args, envVars } -func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error { +func (p *Provisioner) executeAnsible(ui packersdk.Ui, comm packersdk.Communicator, privKeyFile string) error { playbook, _ := filepath.Abs(p.config.PlaybookFile) inventory := p.config.InventoryFile httpAddr := p.generatedData["PackerHTTPAddr"].(string) diff --git a/provisioner/azure-dtlartifact/provisioner.go b/provisioner/azure-dtlartifact/provisioner.go index 612e24b01..1f9ca812d 100644 --- a/provisioner/azure-dtlartifact/provisioner.go +++ b/provisioner/azure-dtlartifact/provisioner.go @@ -12,7 +12,6 @@ import ( "github.com/hashicorp/packer/builder/azure/common/client" dtlBuilder "github.com/hashicorp/packer/builder/azure/dtl" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" @@ -63,7 +62,7 @@ type Config struct { type Provisioner struct { config Config - communicator packer.Communicator + communicator packersdk.Communicator } func (p *Provisioner) ConfigSpec() hcldec.ObjectSpec { return p.config.FlatMapstructure().HCL2Spec() } @@ -93,11 +92,11 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Communicator() packer.Communicator { +func (p *Provisioner) Communicator() packersdk.Communicator { return p.communicator } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { p.communicator = comm diff --git a/provisioner/breakpoint/provisioner.go b/provisioner/breakpoint/provisioner.go index a31f68e27..ebbdd3a11 100644 --- a/provisioner/breakpoint/provisioner.go +++ b/provisioner/breakpoint/provisioner.go @@ -9,7 +9,6 @@ import ( "golang.org/x/sync/errgroup" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -47,7 +46,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { if p.config.Disable { if p.config.Note != "" { ui.Say(fmt.Sprintf( diff --git a/provisioner/chef-client/provisioner.go b/provisioner/chef-client/provisioner.go index 87167e6e6..b275ce5ec 100644 --- a/provisioner/chef-client/provisioner.go +++ b/provisioner/chef-client/provisioner.go @@ -85,7 +85,7 @@ type Config struct { type Provisioner struct { config Config - communicator packer.Communicator + communicator packersdk.Communicator guestOSTypeConfig guestOSTypeConfig guestCommands *guestexec.GuestCommands generatedData map[string]interface{} @@ -241,7 +241,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { p.generatedData = generatedData p.communicator = comm @@ -349,7 +349,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, remotePath string, localPath string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packersdk.Communicator, remotePath string, localPath string) error { ui.Message(fmt.Sprintf("Uploading %s...", localPath)) f, err := os.Open(localPath) @@ -363,7 +363,7 @@ func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, remo func (p *Provisioner) createConfig( ui packersdk.Ui, - comm packer.Communicator, + comm packersdk.Communicator, nodeName string, serverUrl string, clientKey string, @@ -424,7 +424,7 @@ func (p *Provisioner) createConfig( return remotePath, nil } -func (p *Provisioner) createKnifeConfig(ui packersdk.Ui, comm packer.Communicator, nodeName string, serverUrl string, clientKey string, sslVerifyMode string, trustedCertsDir string) (string, error) { +func (p *Provisioner) createKnifeConfig(ui packersdk.Ui, comm packersdk.Communicator, nodeName string, serverUrl string, clientKey string, sslVerifyMode string, trustedCertsDir string) (string, error) { ui.Message("Creating configuration file 'knife.rb'") // Read the template @@ -451,7 +451,7 @@ func (p *Provisioner) createKnifeConfig(ui packersdk.Ui, comm packer.Communicato return remotePath, nil } -func (p *Provisioner) createJson(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) createJson(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { ui.Message("Creating JSON attribute file") jsonData := make(map[string]interface{}) @@ -480,11 +480,11 @@ func (p *Provisioner) createJson(ui packersdk.Ui, comm packer.Communicator) (str return remotePath, nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Creating directory: %s", dir)) - cmd := &packer.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -493,7 +493,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s } // Chmod the directory to 0777 just so that we can access it as our user - cmd = &packer.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} + cmd = &packersdk.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -504,7 +504,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) cleanNode(ui packersdk.Ui, comm packer.Communicator, node string, knifeConfigPath string) error { +func (p *Provisioner) cleanNode(ui packersdk.Ui, comm packersdk.Communicator, node string, knifeConfigPath string) error { ui.Say("Cleaning up chef node...") args := []string{"node", "delete", node} if err := p.knifeExec(ui, comm, node, knifeConfigPath, args); err != nil { @@ -514,7 +514,7 @@ func (p *Provisioner) cleanNode(ui packersdk.Ui, comm packer.Communicator, node return nil } -func (p *Provisioner) cleanClient(ui packersdk.Ui, comm packer.Communicator, node string, knifeConfigPath string) error { +func (p *Provisioner) cleanClient(ui packersdk.Ui, comm packersdk.Communicator, node string, knifeConfigPath string) error { ui.Say("Cleaning up chef client...") args := []string{"client", "delete", node} if err := p.knifeExec(ui, comm, node, knifeConfigPath, args); err != nil { @@ -524,7 +524,7 @@ func (p *Provisioner) cleanClient(ui packersdk.Ui, comm packer.Communicator, nod return nil } -func (p *Provisioner) knifeExec(ui packersdk.Ui, comm packer.Communicator, node string, knifeConfigPath string, args []string) error { +func (p *Provisioner) knifeExec(ui packersdk.Ui, comm packersdk.Communicator, node string, knifeConfigPath string, args []string) error { flags := []string{ "-y", "-c", knifeConfigPath, @@ -542,7 +542,7 @@ func (p *Provisioner) knifeExec(ui packersdk.Ui, comm packer.Communicator, node return err } - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -556,11 +556,11 @@ func (p *Provisioner) knifeExec(ui packersdk.Ui, comm packer.Communicator, node return nil } -func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ui.Message(fmt.Sprintf("Removing directory: %s", dir)) ctx := context.TODO() - cmd := &packer.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -568,7 +568,7 @@ func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, config string, json string) error { +func (p *Provisioner) executeChef(ui packersdk.Ui, comm packersdk.Communicator, config string, json string) error { p.config.ctx.Data = &ExecuteTemplate{ ConfigPath: config, JsonPath: json, @@ -590,7 +590,7 @@ func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, con ui.Message(fmt.Sprintf("Executing Chef: %s", command)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } @@ -605,7 +605,7 @@ func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, con return nil } -func (p *Provisioner) installChef(ui packersdk.Ui, comm packer.Communicator, version string) error { +func (p *Provisioner) installChef(ui packersdk.Ui, comm packersdk.Communicator, version string) error { ui.Message("Installing Chef...") ctx := context.TODO() @@ -620,7 +620,7 @@ func (p *Provisioner) installChef(ui packersdk.Ui, comm packer.Communicator, ver ui.Message(command) - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -715,7 +715,7 @@ func (p *Provisioner) processJsonUserVars() (map[string]interface{}, error) { return result, nil } -func (p *Provisioner) Communicator() packer.Communicator { +func (p *Provisioner) Communicator() packersdk.Communicator { return p.communicator } diff --git a/provisioner/chef-solo/provisioner.go b/provisioner/chef-solo/provisioner.go index 0bb4bcec1..cfc049e99 100644 --- a/provisioner/chef-solo/provisioner.go +++ b/provisioner/chef-solo/provisioner.go @@ -16,7 +16,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -243,7 +242,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { ui.Say("Provisioning with chef-solo") if !p.config.SkipInstall { @@ -315,7 +314,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packersdk.Communicator, dst string, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } @@ -329,7 +328,7 @@ func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, return comm.UploadDir(dst, src, nil) } -func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packersdk.Communicator, dst string, src string) error { f, err := os.Open(src) if err != nil { return err @@ -339,7 +338,7 @@ func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst return comm.Upload(dst, f, nil) } -func (p *Provisioner) createConfig(ui packersdk.Ui, comm packer.Communicator, localCookbooks []string, rolesPath string, dataBagsPath string, encryptedDataBagSecretPath string, environmentsPath string, chefEnvironment string, chefLicense string) (string, error) { +func (p *Provisioner) createConfig(ui packersdk.Ui, comm packersdk.Communicator, localCookbooks []string, rolesPath string, dataBagsPath string, encryptedDataBagSecretPath string, environmentsPath string, chefEnvironment string, chefLicense string) (string, error) { ui.Message("Creating configuration file 'solo.rb'") cookbook_paths := make([]string, len(p.config.RemoteCookbookPaths)+len(localCookbooks)) @@ -395,7 +394,7 @@ func (p *Provisioner) createConfig(ui packersdk.Ui, comm packer.Communicator, lo return remotePath, nil } -func (p *Provisioner) createJson(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) createJson(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { ui.Message("Creating JSON attribute file") jsonData := make(map[string]interface{}) @@ -424,11 +423,11 @@ func (p *Provisioner) createJson(ui packersdk.Ui, comm packer.Communicator) (str return remotePath, nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) ctx := context.TODO() - cmd := &packer.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -437,7 +436,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s } // Chmod the directory to 0777 just so that we can access it as our user - cmd = &packer.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} + cmd = &packersdk.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -448,7 +447,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, config string, json string) error { +func (p *Provisioner) executeChef(ui packersdk.Ui, comm packersdk.Communicator, config string, json string) error { p.config.ctx.Data = &ExecuteTemplate{ ConfigPath: config, JsonPath: json, @@ -461,7 +460,7 @@ func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, con ui.Message(fmt.Sprintf("Executing Chef: %s", command)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } ctx := context.TODO() @@ -476,7 +475,7 @@ func (p *Provisioner) executeChef(ui packersdk.Ui, comm packer.Communicator, con return nil } -func (p *Provisioner) installChef(ui packersdk.Ui, comm packer.Communicator, version string) error { +func (p *Provisioner) installChef(ui packersdk.Ui, comm packersdk.Communicator, version string) error { ui.Message("Installing Chef...") ctx := context.TODO() @@ -489,7 +488,7 @@ func (p *Provisioner) installChef(ui packersdk.Ui, comm packer.Communicator, ver return err } - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } diff --git a/provisioner/converge/provisioner.go b/provisioner/converge/provisioner.go index d179cb1bb..73b690c42 100644 --- a/provisioner/converge/provisioner.go +++ b/provisioner/converge/provisioner.go @@ -16,7 +16,6 @@ import ( "encoding/json" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -112,7 +111,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } // Provision node somehow. TODO: actual docs -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { ui.Say("Provisioning with Converge") // bootstrapping @@ -133,7 +132,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) maybeBootstrap(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) maybeBootstrap(ui packersdk.Ui, comm packersdk.Communicator) error { ctx := context.TODO() if !p.config.Bootstrap { return nil @@ -153,7 +152,7 @@ func (p *Provisioner) maybeBootstrap(ui packersdk.Ui, comm packer.Communicator) } var out, outErr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, Stdin: nil, Stdout: &out, @@ -175,7 +174,7 @@ func (p *Provisioner) maybeBootstrap(ui packersdk.Ui, comm packer.Communicator) return nil } -func (p *Provisioner) sendModuleDirectories(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) sendModuleDirectories(ui packersdk.Ui, comm packersdk.Communicator) error { for _, dir := range p.config.ModuleDirs { if err := comm.UploadDir(dir.Destination, dir.Source, dir.Exclude); err != nil { return fmt.Errorf("Could not upload %q: %s", dir.Source, err) @@ -186,7 +185,7 @@ func (p *Provisioner) sendModuleDirectories(ui packersdk.Ui, comm packer.Communi return nil } -func (p *Provisioner) applyModules(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) applyModules(ui packersdk.Ui, comm packersdk.Communicator) error { ctx := context.TODO() // create params JSON file params, err := json.Marshal(p.config.Params) @@ -210,7 +209,7 @@ func (p *Provisioner) applyModules(ui packersdk.Ui, comm packer.Communicator) er // run Converge in the specified directory var runOut, runErr bytes.Buffer - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, Stdin: nil, Stdout: &runOut, diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index b7f493a74..cd4088146 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -13,7 +13,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/template/config" @@ -120,7 +119,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { if generatedData == nil { generatedData = make(map[string]interface{}) } @@ -133,7 +132,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } } -func (p *Provisioner) ProvisionDownload(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) ProvisionDownload(ui packersdk.Ui, comm packersdk.Communicator) error { dst, err := interpolate.Render(p.config.Destination, &p.config.ctx) if err != nil { return fmt.Errorf("Error interpolating destination: %s", err) @@ -182,7 +181,7 @@ func (p *Provisioner) ProvisionDownload(ui packersdk.Ui, comm packer.Communicato return nil } -func (p *Provisioner) ProvisionUpload(ui packersdk.Ui, comm packer.Communicator) error { +func (p *Provisioner) ProvisionUpload(ui packersdk.Ui, comm packersdk.Communicator) error { dst, err := interpolate.Render(p.config.Destination, &p.config.ctx) if err != nil { return fmt.Errorf("Error interpolating destination: %s", err) diff --git a/provisioner/inspec/provisioner.go b/provisioner/inspec/provisioner.go index 8897f8a95..0c7ab0492 100644 --- a/provisioner/inspec/provisioner.go +++ b/provisioner/inspec/provisioner.go @@ -191,7 +191,7 @@ func (p *Provisioner) getVersion() error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Inspec...") p.config.ctx.Data = generatedData @@ -342,7 +342,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) executeInspec(ui packersdk.Ui, comm packer.Communicator, privKeyFile string) error { +func (p *Provisioner) executeInspec(ui packersdk.Ui, comm packersdk.Communicator, privKeyFile string) error { var envvars []string args := []string{p.config.SubCommand, p.config.Profile} diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index d6ea048de..6d33afa1e 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -17,7 +17,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -93,7 +92,7 @@ type Config struct { type Provisioner struct { config Config - communicator packer.Communicator + communicator packersdk.Communicator generatedData map[string]interface{} } @@ -258,7 +257,7 @@ func extractScript(p *Provisioner) (string, error) { return temp.Name(), nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say(fmt.Sprintf("Provisioning with Powershell...")) p.communicator = comm p.generatedData = generatedData @@ -305,7 +304,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe // single retryable function so that we don't end up with the case // that the upload succeeded, a restart is initiated, and then the // command is executed but the file doesn't exist any longer. - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error { if _, err := f.Seek(0, 0); err != nil { return err @@ -314,7 +313,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return fmt.Errorf("Error uploading script: %s", err) } - cmd = &packer.RemoteCmd{Command: command} + cmd = &packersdk.RemoteCmd{Command: command} return cmd.RunWithUi(ctx, comm, ui) }) if err != nil { @@ -344,7 +343,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return err } - cmd := &packer.RemoteCmd{Command: command} + cmd := &packersdk.RemoteCmd{Command: command} return cmd.RunWithUi(ctx, comm, ui) }) if err != nil { @@ -531,7 +530,7 @@ func (p *Provisioner) createCommandTextPrivileged() (command string, err error) return command, err } -func (p *Provisioner) Communicator() packer.Communicator { +func (p *Provisioner) Communicator() packersdk.Communicator { return p.communicator } diff --git a/provisioner/puppet-masterless/provisioner.go b/provisioner/puppet-masterless/provisioner.go index 46aa413e9..d0477912c 100644 --- a/provisioner/puppet-masterless/provisioner.go +++ b/provisioner/puppet-masterless/provisioner.go @@ -13,7 +13,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -128,7 +127,7 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{ type Provisioner struct { config Config - communicator packer.Communicator + communicator packersdk.Communicator guestOSTypeConfig guestOSTypeConfig guestCommands *guestexec.GuestCommands generatedData map[string]interface{} @@ -258,7 +257,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Puppet...") p.communicator = comm p.generatedData = generatedData @@ -345,7 +344,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } } - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } @@ -367,7 +366,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) uploadHieraConfig(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) uploadHieraConfig(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { ui.Message("Uploading hiera configuration...") f, err := os.Open(p.config.HieraConfigPath) if err != nil { @@ -383,7 +382,7 @@ func (p *Provisioner) uploadHieraConfig(ui packersdk.Ui, comm packer.Communicato return path, nil } -func (p *Provisioner) uploadManifests(ui packersdk.Ui, comm packer.Communicator) (string, error) { +func (p *Provisioner) uploadManifests(ui packersdk.Ui, comm packersdk.Communicator) (string, error) { // Create the remote manifests directory... ui.Message("Uploading manifests...") remoteManifestsPath := fmt.Sprintf("%s/manifests", p.config.StagingDir) @@ -429,10 +428,10 @@ func (p *Provisioner) uploadManifests(ui packersdk.Ui, comm packer.Communicator) return remoteManifestFile, nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) - cmd := &packer.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} ctx := context.TODO() if err := cmd.RunWithUi(ctx, comm, ui); err != nil { @@ -444,7 +443,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s } // Chmod the directory to 0777 just so that we can access it as our user - cmd = &packer.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} + cmd = &packersdk.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -455,10 +454,10 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() - cmd := &packer.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -470,7 +469,7 @@ func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packersdk.Communicator, dst string, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } @@ -484,7 +483,7 @@ func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, return comm.UploadDir(dst, src, nil) } -func (p *Provisioner) Communicator() packer.Communicator { +func (p *Provisioner) Communicator() packersdk.Communicator { return p.communicator } diff --git a/provisioner/puppet-server/provisioner.go b/provisioner/puppet-server/provisioner.go index fa9004a59..891e606db 100644 --- a/provisioner/puppet-server/provisioner.go +++ b/provisioner/puppet-server/provisioner.go @@ -12,7 +12,6 @@ import ( "strings" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -123,7 +122,7 @@ var guestOSTypeConfigs = map[string]guestOSTypeConfig{ type Provisioner struct { config Config - communicator packer.Communicator + communicator packersdk.Communicator guestOSTypeConfig guestOSTypeConfig guestCommands *guestexec.GuestCommands generatedData map[string]interface{} @@ -228,7 +227,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with Puppet...") p.communicator = comm p.generatedData = generatedData @@ -298,7 +297,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } } - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: command, } @@ -320,11 +319,11 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) ctx := context.TODO() - cmd := &packer.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.CreateDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -333,7 +332,7 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s } // Chmod the directory to 0777 just so that we can access it as our user - cmd = &packer.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} + cmd = &packersdk.RemoteCmd{Command: p.guestCommands.Chmod(dir, "0777")} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -344,10 +343,10 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() - cmd := &packer.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} + cmd := &packersdk.RemoteCmd{Command: p.guestCommands.RemoveDir(dir)} if err := cmd.RunWithUi(ctx, comm, ui); err != nil { return err } @@ -359,7 +358,7 @@ func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packersdk.Communicator, dst string, src string) error { if err := p.createDir(ui, comm, dst); err != nil { return err } @@ -373,7 +372,7 @@ func (p *Provisioner) uploadDirectory(ui packersdk.Ui, comm packer.Communicator, return comm.UploadDir(dst, src, nil) } -func (p *Provisioner) Communicator() packer.Communicator { +func (p *Provisioner) Communicator() packersdk.Communicator { return p.communicator } diff --git a/provisioner/salt-masterless/provisioner.go b/provisioner/salt-masterless/provisioner.go index 2346ac263..ed7488aeb 100644 --- a/provisioner/salt-masterless/provisioner.go +++ b/provisioner/salt-masterless/provisioner.go @@ -16,7 +16,6 @@ import ( "github.com/hashicorp/go-getter/v2" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" "github.com/hashicorp/packer/packer-plugin-sdk/guestexec" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" @@ -240,7 +239,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { var err error var src, dst string var formulas []string @@ -275,7 +274,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe ui.Say("Provisioning with Salt...") if !p.config.SkipBootstrap { - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ // Fallback on wget if curl failed for any reason (such as not being installed) Command: fmt.Sprintf(p.guestOSTypeConfig.bootstrapFetchCmd), } @@ -283,7 +282,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe if err = cmd.RunWithUi(ctx, comm, ui); err != nil { return fmt.Errorf("Unable to download Salt: %s", err) } - cmd = &packer.RemoteCmd{ + cmd = &packersdk.RemoteCmd{ Command: fmt.Sprintf("%s %s", p.sudo(p.guestOSTypeConfig.bootstrapRunCmd), p.config.BootstrapArgs), } ui.Message(fmt.Sprintf("Installing Salt with command %s", cmd.Command)) @@ -452,7 +451,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } ui.Message(fmt.Sprintf("Running: salt-call --local %s", p.config.CmdArgs)) - cmd := &packer.RemoteCmd{Command: p.sudo(fmt.Sprintf("%s --local %s", filepath.Join(p.config.SaltBinDir, "salt-call"), p.config.CmdArgs))} + cmd := &packersdk.RemoteCmd{Command: p.sudo(fmt.Sprintf("%s --local %s", filepath.Join(p.config.SaltBinDir, "salt-call"), p.config.CmdArgs))} if err = cmd.RunWithUi(ctx, comm, ui); (err != nil || cmd.ExitStatus() != 0) && !p.config.NoExitOnFailure { if err == nil { err = fmt.Errorf("Bad exit status: %d", cmd.ExitStatus()) @@ -515,7 +514,7 @@ func hasValidFormulaURLs(s []string) bool { return true } -func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst, src string) error { +func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packersdk.Communicator, dst, src string) error { f, err := os.Open(src) if err != nil { return fmt.Errorf("Error opening: %s", err) @@ -536,11 +535,11 @@ func (p *Provisioner) uploadFile(ui packersdk.Ui, comm packer.Communicator, dst, return nil } -func (p *Provisioner) moveFile(ui packersdk.Ui, comm packer.Communicator, dst string, src string) error { +func (p *Provisioner) moveFile(ui packersdk.Ui, comm packersdk.Communicator, dst string, src string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Moving %s to %s", src, dst)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: p.sudo(p.guestCommands.MovePath(src, dst)), } if err := cmd.RunWithUi(ctx, comm, ui); err != nil || cmd.ExitStatus() != 0 { @@ -553,9 +552,9 @@ func (p *Provisioner) moveFile(ui packersdk.Ui, comm packer.Communicator, dst st return nil } -func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) createDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ui.Message(fmt.Sprintf("Creating directory: %s", dir)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: p.guestCommands.CreateDir(dir), } ctx := context.TODO() @@ -568,10 +567,10 @@ func (p *Provisioner) createDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) statPath(ui packersdk.Ui, comm packer.Communicator, path string) error { +func (p *Provisioner) statPath(ui packersdk.Ui, comm packersdk.Communicator, path string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Verifying Path: %s", path)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: p.guestCommands.StatPath(path), } if err := cmd.RunWithUi(ctx, comm, ui); err != nil { @@ -583,10 +582,10 @@ func (p *Provisioner) statPath(ui packersdk.Ui, comm packer.Communicator, path s return nil } -func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir string) error { +func (p *Provisioner) removeDir(ui packersdk.Ui, comm packersdk.Communicator, dir string) error { ctx := context.TODO() ui.Message(fmt.Sprintf("Removing directory: %s", dir)) - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: p.guestCommands.RemoveDir(dir), } if err := cmd.RunWithUi(ctx, comm, ui); err != nil { @@ -598,7 +597,7 @@ func (p *Provisioner) removeDir(ui packersdk.Ui, comm packer.Communicator, dir s return nil } -func (p *Provisioner) uploadDir(ui packersdk.Ui, comm packer.Communicator, dst, src string, ignore []string) error { +func (p *Provisioner) uploadDir(ui packersdk.Ui, comm packersdk.Communicator, dst, src string, ignore []string) error { _, temp_dst := filepath.Split(dst) if err := comm.UploadDir(temp_dst, src, ignore); err != nil { return err diff --git a/provisioner/shell-local/provisioner.go b/provisioner/shell-local/provisioner.go index aecf871cb..1047a9bd6 100644 --- a/provisioner/shell-local/provisioner.go +++ b/provisioner/shell-local/provisioner.go @@ -4,7 +4,6 @@ import ( "context" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" sl "github.com/hashicorp/packer/packer-plugin-sdk/shell-local" ) @@ -29,7 +28,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, _ packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, _ packersdk.Communicator, generatedData map[string]interface{}) error { _, retErr := sl.Run(ctx, ui, &p.config, generatedData) return retErr diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index 6f0d0ce6d..16e705d22 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -18,7 +18,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" @@ -178,7 +177,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { if generatedData == nil { generatedData = make(map[string]interface{}) } @@ -240,7 +239,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe p.config.envVarFile = tf.Name() // upload the var file - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error { if _, err := tf.Seek(0, 0); err != nil { return err @@ -257,7 +256,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } tf.Close() - cmd = &packer.RemoteCmd{ + cmd = &packersdk.RemoteCmd{ Command: fmt.Sprintf("chmod 0600 %s", remoteVFName), } if err := comm.Start(ctx, cmd); err != nil { @@ -302,7 +301,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe // the case that the upload succeeded, a restart is initiated, // and then the command is executed but the file doesn't exist // any longer. - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error { if _, err := f.Seek(0, 0); err != nil { return err @@ -317,7 +316,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return fmt.Errorf("Error uploading script: %s", err) } - cmd = &packer.RemoteCmd{ + cmd = &packersdk.RemoteCmd{ Command: fmt.Sprintf("chmod 0755 %s", p.config.RemotePath), } if err := comm.Start(ctx, cmd); err != nil { @@ -327,7 +326,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe } cmd.Wait() - cmd = &packer.RemoteCmd{Command: command} + cmd = &packersdk.RemoteCmd{Command: command} return cmd.RunWithUi(ctx, comm, ui) }) @@ -337,7 +336,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe // If the exit code indicates a remote disconnect, fail unless // we were expecting it. - if cmd.ExitStatus() == packer.CmdDisconnect { + if cmd.ExitStatus() == packersdk.CmdDisconnect { if !p.config.ExpectDisconnect { return fmt.Errorf("Script disconnected unexpectedly. " + "If you expected your script to disconnect, i.e. from a " + @@ -379,10 +378,10 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return nil } -func (p *Provisioner) cleanupRemoteFile(path string, comm packer.Communicator) error { +func (p *Provisioner) cleanupRemoteFile(path string, comm packersdk.Communicator) error { ctx := context.TODO() err := retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error { - cmd := &packer.RemoteCmd{ + cmd := &packersdk.RemoteCmd{ Command: fmt.Sprintf("rm -f %s", path), } if err := comm.Start(ctx, cmd); err != nil { @@ -392,7 +391,7 @@ func (p *Provisioner) cleanupRemoteFile(path string, comm packer.Communicator) e } cmd.Wait() // treat disconnects as retryable by returning an error - if cmd.ExitStatus() == packer.CmdDisconnect { + if cmd.ExitStatus() == packersdk.CmdDisconnect { return fmt.Errorf("Disconnect while removing temporary script.") } if cmd.ExitStatus() != 0 { diff --git a/provisioner/sleep/provisioner.go b/provisioner/sleep/provisioner.go index 4e01e808e..8c3de5dd8 100644 --- a/provisioner/sleep/provisioner.go +++ b/provisioner/sleep/provisioner.go @@ -26,7 +26,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return config.Decode(&p, &config.DecodeOpts{}, raws...) } -func (p *Provisioner) Provision(ctx context.Context, _ packersdk.Ui, _ packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, _ packersdk.Ui, _ packersdk.Communicator, _ map[string]interface{}) error { select { case <-ctx.Done(): return ctx.Err() diff --git a/provisioner/windows-restart/provisioner.go b/provisioner/windows-restart/provisioner.go index d3c6bdd92..e3afa1aa4 100644 --- a/provisioner/windows-restart/provisioner.go +++ b/provisioner/windows-restart/provisioner.go @@ -14,7 +14,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/common" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" @@ -59,7 +58,7 @@ type Config struct { type Provisioner struct { config Config - comm packer.Communicator + comm packersdk.Communicator ui packersdk.Ui cancel chan struct{} cancelLock sync.Mutex @@ -101,7 +100,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, _ map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, _ map[string]interface{}) error { p.cancelLock.Lock() p.cancel = make(chan struct{}) p.cancelLock.Unlock() @@ -110,10 +109,10 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe p.comm = comm p.ui = ui - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd command := p.config.RestartCommand err := retry.Config{StartTimeout: p.config.RestartTimeout}.Run(ctx, func(context.Context) error { - cmd = &packer.RemoteCmd{Command: command} + cmd = &packersdk.RemoteCmd{Command: command} return cmd.RunWithUi(ctx, comm, ui) }) @@ -128,7 +127,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return waitForRestart(ctx, p, comm) } -var waitForRestart = func(ctx context.Context, p *Provisioner, comm packer.Communicator) error { +var waitForRestart = func(ctx context.Context, p *Provisioner, comm packersdk.Communicator) error { ui := p.ui ui.Say("Waiting for machine to restart...") waitDone := make(chan bool, 1) @@ -136,14 +135,14 @@ var waitForRestart = func(ctx context.Context, p *Provisioner, comm packer.Commu var err error p.comm = comm - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd trycommand := TryCheckReboot abortcommand := AbortReboot // Stolen from Vagrant reboot checker for { log.Printf("Check if machine is rebooting...") - cmd = &packer.RemoteCmd{Command: trycommand} + cmd = &packersdk.RemoteCmd{Command: trycommand} err = cmd.RunWithUi(ctx, comm, ui) if err != nil { // Couldn't execute, we assume machine is rebooting already @@ -161,7 +160,7 @@ var waitForRestart = func(ctx context.Context, p *Provisioner, comm packer.Commu } if cmd.ExitStatus() == 0 { // Cancel reboot we created to test if machine was already rebooting - cmd = &packer.RemoteCmd{Command: abortcommand} + cmd = &packersdk.RemoteCmd{Command: abortcommand} cmd.RunWithUi(ctx, comm, ui) break } @@ -212,7 +211,7 @@ var waitForCommunicator = func(ctx context.Context, p *Provisioner) error { // vm has met their necessary criteria for having restarted. If the // user doesn't set a special restart command, we just run the // default as cmdModuleLoad below. - cmdRestartCheck := &packer.RemoteCmd{Command: p.config.RestartCheckCommand} + cmdRestartCheck := &packersdk.RemoteCmd{Command: p.config.RestartCheckCommand} log.Printf("Checking that communicator is connected with: '%s'", cmdRestartCheck.Command) for { @@ -241,7 +240,7 @@ var waitForCommunicator = func(ctx context.Context, p *Provisioner) error { // provisioning before powershell is actually ready. // In this next check, we parse stdout to make sure that the command is // actually running as expected. - cmdModuleLoad := &packer.RemoteCmd{Command: DefaultRestartCheckCommand} + cmdModuleLoad := &packersdk.RemoteCmd{Command: DefaultRestartCheckCommand} var buf, buf2 bytes.Buffer cmdModuleLoad.Stdout = &buf cmdModuleLoad.Stdout = io.MultiWriter(cmdModuleLoad.Stdout, &buf2) @@ -259,7 +258,7 @@ var waitForCommunicator = func(ctx context.Context, p *Provisioner) error { shouldContinue := false for _, RegKey := range p.config.RegistryKeys { KeyTestCommand := winrm.Powershell(fmt.Sprintf(`Test-Path "%s"`, RegKey)) - cmdKeyCheck := &packer.RemoteCmd{Command: KeyTestCommand} + cmdKeyCheck := &packersdk.RemoteCmd{Command: KeyTestCommand} log.Printf("Checking registry for pending reboots") var buf, buf2 bytes.Buffer cmdKeyCheck.Stdout = &buf diff --git a/provisioner/windows-restart/provisioner_test.go b/provisioner/windows-restart/provisioner_test.go index 391068457..ac44db001 100644 --- a/provisioner/windows-restart/provisioner_test.go +++ b/provisioner/windows-restart/provisioner_test.go @@ -8,6 +8,7 @@ import ( "time" "github.com/hashicorp/packer/packer" + packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" ) func testConfig() map[string]interface{} { @@ -101,7 +102,7 @@ func TestProvisionerProvision_Success(t *testing.T) { return nil } waitForRestartOld := waitForRestart - waitForRestart = func(context.Context, *Provisioner, packer.Communicator) error { + waitForRestart = func(context.Context, *Provisioner, packersdk.Communicator) error { return nil } err := p.Provision(context.Background(), ui, comm, make(map[string]interface{})) @@ -137,7 +138,7 @@ func TestProvisionerProvision_CustomCommand(t *testing.T) { return nil } waitForRestartOld := waitForRestart - waitForRestart = func(context.Context, *Provisioner, packer.Communicator) error { + waitForRestart = func(context.Context, *Provisioner, packersdk.Communicator) error { return nil } err := p.Provision(context.Background(), ui, comm, make(map[string]interface{})) diff --git a/provisioner/windows-shell/provisioner.go b/provisioner/windows-shell/provisioner.go index 0a46d7833..8d1e1c4b9 100644 --- a/provisioner/windows-shell/provisioner.go +++ b/provisioner/windows-shell/provisioner.go @@ -16,7 +16,6 @@ import ( "time" "github.com/hashicorp/hcl/v2/hcldec" - "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer-plugin-sdk/multistep/commonsteps" packersdk "github.com/hashicorp/packer/packer-plugin-sdk/packer" "github.com/hashicorp/packer/packer-plugin-sdk/retry" @@ -160,7 +159,7 @@ func extractScript(p *Provisioner) (string, error) { return temp.Name(), nil } -func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packer.Communicator, generatedData map[string]interface{}) error { +func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packersdk.Communicator, generatedData map[string]interface{}) error { ui.Say("Provisioning with windows-shell...") scripts := make([]string, len(p.config.Scripts)) copy(scripts, p.config.Scripts) @@ -204,7 +203,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe // the case that the upload succeeded, a restart is initiated, // and then the command is executed but the file doesn't exist // any longer. - var cmd *packer.RemoteCmd + var cmd *packersdk.RemoteCmd err = retry.Config{StartTimeout: p.config.StartRetryTimeout}.Run(ctx, func(ctx context.Context) error { if _, err := f.Seek(0, 0); err != nil { return err @@ -214,7 +213,7 @@ func (p *Provisioner) Provision(ctx context.Context, ui packersdk.Ui, comm packe return fmt.Errorf("Error uploading script: %s", err) } - cmd = &packer.RemoteCmd{Command: command} + cmd = &packersdk.RemoteCmd{Command: command} return cmd.RunWithUi(ctx, comm, ui) }) if err != nil {