Class: RubyTerraform::Commands::Apply

Inherits:
Base
  • Object
show all
Defined in:
lib/ruby_terraform/commands/apply.rb

Instance Attribute Summary

Attributes inherited from Base

#binary

Instance Method Summary collapse

Methods inherited from Base

#do_after, #do_before, #execute, #initialize, #instantiate_builder, #stderr, #stdin, #stdout

Constructor Details

This class inherits a constructor from RubyTerraform::Commands::Base

Instance Method Details

#configure_command(builder, opts) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/ruby_terraform/commands/apply.rb', line 7

def configure_command(builder, opts)
  directory = opts[:directory]
  vars = opts[:vars] || {}
  state = opts[:state]
  no_backup = opts[:no_backup]
  backup = no_backup ? '-' : opts[:backup]
  no_color = opts[:no_color]

  builder
      .with_subcommand('apply') do |sub|
        vars.each do |key, value|
          sub = sub.with_option('-var', "'#{key}=#{value}'", separator: ' ')
        end
        sub = sub.with_option('-state', state) if state
        sub = sub.with_option('-backup', backup) if backup
        sub = sub.with_flag('-no-color') if no_color
        sub
      end
      .with_argument(directory)
end