Skip to content

Commit

Permalink
Merge pull request #224 from kornypoet/master
Browse files Browse the repository at this point in the history
Added --with-facet option to knife cluster list
  • Loading branch information
temujin9 committed Dec 13, 2012
2 parents d3aca11 + d8b7ca6 commit 372b82f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions lib/chef/knife/cluster_list.rb
Expand Up @@ -27,23 +27,30 @@ class ClusterList < Knife
require 'formatador'
end

banner "knife cluster list (options)"

banner 'knife cluster list (options)'

option :facets,
:long => '--with-facets',
:description => 'List cluster facets along with names and paths',
:default => false,
:boolean => true

def run
load_ironfan
configure_dry_run

hash = Ironfan.cluster_filenames

table = []
hash.keys.sort.each do |key|
table.push( { :cluster => key, :path => hash[key] } )
data = Ironfan.cluster_filenames.map do |name, path|
as_table = { :cluster => name, :path => path }
if config[:facets]
facets = Ironfan.load_cluster(name).facets.to_a.map(&:name).join(', ')
as_table.merge!(:facets => facets)
end
as_table
end

ui.info "Cluster Path: #{ Ironfan.cluster_path.join ", " }"

Formatador.display_compact_table(table, [:cluster,:path])

headers = config[:facets] ? [:cluster, :facets, :path] : [:cluster, :path]
Formatador.display_compact_table(data, headers)
end
end
end
Expand Down

0 comments on commit 372b82f

Please sign in to comment.