Class: Ruby::Terraform::Commands::PlanCommand
- Inherits:
-
Object
- Object
- Ruby::Terraform::Commands::PlanCommand
- Includes:
- ExecutionSupport
- Defined in:
- lib/ruby/terraform/commands/plan_command.rb
Instance Attribute Summary collapse
-
#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 = {}) ⇒ PlanCommand
constructor
A new instance of PlanCommand.
Methods included from ExecutionSupport
Constructor Details
#initialize(opts = {}) ⇒ PlanCommand
Returns a new instance of PlanCommand.
11 12 13 14 15 |
# File 'lib/ruby/terraform/commands/plan_command.rb', line 11 def initialize(opts = {}) @dir = opts[:dir] @state = opts[:state] @vars = opts[:vars] end |
Instance Attribute Details
#dir ⇒ Object
Returns the value of attribute dir.
7 8 9 |
# File 'lib/ruby/terraform/commands/plan_command.rb', line 7 def dir @dir end |
#state ⇒ Object
Returns the value of attribute state.
8 9 10 |
# File 'lib/ruby/terraform/commands/plan_command.rb', line 8 def state @state end |
#vars ⇒ Object
Returns the value of attribute vars.
9 10 11 |
# File 'lib/ruby/terraform/commands/plan_command.rb', line 9 def vars @vars end |
Instance Method Details
#command ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/ruby/terraform/commands/plan_command.rb', line 17 def command cmd = %W[#{tf_binary} plan] cmd += ['-state', state] if state 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 |