Class: Chef::Knife::CloudformationList

Inherits:
Chef::Knife show all
Includes:
KnifeCloudformation::Knife::Base
Defined in:
lib/chef/knife/cloudformation_list.rb

Overview

Cloudformation list command

Instance Method Summary collapse

Methods included from KnifeCloudformation::Knife::Base

included

Instance Method Details

#_runObject

Run the list command



38
39
40
# File 'lib/chef/knife/cloudformation_list.rb', line 38

def _run
  things_output(nil, get_list, nil)
end

#default_attributesArray<String>

Returns default attributes to display.

Returns:

  • (Array<String>)

    default attributes to display



62
63
64
65
66
67
68
# File 'lib/chef/knife/cloudformation_list.rb', line 62

def default_attributes
  if(provider.connection.provider == :aws)
    %w(name created status template_description)
  else
    %w(name created status description)
  end
end

#get_listArray<Hash>

Get the list of stacks to display

Returns:

  • (Array<Hash>)


45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/chef/knife/cloudformation_list.rb', line 45

def get_list
  get_things do
    provider.stacks.all.map do |stack|
      Mash.new(stack.attributes)
    end.sort do |x, y|
      if(y[:created].to_s.empty?)
        -1
      elsif(x[:created].to_s.empty?)
        1
      else
        Time.parse(y['created'].to_s) <=> Time.parse(x['created'].to_s)
      end
    end
  end
end