Merge pull request #6559 from arizvisa/GH-6491

Emit both the host and the communicator to the user during StepConnect.
This commit is contained in:
Megan Marsh 2018-08-06 11:32:21 -07:00 committed by GitHub
commit 1d0e0f82dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 5 deletions

View File

@ -45,6 +45,8 @@ type StepConnect struct {
} }
func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
ui := state.Get("ui").(packer.Ui)
typeMap := map[string]multistep.Step{ typeMap := map[string]multistep.Step{
"none": nil, "none": nil,
"ssh": &StepConnectSSH{ "ssh": &StepConnectSSH{
@ -71,19 +73,26 @@ func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multist
} }
if step == nil { if step == nil {
comm, err := none.New("none") if comm, err := none.New("none"); err != nil {
if err != nil {
err := fmt.Errorf("Failed to set communicator 'none': %s", err) err := fmt.Errorf("Failed to set communicator 'none': %s", err)
state.Put("error", err) state.Put("error", err)
ui := state.Get("ui").(packer.Ui)
ui.Error(err.Error()) ui.Error(err.Error())
return multistep.ActionHalt return multistep.ActionHalt
} else {
state.Put("communicator", comm)
log.Printf("[INFO] communicator disabled, will not connect")
} }
state.Put("communicator", comm)
log.Printf("[INFO] communicator disabled, will not connect")
return multistep.ActionContinue return multistep.ActionContinue
} }
if host, err := s.Host(state); err == nil {
ui.Say(fmt.Sprintf("Using %s communicator to connect: %s", s.Config.Type, host))
} else {
log.Printf("[DEBUG] Unable to get address during connection step: %s", err)
}
s.substep = step s.substep = step
return s.substep.Run(ctx, state) return s.substep.Run(ctx, state)
} }