From f4c3501af5663959ac2f7d12ff47296453bb59e9 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 11 Jul 2019 09:37:59 -0700 Subject: [PATCH] pass struct of generated data into provision() call --- common/step_provision.go | 16 ++++++++- packer/plugin/provisioner.go | 4 +-- packer/provisioner.go | 32 +++++++++++++---- packer/provisioner_mock.go | 2 +- packer/provisioner_timeout.go | 4 +-- packer/rpc/provisioner.go | 6 ++-- provisioner/ansible-local/provisioner.go | 2 +- provisioner/ansible/provisioner.go | 2 +- provisioner/breakpoint/provisioner.go | 2 +- provisioner/chef-client/provisioner.go | 2 +- provisioner/chef-solo/provisioner.go | 2 +- provisioner/converge/provisioner.go | 2 +- provisioner/file/provisioner.go | 2 +- provisioner/inspec/provisioner.go | 2 +- provisioner/powershell/provisioner.go | 38 +++++++------------- provisioner/puppet-masterless/provisioner.go | 2 +- provisioner/puppet-server/provisioner.go | 2 +- provisioner/salt-masterless/provisioner.go | 2 +- provisioner/shell-local/provisioner.go | 2 +- provisioner/shell/provisioner.go | 2 +- provisioner/sleep/provisioner.go | 2 +- provisioner/windows-restart/provisioner.go | 2 +- provisioner/windows-shell/provisioner.go | 2 +- 23 files changed, 78 insertions(+), 56 deletions(-) diff --git a/common/step_provision.go b/common/step_provision.go index 07ba39f81..233bcf2fc 100644 --- a/common/step_provision.go +++ b/common/step_provision.go @@ -23,6 +23,17 @@ type StepProvision struct { Comm packer.Communicator } +func PopulateProvisionHookData(state multistep.StateBag) packer.ProvisionHookData { + hookData := packer.NewProvisionHookData() + + // Add WinRMPassword to runtime data + WinRMPassword, ok := state.GetOk("winrm_password") + if ok { + hookData.WinRMPassword = WinRMPassword.(string) + } + return hookData +} + func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBag, hooktype string) multistep.StepAction { // hooktype will be either packer.HookProvision or packer.HookCleanupProvision comm := s.Comm @@ -32,9 +43,12 @@ func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBa comm = raw.(packer.Communicator) } } + hook := state.Get("hook").(packer.Hook) ui := state.Get("ui").(packer.Ui) + hookData := PopulateProvisionHookData(state) + // Run the provisioner in a goroutine so we can continually check // for cancellations... if hooktype == packer.HookProvision { @@ -44,7 +58,7 @@ func (s *StepProvision) runWithHook(ctx context.Context, state multistep.StateBa } errCh := make(chan error, 1) go func() { - errCh <- hook.Run(ctx, hooktype, ui, comm, nil) + errCh <- hook.Run(ctx, hooktype, ui, comm, &hookData) }() for { diff --git a/packer/plugin/provisioner.go b/packer/plugin/provisioner.go index 9c3b8fb42..23cb41730 100644 --- a/packer/plugin/provisioner.go +++ b/packer/plugin/provisioner.go @@ -21,13 +21,13 @@ func (c *cmdProvisioner) Prepare(configs ...interface{}) error { return c.p.Prepare(configs...) } -func (c *cmdProvisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (c *cmdProvisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData *packer.ProvisionHookData) error { defer func() { r := recover() c.checkExit(r, nil) }() - return c.p.Provision(ctx, ui, comm) + return c.p.Provision(ctx, ui, comm, generatedData) } func (c *cmdProvisioner) checkExit(p interface{}, cb func()) { diff --git a/packer/provisioner.go b/packer/provisioner.go index ff89c0c42..c9e9a9f31 100644 --- a/packer/provisioner.go +++ b/packer/provisioner.go @@ -20,7 +20,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, Ui, Communicator) error + Provision(context.Context, Ui, Communicator, *ProvisionHookData) error } // A HookedProvisioner represents a provisioner and information describing it @@ -37,6 +37,21 @@ type ProvisionHook struct { Provisioners []*HookedProvisioner } +type ProvisionHookData struct { + WinRMPassword string +} + +func NewProvisionHookData() ProvisionHookData { + // this is the function we use to create the provisionhookdata, and as a + // bonus the initialized state applies defaults that act as passthroughs so + // that when prepare is called the first time, we can save interpolating + // these values until provisioner run time. + hookData := ProvisionHookData{ + WinRMPassword: `{{.WinRMPassword}}`, + } + return hookData +} + // Runs the provisioners in order. func (h *ProvisionHook) Run(ctx context.Context, name string, ui Ui, comm Communicator, data interface{}) error { // Shortcut @@ -44,6 +59,11 @@ func (h *ProvisionHook) Run(ctx context.Context, name string, ui Ui, comm Commun return nil } + generatedData := NewProvisionHookData() + if data != nil { + generatedData = data.(ProvisionHookData) + } + if comm == nil { return fmt.Errorf( "No communicator found for provisioners! This is usually because the\n" + @@ -53,7 +73,7 @@ func (h *ProvisionHook) Run(ctx context.Context, name string, ui Ui, comm Commun for _, p := range h.Provisioners { ts := CheckpointReporter.AddSpan(p.TypeName, "provisioner", p.Config) - err := p.Provisioner.Provision(ctx, ui, comm) + err := p.Provisioner.Provision(ctx, ui, comm, &generatedData) ts.End(err) if err != nil { @@ -75,7 +95,7 @@ func (p *PausedProvisioner) Prepare(raws ...interface{}) error { return p.Provisioner.Prepare(raws...) } -func (p *PausedProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator) error { +func (p *PausedProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator, generatedData *ProvisionHookData) 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)) @@ -85,7 +105,7 @@ func (p *PausedProvisioner) Provision(ctx context.Context, ui Ui, comm Communica return ctx.Err() } - return p.Provisioner.Provision(ctx, ui, comm) + return p.Provisioner.Provision(ctx, ui, comm, generatedData) } // DebuggedProvisioner is a Provisioner implementation that waits until a key @@ -102,7 +122,7 @@ func (p *DebuggedProvisioner) Prepare(raws ...interface{}) error { return p.Provisioner.Prepare(raws...) } -func (p *DebuggedProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator) error { +func (p *DebuggedProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator, generatedData *ProvisionHookData) error { // Use a select to determine if we get cancelled during the wait message := "Pausing before the next provisioner . Press enter to continue." @@ -122,5 +142,5 @@ func (p *DebuggedProvisioner) Provision(ctx context.Context, ui Ui, comm Communi return ctx.Err() } - return p.Provisioner.Provision(ctx, ui, comm) + return p.Provisioner.Provision(ctx, ui, comm, generatedData) } diff --git a/packer/provisioner_mock.go b/packer/provisioner_mock.go index 9555c5f57..26be569a2 100644 --- a/packer/provisioner_mock.go +++ b/packer/provisioner_mock.go @@ -22,7 +22,7 @@ func (t *MockProvisioner) Prepare(configs ...interface{}) error { return nil } -func (t *MockProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator) error { +func (t *MockProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator, generatedData *ProvisionHookData) error { t.ProvCalled = true t.ProvCommunicator = comm t.ProvUi = ui diff --git a/packer/provisioner_timeout.go b/packer/provisioner_timeout.go index 1da02f563..cfe0566b5 100644 --- a/packer/provisioner_timeout.go +++ b/packer/provisioner_timeout.go @@ -13,7 +13,7 @@ type TimeoutProvisioner struct { Timeout time.Duration } -func (p *TimeoutProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator) error { +func (p *TimeoutProvisioner) Provision(ctx context.Context, ui Ui, comm Communicator, generatedData *ProvisionHookData) error { ctx, cancel := context.WithTimeout(ctx, p.Timeout) defer cancel() @@ -37,7 +37,7 @@ func (p *TimeoutProvisioner) Provision(ctx context.Context, ui Ui, comm Communic } }() - err := p.Provisioner.Provision(ctx, ui, comm) + err := p.Provisioner.Provision(ctx, ui, comm, generatedData) close(errC) return err } diff --git a/packer/rpc/provisioner.go b/packer/rpc/provisioner.go index faad6f434..5fcabf1f7 100644 --- a/packer/rpc/provisioner.go +++ b/packer/rpc/provisioner.go @@ -38,7 +38,7 @@ func (p *provisioner) Prepare(configs ...interface{}) (err error) { return } -func (p *provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData *packer.ProvisionHookData) error { nextId := p.mux.NextId() server := newServerWithMux(p.mux, nextId) server.RegisterCommunicator(comm) @@ -66,7 +66,7 @@ func (p *ProvisionerServer) Prepare(args *ProvisionerPrepareArgs, reply *interfa return p.p.Prepare(args.Configs...) } -func (p *ProvisionerServer) Provision(streamId uint32, reply *interface{}) error { +func (p *ProvisionerServer) Provision(streamId uint32, reply *interface{}, generatedData *packer.ProvisionHookData) error { client, err := newClientWithMux(p.mux, streamId) if err != nil { return NewBasicError(err) @@ -77,7 +77,7 @@ func (p *ProvisionerServer) Provision(streamId uint32, reply *interface{}) error p.context, p.contextCancel = context.WithCancel(context.Background()) } - if err := p.p.Provision(p.context, client.Ui(), client.Communicator()); err != nil { + if err := p.p.Provision(p.context, client.Ui(), client.Communicator(), generatedData); err != nil { return NewBasicError(err) } diff --git a/provisioner/ansible-local/provisioner.go b/provisioner/ansible-local/provisioner.go index 4575115ac..be3449b3b 100644 --- a/provisioner/ansible-local/provisioner.go +++ b/provisioner/ansible-local/provisioner.go @@ -188,7 +188,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { ui.Say("Provisioning with Ansible...") if len(p.config.PlaybookDir) > 0 { diff --git a/provisioner/ansible/provisioner.go b/provisioner/ansible/provisioner.go index 6de5bba5f..e717edb50 100644 --- a/provisioner/ansible/provisioner.go +++ b/provisioner/ansible/provisioner.go @@ -214,7 +214,7 @@ func (p *Provisioner) getVersion() error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { ui.Say("Provisioning with Ansible...") // Interpolate env vars to check for .WinRMPassword p.config.ctx.Data = &PassthroughTemplate{ diff --git a/provisioner/breakpoint/provisioner.go b/provisioner/breakpoint/provisioner.go index 8ff752065..668da955b 100644 --- a/provisioner/breakpoint/provisioner.go +++ b/provisioner/breakpoint/provisioner.go @@ -42,7 +42,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) 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 6ca75e402..a5091b748 100644 --- a/provisioner/chef-client/provisioner.go +++ b/provisioner/chef-client/provisioner.go @@ -244,7 +244,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { p.communicator = comm diff --git a/provisioner/chef-solo/provisioner.go b/provisioner/chef-solo/provisioner.go index 39d59b36b..7d8119eb6 100644 --- a/provisioner/chef-solo/provisioner.go +++ b/provisioner/chef-solo/provisioner.go @@ -238,7 +238,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { ui.Say("Provisioning with chef-solo") if !p.config.SkipInstall { diff --git a/provisioner/converge/provisioner.go b/provisioner/converge/provisioner.go index c0c5cbeb4..b226edaac 100644 --- a/provisioner/converge/provisioner.go +++ b/provisioner/converge/provisioner.go @@ -108,7 +108,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { } // Provision node somehow. TODO: actual docs -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { ui.Say("Provisioning with Converge") // bootstrapping diff --git a/provisioner/file/provisioner.go b/provisioner/file/provisioner.go index 9fc73b950..eb8d3db6a 100644 --- a/provisioner/file/provisioner.go +++ b/provisioner/file/provisioner.go @@ -92,7 +92,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { if p.config.Direction == "download" { return p.ProvisionDownload(ui, comm) } else { diff --git a/provisioner/inspec/provisioner.go b/provisioner/inspec/provisioner.go index 0b7d047aa..e12d419ed 100644 --- a/provisioner/inspec/provisioner.go +++ b/provisioner/inspec/provisioner.go @@ -186,7 +186,7 @@ func (p *Provisioner) getVersion() error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { ui.Say("Provisioning with Inspec...") for i, envVar := range p.config.InspecEnvVars { diff --git a/provisioner/powershell/provisioner.go b/provisioner/powershell/provisioner.go index 5ff6cbe93..9c6fd76aa 100644 --- a/provisioner/powershell/provisioner.go +++ b/provisioner/powershell/provisioner.go @@ -20,7 +20,6 @@ import ( "github.com/hashicorp/packer/common/retry" "github.com/hashicorp/packer/common/shell" "github.com/hashicorp/packer/common/uuid" - commonhelper "github.com/hashicorp/packer/helper/common" "github.com/hashicorp/packer/helper/config" "github.com/hashicorp/packer/packer" "github.com/hashicorp/packer/packer/tmp" @@ -73,8 +72,9 @@ type Config struct { } type Provisioner struct { - config Config - communicator packer.Communicator + config Config + communicator packer.Communicator + generatedData *packer.ProvisionHookData } type ExecuteCommandTemplate struct { @@ -83,10 +83,6 @@ type ExecuteCommandTemplate struct { WinRMPassword string } -type EnvVarsTemplate struct { - WinRMPassword string -} - func (p *Provisioner) defaultExecuteCommand() string { baseCmd := `& { if (Test-Path variable:global:ProgressPreference)` + `{set-variable -name variable:global:ProgressPreference -value 'SilentlyContinue'};` + @@ -101,9 +97,7 @@ func (p *Provisioner) defaultExecuteCommand() string { func (p *Provisioner) Prepare(raws ...interface{}) error { // Create passthrough for winrm password so we can fill it in once we know // it - p.config.ctx.Data = &EnvVarsTemplate{ - WinRMPassword: `{{.WinRMPassword}}`, - } + p.config.ctx.Data = packer.NewProvisionHookData() err := config.Decode(&p.config, &config.DecodeOpts{ Interpolate: true, @@ -232,9 +226,12 @@ func extractScript(p *Provisioner) (string, error) { return temp.Name(), nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, generatedData *packer.ProvisionHookData) error { ui.Say(fmt.Sprintf("Provisioning with Powershell...")) p.communicator = comm + p.generatedData = generatedData + + packer.LogSecretFilter.Set(p.generatedData.WinRMPassword) scripts := make([]string, len(p.config.Scripts)) copy(scripts, p.config.Scripts) @@ -344,9 +341,8 @@ func (p *Provisioner) createFlattenedEnvVars(elevated bool) (flattened string) { } // interpolate environment variables - p.config.ctx.Data = &EnvVarsTemplate{ - WinRMPassword: getWinRMPassword(p.config.PackerBuildName), - } + p.config.ctx.Data = p.generatedData + // Split vars into key/value components for _, envVar := range p.config.Vars { envVar, err := interpolate.Render(envVar, &p.config.ctx) @@ -421,7 +417,7 @@ func (p *Provisioner) createCommandTextNonPrivileged() (command string, err erro p.config.ctx.Data = &ExecuteCommandTemplate{ Path: p.config.RemotePath, Vars: p.config.RemoteEnvVarPath, - WinRMPassword: getWinRMPassword(p.config.PackerBuildName), + WinRMPassword: p.generatedData.WinRMPassword, } command, err = interpolate.Render(p.config.ExecuteCommand, &p.config.ctx) @@ -433,12 +429,6 @@ func (p *Provisioner) createCommandTextNonPrivileged() (command string, err erro return command, nil } -func getWinRMPassword(buildName string) string { - winRMPass, _ := commonhelper.RetrieveSharedState("winrm_password", buildName) - packer.LogSecretFilter.Set(winRMPass) - return winRMPass -} - func (p *Provisioner) createCommandTextPrivileged() (command string, err error) { // Prepare everything needed to enable the required env vars within the // remote environment @@ -450,7 +440,7 @@ func (p *Provisioner) createCommandTextPrivileged() (command string, err error) p.config.ctx.Data = &ExecuteCommandTemplate{ Path: p.config.RemotePath, Vars: p.config.RemoteEnvVarPath, - WinRMPassword: getWinRMPassword(p.config.PackerBuildName), + WinRMPassword: p.generatedData.WinRMPassword, } command, err = interpolate.Render(p.config.ElevatedExecuteCommand, &p.config.ctx) if err != nil { @@ -475,9 +465,7 @@ func (p *Provisioner) ElevatedUser() string { func (p *Provisioner) ElevatedPassword() string { // Replace ElevatedPassword for winrm users who used this feature - p.config.ctx.Data = &EnvVarsTemplate{ - WinRMPassword: getWinRMPassword(p.config.PackerBuildName), - } + p.config.ctx.Data = p.generatedData elevatedPassword, _ := interpolate.Render(p.config.ElevatedPassword, &p.config.ctx) diff --git a/provisioner/puppet-masterless/provisioner.go b/provisioner/puppet-masterless/provisioner.go index d66e54baa..fe6a899d8 100644 --- a/provisioner/puppet-masterless/provisioner.go +++ b/provisioner/puppet-masterless/provisioner.go @@ -259,7 +259,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { ui.Say("Provisioning with Puppet...") p.communicator = comm ui.Message("Creating Puppet staging directory...") diff --git a/provisioner/puppet-server/provisioner.go b/provisioner/puppet-server/provisioner.go index e4fc2adff..256050ef9 100644 --- a/provisioner/puppet-server/provisioner.go +++ b/provisioner/puppet-server/provisioner.go @@ -229,7 +229,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { ui.Say("Provisioning with Puppet...") p.communicator = comm ui.Message("Creating Puppet staging directory...") diff --git a/provisioner/salt-masterless/provisioner.go b/provisioner/salt-masterless/provisioner.go index 5531d76b9..485f58389 100644 --- a/provisioner/salt-masterless/provisioner.go +++ b/provisioner/salt-masterless/provisioner.go @@ -222,7 +222,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { var err error var src, dst string diff --git a/provisioner/shell-local/provisioner.go b/provisioner/shell-local/provisioner.go index f92f93c70..d5de2b51c 100644 --- a/provisioner/shell-local/provisioner.go +++ b/provisioner/shell-local/provisioner.go @@ -25,7 +25,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, _ packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, _ packer.Communicator, _ *packer.ProvisionHookData) error { _, retErr := sl.Run(ctx, ui, &p.config) return retErr diff --git a/provisioner/shell/provisioner.go b/provisioner/shell/provisioner.go index 824225aee..dd2560fc8 100644 --- a/provisioner/shell/provisioner.go +++ b/provisioner/shell/provisioner.go @@ -179,7 +179,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { scripts := make([]string, len(p.config.Scripts)) copy(scripts, p.config.Scripts) diff --git a/provisioner/sleep/provisioner.go b/provisioner/sleep/provisioner.go index 646f1c4dd..84de8ae16 100644 --- a/provisioner/sleep/provisioner.go +++ b/provisioner/sleep/provisioner.go @@ -20,7 +20,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return config.Decode(&p, &config.DecodeOpts{}, raws...) } -func (p *Provisioner) Provision(ctx context.Context, _ packer.Ui, _ packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, _ packer.Ui, _ packer.Communicator, _ *packer.ProvisionHookData) error { select { case <-ctx.Done(): return ctx.Err() diff --git a/provisioner/windows-restart/provisioner.go b/provisioner/windows-restart/provisioner.go index f2bc01d30..20ff840f2 100644 --- a/provisioner/windows-restart/provisioner.go +++ b/provisioner/windows-restart/provisioner.go @@ -96,7 +96,7 @@ func (p *Provisioner) Prepare(raws ...interface{}) error { return nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { p.cancelLock.Lock() p.cancel = make(chan struct{}) p.cancelLock.Unlock() diff --git a/provisioner/windows-shell/provisioner.go b/provisioner/windows-shell/provisioner.go index 2f42b145d..dbb441f83 100644 --- a/provisioner/windows-shell/provisioner.go +++ b/provisioner/windows-shell/provisioner.go @@ -156,7 +156,7 @@ func extractScript(p *Provisioner) (string, error) { return temp.Name(), nil } -func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator) error { +func (p *Provisioner) Provision(ctx context.Context, ui packer.Ui, comm packer.Communicator, _ *packer.ProvisionHookData) error { ui.Say(fmt.Sprintf("Provisioning with windows-shell...")) scripts := make([]string, len(p.config.Scripts)) copy(scripts, p.config.Scripts)