Class: Terraspace::Terraform::Runner
Defined Under Namespace
Classes: Retryer
Constant Summary
collapse
- @@current_dir_message_shown =
false
Instance Attribute Summary collapse
Instance Method Summary
collapse
#pretty_path, #pretty_time
Methods included from Util::Sure
#sure?
#logger
#run_hooks
Constructor Details
#initialize(name, options = {}) ⇒ Runner
Returns a new instance of Runner.
8
9
10
11
|
# File 'lib/terraspace/terraform/runner.rb', line 8
def initialize(name, options={})
@name = name
super(options)
end
|
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
7
8
9
|
# File 'lib/terraspace/terraform/runner.rb', line 7
def name
@name
end
|
Instance Method Details
#args ⇒ Object
49
50
51
52
|
# File 'lib/terraspace/terraform/runner.rb', line 49
def args
custom.args + custom.var_files + default.args
end
|
#current_dir_message ⇒ Object
38
39
40
41
42
|
# File 'lib/terraspace/terraform/runner.rb', line 38
def current_dir_message
return if @@current_dir_message_shown
log "Current directory: #{Terraspace::Util.pretty_path(@mod.cache_dir)}"
@@current_dir_message_shown = true
end
|
#custom ⇒ Object
54
55
56
|
# File 'lib/terraspace/terraform/runner.rb', line 54
def custom
Args::Custom.new(@mod, @name)
end
|
#default ⇒ Object
59
60
61
|
# File 'lib/terraspace/terraform/runner.rb', line 59
def default
Args::Default.new(@mod, @name, @options)
end
|
#log(msg) ⇒ Object
44
45
46
47
|
# File 'lib/terraspace/terraform/runner.rb', line 44
def log(msg)
@options[:quiet] ? logger.debug(msg) : logger.info(msg)
end
|
#run ⇒ Object
13
14
15
16
17
|
# File 'lib/terraspace/terraform/runner.rb', line 13
def run
time_took do
terraform(name, args)
end
end
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/terraspace/terraform/runner.rb', line 19
def terraform(name, *args)
current_dir_message
params = args.flatten.join(' ')
command = "terraform #{name} #{params}".squish
run_hooks("terraform.rb", name) do
Terraspace::Shell.new(@mod, command, @options.merge(env: custom.env_vars)).run
end
rescue Terraspace::SharedCacheError, Terraspace::InitRequiredError
@retryer ||= Retryer.new(@mod, @options, name, $!)
if @retryer.retry?
@retryer.run
retry
else
exit(1)
end
end
|