Emit both the host and the communicator to the user during StepConnect.

This commit is contained in:
Ali Rizvi-Santiago 2018-07-29 02:18:26 -05:00
parent fe9e1bc9af
commit a3cec4f274

View File

@ -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)
}