Class: Terraspace::CLI::Down

Inherits:
Base
  • Object
show all
Includes:
Concerns::PlanPath, TfcConcern, Terraspace::Cloud::Streamer, Terraspace::Cloud::Vcs::Commenter
Defined in:
lib/terraspace/cli/down.rb

Instance Method Summary collapse

Methods included from TfcConcern

#backend, #tfc?

Methods included from Terraspace::Cloud::Vcs::Commenter

#able_to_comment?, #cloud_comment, #finalize_vars, #kind, #pr_comment, #vcs, #vcs_vars

Methods included from Terraspace::Cloud::Streamer

#cloud_stream

Methods included from Concerns::PlanPath

#plan_path

Methods inherited from Base

#initialize

Methods included from Util::Pretty

#pretty_path, #pretty_time

Methods included from Util::Sure

#sure?

Methods included from Util::Logging

#logger

Constructor Details

This class inherits a constructor from Terraspace::CLI::Base

Instance Method Details

#performObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/terraspace/cli/down.rb', line 16

def perform
  success = nil
  if @options[:yes] && !tfc?
    success = plan
  else
    skip_plan = true
  end
  if success or skip_plan
    success = destroy
  end
  success
rescue Exception => e
  @exception = true
  logger.info "Exception #{e.class}: #{e.message}".color(:red)
  logger.info e.backtrace.join("\n")
  false
end

#runObject



8
9
10
11
12
13
14
# File 'lib/terraspace/cli/down.rb', line 8

def run
  cloud_update.cani?
  @stream = cloud_stream.open("down")
  success = perform
  cloud_stream.close(success, @exception)
  exit 1 unless success
end