Class: Terradactyl::Terraform::Commands::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/terradactyl/terraform/commands/base.rb

Direct Known Subclasses

Apply, Destroy, Fmt, Init, Plan, Refresh, Show, Validate, Version

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir_or_plan: nil, options: nil) ⇒ Base

Returns a new instance of Base.



43
44
45
46
47
48
# File 'lib/terradactyl/terraform/commands/base.rb', line 43

def initialize(dir_or_plan: nil, options: nil)
  @dir_or_plan = dir_or_plan.to_s
  @options     = options || Options.new
  Terradactyl::Terraform.select_revision(version, self)
  inject_env_vars
end

Instance Attribute Details

#dir_or_planObject

Returns the value of attribute dir_or_plan.



41
42
43
# File 'lib/terradactyl/terraform/commands/base.rb', line 41

def dir_or_plan
  @dir_or_plan
end

#optionsObject

Returns the value of attribute options.



41
42
43
# File 'lib/terradactyl/terraform/commands/base.rb', line 41

def options
  @options
end

Class Method Details

.execute(dir_or_plan: nil, options: nil, capture: false) ⇒ Object



36
37
38
39
# File 'lib/terradactyl/terraform/commands/base.rb', line 36

def self.execute(dir_or_plan: nil, options: nil, capture: false)
  new(dir_or_plan: dir_or_plan,
      options: options).execute(capture: capture)
end

Instance Method Details

#execute(capture: false) ⇒ Object



50
51
52
53
54
# File 'lib/terradactyl/terraform/commands/base.rb', line 50

def execute(capture: false)
  cmd = assemble_command
  echo_cmd(cmd)
  send((capture ? :capture3 : :popen3), ENV, cmd)
end