class StackMaster::Commands::Status

Public Class Methods

new(config, options, show_progress = true) click to toggle source
Calls superclass method StackMaster::Command::new
# File lib/stack_master/commands/status.rb, line 10
def initialize(config, options, show_progress = true)
  super(config, nil, options)
  @show_progress = show_progress
end

Public Instance Methods

perform() click to toggle source
# File lib/stack_master/commands/status.rb, line 15
def perform
  progress if @show_progress
  status = @config.stacks.map do |stack_definition|
    stack_status = StackStatus.new(@config, stack_definition)
    allowed_accounts = stack_definition.allowed_accounts
    progress.increment if @show_progress
    {
      region: stack_definition.region,
      stack_name: stack_definition.stack_name,
      stack_status: running_in_allowed_account?(allowed_accounts) ? stack_status.status : "Disallowed account",
      different: running_in_allowed_account?(allowed_accounts) ? stack_status.changed_message : "N/A",
    }
  end
  tp.set :max_width, self.window_size
  tp.set :io, StackMaster.stdout
  tp status
  StackMaster.stdout.puts " * No echo parameters can't be diffed"
end

Private Instance Methods

identity() click to toggle source
# File lib/stack_master/commands/status.rb, line 50
def identity
  @identity ||= StackMaster::Identity.new
end
progress() click to toggle source
# File lib/stack_master/commands/status.rb, line 36
def progress
  @progress ||= ProgressBar.create(title: "Fetching stack information",
                                   total: @config.stacks.size,
                                   output: StackMaster.stdout)
end
running_in_allowed_account?(allowed_accounts) click to toggle source
# File lib/stack_master/commands/status.rb, line 46
def running_in_allowed_account?(allowed_accounts)
  StackMaster.skip_account_check? || identity.running_in_account?(allowed_accounts)
end
sort_params(hash) click to toggle source
# File lib/stack_master/commands/status.rb, line 42
def sort_params(hash)
  hash.sort.to_h
end