Skip to content

Commit

Permalink
Merge branch 'parallelism_and_extra_output'
Browse files Browse the repository at this point in the history
  • Loading branch information
phyber committed Apr 27, 2023
2 parents 08be430 + d8c41d7 commit b454737
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
= Changelog

== 1.7.0

* feat: added a `-p` flag to configure parallelism
* feat: enhanced the executor output when raising `Tfctl::Error`, it will now
report the `account_name` that raised the error along with the full command
that was being run

== 1.6.1

* fix: pagination problem when listing accounts in an OU.
Expand Down
8 changes: 6 additions & 2 deletions bin/tfctl
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ options = {
unbuffered: false,
debug: false,
use_cache: false,
parallelism: 8,
}

optparse = OptionParser.new do |opts|
Expand Down Expand Up @@ -56,6 +57,9 @@ optparse = OptionParser.new do |opts|
opts.on('-d', '--debug', 'Turn on debug messages') do
options[:debug] = true
end
opts.on('-p', '--parallelism=num', 'How many terraform processes to execute in parallel') do |o|
options[:parallelism] = o.to_i
end
opts.on('-v', '--version', 'Show version') do
puts Tfctl::VERSION
exit
Expand Down Expand Up @@ -93,7 +97,7 @@ begin
raise OptionParser::InvalidOption, 'Please specify target'
end
rescue OptionParser::InvalidOption, OptionParser::MissingArgument
warn $ERROR_INFO.to_s
warn $ERROR_INFO
warn optparse
exit 2
end
Expand Down Expand Up @@ -202,7 +206,7 @@ begin

# Execute Terraform in target accounts

Parallel.each(accounts, in_processes: 8) do |ac|
Parallel.each(accounts, in_processes: options[:parallelism]) do |ac|
run_account(config, ac, options, ARGV, log)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/tfctl/executor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def run(account_name:, config_name:, log:, cmd: nil, argv: [], unbuffered: true)
FileUtils.rm_f plan_file if args[0] == 'apply' # tidy up the plan file

unless status.exitstatus.zero?
raise Tfctl::Error, "#{cmd} failed with exit code: #{status.exitstatus}"
raise Tfctl::Error, "#{account_name}: #{runcmd} failed with exit code: #{status.exitstatus}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/tfctl/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Tfctl
VERSION = '1.6.1'
VERSION = '1.7.0'
end

0 comments on commit b454737

Please sign in to comment.