From a3cec4f274ec1182b66e697bb8faa4f4cbfceb4c Mon Sep 17 00:00:00 2001 From: Ali Rizvi-Santiago Date: Sun, 29 Jul 2018 02:18:26 -0500 Subject: [PATCH] Emit both the host and the communicator to the user during StepConnect. --- helper/communicator/step_connect.go | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/helper/communicator/step_connect.go b/helper/communicator/step_connect.go index 273935710..10adc5d2b 100644 --- a/helper/communicator/step_connect.go +++ b/helper/communicator/step_connect.go @@ -45,6 +45,8 @@ type StepConnect struct { } func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction { + ui := state.Get("ui").(packer.Ui) + typeMap := map[string]multistep.Step{ "none": nil, "ssh": &StepConnectSSH{ @@ -71,19 +73,26 @@ func (s *StepConnect) Run(ctx context.Context, state multistep.StateBag) multist } if step == nil { - comm, err := none.New("none") - if err != nil { + if comm, err := none.New("none"); err != nil { err := fmt.Errorf("Failed to set communicator 'none': %s", err) state.Put("error", err) - ui := state.Get("ui").(packer.Ui) ui.Error(err.Error()) 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 } + 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 return s.substep.Run(ctx, state) }