From 78d4c93e0899e2929ed9d165100a2f8341d440f5 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet <105649352+lbajolet-hashicorp@users.noreply.github.com> Date: Wed, 27 Jul 2022 12:43:35 -0400 Subject: [PATCH] Apply suggestions from code review Co-authored-by: Wilken Rivera --- communicator/step_connect_ssh.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/communicator/step_connect_ssh.go b/communicator/step_connect_ssh.go index 53915078e8..fa5ddacda4 100644 --- a/communicator/step_connect_ssh.go +++ b/communicator/step_connect_ssh.go @@ -50,14 +50,10 @@ func (s *StepConnectSSH) Run(ctx context.Context, state multistep.StateBag) mult }() log.Printf("[INFO] Waiting for SSH, up to timeout: %s", s.Config.SSHTimeout) - var timeout <-chan time.Time - // Only setup a timeout when it is specified in the configs - if s.Config.SSHTimeout != 0 { + timeout := make(<-chan time.Time) + if s.Config.SSHTimeout > 0 { timeout = time.After(s.Config.SSHTimeout) - } else { - timeout = make(<-chan time.Time) - } - + } for { // Wait for either SSH to become available, a timeout to occur, // or an interrupt to come through.