Class: SimplyGenius::Atmos::Commands::Terraform

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/simplygenius/atmos/commands/terraform.rb

Direct Known Subclasses

Apply, Destroy, Init, Plan

Class Method Summary collapse

Instance Method Summary collapse

Methods included from UI

#agree, #ask, #choose, color_enabled, color_enabled=, #display, #error, #notify, #say, #warn

Class Method Details

.descriptionObject



10
11
12
# File 'lib/simplygenius/atmos/commands/terraform.rb', line 10

def self.description
  "Runs terraform"
end

Instance Method Details

#executeObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/simplygenius/atmos/commands/terraform.rb', line 20

def execute

  unless Atmos.config.is_atmos_repo?
    signal_usage_error <<~EOF
      Atmos can only run terraform from a location configured for atmos. 
      Have you run atmos init?"
    EOF
  end

  Atmos.config.provider.auth_manager.authenticate(ENV) do |auth_env|
    begin
      exe = TerraformExecutor.new(process_env: auth_env)
      get_modules = @terraform_arguments.delete("--get-modules")
      exe.run(*@terraform_arguments, get_modules: get_modules.present?)
    rescue TerraformExecutor::ProcessFailed => e
      logger.error(e.message)
    end
  end
end

#parse(arguments) ⇒ Object

override so we can pass all options/flags/parameters directly to terraform instead of having clamp parse them



16
17
18
# File 'lib/simplygenius/atmos/commands/terraform.rb', line 16

def parse(arguments)
  @terraform_arguments = arguments
end