Class: Terraspace::Terraform::Runner
Constant Summary collapse
- @@current_dir_message_shown =
false
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #args ⇒ Object
- #current_dir_message ⇒ Object
- #custom ⇒ Object
- #default ⇒ Object
-
#initialize(name, options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #run ⇒ Object
- #run_hooks(name, &block) ⇒ Object
- #terraform(name, *args) ⇒ Object
Methods included from Util
Methods included from Util::Sure
Methods included from Util::Sh
Methods included from Util::Logging
Constructor Details
#initialize(name, options = {}) ⇒ Runner
Returns a new instance of Runner.
7 8 9 10 |
# File 'lib/terraspace/terraform/runner.rb', line 7 def initialize(name, ={}) @name = name super() end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/terraspace/terraform/runner.rb', line 6 def name @name end |
Instance Method Details
#args ⇒ Object
41 42 43 44 |
# File 'lib/terraspace/terraform/runner.rb', line 41 def args # base at end in case of redirection. IE: terraform output > /path custom.args + custom.var_files + default.args end |
#current_dir_message ⇒ Object
29 30 31 32 33 |
# File 'lib/terraspace/terraform/runner.rb', line 29 def return if logger.info "Current directory: #{Terraspace::Util.pretty_path(@mod.cache_dir)}" = true end |
#custom ⇒ Object
46 47 48 |
# File 'lib/terraspace/terraform/runner.rb', line 46 def custom Args::Custom.new(@mod, @name) end |
#default ⇒ Object
51 52 53 |
# File 'lib/terraspace/terraform/runner.rb', line 51 def default Args::Default.new(@mod, @name, ) end |
#run ⇒ Object
12 13 14 15 16 |
# File 'lib/terraspace/terraform/runner.rb', line 12 def run time_took do terraform(name, args) end end |
#run_hooks(name, &block) ⇒ Object
35 36 37 38 39 |
# File 'lib/terraspace/terraform/runner.rb', line 35 def run_hooks(name, &block) hooks = Hooks::Builder.new(@mod, name) hooks.build # build hooks hooks.run_hooks(&block) end |
#terraform(name, *args) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/terraspace/terraform/runner.rb', line 18 def terraform(name, *args) # only show once params = args.flatten.join(' ') command = "terraform #{name} #{params}" run_hooks(name) do sh(command, env: custom.env_vars) end end |