Wire context through misc steps
Some steps actually need to pass the context around, so let's create a ctx variable and pass it.
This commit is contained in:
parent
7a189a83a1
commit
5d48d658b4
|
@ -37,7 +37,7 @@ type StepDownloadGuestAdditions struct {
|
|||
Ctx interpolate.Context
|
||||
}
|
||||
|
||||
func (s *StepDownloadGuestAdditions) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepDownloadGuestAdditions) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
var action multistep.StepAction
|
||||
driver := state.Get("driver").(Driver)
|
||||
ui := state.Get("ui").(packer.Ui)
|
||||
|
@ -114,7 +114,7 @@ func (s *StepDownloadGuestAdditions) Run(_ context.Context, state multistep.Stat
|
|||
if s.GuestAdditionsSHA256 != "" {
|
||||
checksum = s.GuestAdditionsSHA256
|
||||
} else {
|
||||
checksum, action = s.downloadAdditionsSHA256(state, version, additionsName)
|
||||
checksum, action = s.downloadAdditionsSHA256(ctx, state, version, additionsName)
|
||||
if action != multistep.ActionContinue {
|
||||
return action
|
||||
}
|
||||
|
@ -141,12 +141,12 @@ func (s *StepDownloadGuestAdditions) Run(_ context.Context, state multistep.Stat
|
|||
Url: []string{url},
|
||||
}
|
||||
|
||||
return downStep.Run(state)
|
||||
return downStep.Run(ctx, state)
|
||||
}
|
||||
|
||||
func (s *StepDownloadGuestAdditions) Cleanup(state multistep.StateBag) {}
|
||||
|
||||
func (s *StepDownloadGuestAdditions) downloadAdditionsSHA256(state multistep.StateBag, additionsVersion string, additionsName string) (string, multistep.StepAction) {
|
||||
func (s *StepDownloadGuestAdditions) downloadAdditionsSHA256(ctx context.Context, state multistep.StateBag, additionsVersion string, additionsName string) (string, multistep.StepAction) {
|
||||
// First things first, we get the list of checksums for the files available
|
||||
// for this version.
|
||||
checksumsUrl := fmt.Sprintf(
|
||||
|
@ -170,7 +170,7 @@ func (s *StepDownloadGuestAdditions) downloadAdditionsSHA256(state multistep.Sta
|
|||
Url: []string{checksumsUrl},
|
||||
}
|
||||
|
||||
action := downStep.Run(state)
|
||||
action := downStep.Run(ctx, state)
|
||||
if action == multistep.ActionHalt {
|
||||
return "", action
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
@ -65,8 +66,8 @@ func (s abortStep) InnerStepName() string {
|
|||
return typeName(s.step)
|
||||
}
|
||||
|
||||
func (s abortStep) Run(state multistep.StateBag) multistep.StepAction {
|
||||
return s.step.Run(state)
|
||||
func (s abortStep) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
return s.step.Run(ctx, state)
|
||||
}
|
||||
|
||||
func (s abortStep) Cleanup(state multistep.StateBag) {
|
||||
|
@ -90,9 +91,9 @@ func (s askStep) InnerStepName() string {
|
|||
return typeName(s.step)
|
||||
}
|
||||
|
||||
func (s askStep) Run(state multistep.StateBag) (action multistep.StepAction) {
|
||||
func (s askStep) Run(ctx context.Context, state multistep.StateBag) (action multistep.StepAction) {
|
||||
for {
|
||||
action = s.step.Run(state)
|
||||
action = s.step.Run(ctx, state)
|
||||
|
||||
if action != multistep.ActionHalt {
|
||||
return
|
||||
|
|
|
@ -44,7 +44,7 @@ type StepConnect struct {
|
|||
substep multistep.Step
|
||||
}
|
||||
|
||||
func (s *StepConnect) Run(_ context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
||||
typeMap := map[string]multistep.Step{
|
||||
"none": nil,
|
||||
"ssh": &StepConnectSSH{
|
||||
|
@ -85,7 +85,7 @@ func (s *StepConnect) Run(_ context.Context, state multistep.StateBag) multistep
|
|||
}
|
||||
|
||||
s.substep = step
|
||||
return s.substep.Run(state)
|
||||
return s.substep.Run(ctx, state)
|
||||
}
|
||||
|
||||
func (s *StepConnect) Cleanup(state multistep.StateBag) {
|
||||
|
|
Loading…
Reference in New Issue