Skip to content

Commit

Permalink
Merge pull request #112 from boltops-tools/fix-smart-auto-retry
Browse files Browse the repository at this point in the history
fix smart auto retry
  • Loading branch information
tongueroo authored May 7, 2021
2 parents df02738 + 8959d59 commit b10a3d1
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions lib/terraspace/shell.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,30 @@ def handle_streams(stdin, stdout, stderr)

lines = buffer.split("\n")
lines.each do |line|
terraform_to_stdout(line)
handle_input(stdin, line)
if f.fileno == stdout.fileno
handle_stdout(line)
handle_input(stdin, line)
else
handle_stderr(line)
end
end
end
end
end
end

def handle_stderr(line)
@error ||= Error.new
@error.lines << line # aggregate all error lines

return if @error.known?
# Sometimes may print a "\e[31m\n" which like during dependencies fetcher init
# suppress it so dont get a bunch of annoying "newlines"
return if line == "\e[31m\n" && @options[:suppress_error_color]

logger.error(line)
end

def all_eof?(files)
files.find { |f| !f.eof }.nil?
end
Expand Down Expand Up @@ -93,7 +109,7 @@ def exit_status(status)
end
end

def terraform_to_stdout(line)
def handle_stdout(line)
prompted = line.include?('Enter a value')
@prompt_shown ||= prompted
return if @prompt_shown && prompted
Expand Down

0 comments on commit b10a3d1

Please sign in to comment.