Class: Ruby::Terraform::Commands::ApplyCommand
- Inherits:
-
Object
- Object
- Ruby::Terraform::Commands::ApplyCommand
- Includes:
- ExecutionSupport
- Defined in:
- lib/ruby/terraform/commands/apply_command.rb
Instance Attribute Summary collapse
-
#auto_approve ⇒ Object
Returns the value of attribute auto_approve.
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#state ⇒ Object
Returns the value of attribute state.
-
#vars ⇒ Object
Returns the value of attribute vars.
Instance Method Summary collapse
- #command ⇒ Object
-
#initialize(opts = {}) ⇒ ApplyCommand
constructor
A new instance of ApplyCommand.
Methods included from ExecutionSupport
Constructor Details
#initialize(opts = {}) ⇒ ApplyCommand
Returns a new instance of ApplyCommand.
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/ruby/terraform/commands/apply_command.rb', line 12 def initialize(opts = {}) @dir = opts[:dir] @state = opts[:state] @vars = opts[:vars] @auto_approve = if opts[:auto_approve].nil? true else opts[:auto_approve] end end |
Instance Attribute Details
#auto_approve ⇒ Object
Returns the value of attribute auto_approve.
10 11 12 |
# File 'lib/ruby/terraform/commands/apply_command.rb', line 10 def auto_approve @auto_approve end |
#dir ⇒ Object
Returns the value of attribute dir.
7 8 9 |
# File 'lib/ruby/terraform/commands/apply_command.rb', line 7 def dir @dir end |
#state ⇒ Object
Returns the value of attribute state.
8 9 10 |
# File 'lib/ruby/terraform/commands/apply_command.rb', line 8 def state @state end |
#vars ⇒ Object
Returns the value of attribute vars.
9 10 11 |
# File 'lib/ruby/terraform/commands/apply_command.rb', line 9 def vars @vars end |
Instance Method Details
#command ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/ruby/terraform/commands/apply_command.rb', line 23 def command cmd = %W[#{tf_binary} apply] cmd += ['-state', state] if state cmd += ['-auto-approve'] if auto_approve if vars vars.each do |key, value| var_value = value.is_a?(String) ? value : JSON.generate(value) cmd += ['-var', "#{key}=#{var_value}"] end end cmd += [dir] if dir cmd end |