Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

added a --with-facet option to knife cluster list

  • Loading branch information...
commit d8b7ca66490606c5068cfe88a37d1da66906303e 1 parent d3aca11
Travis Dempsey authored
Showing with 17 additions and 10 deletions.
  1. +17 −10 lib/chef/knife/cluster_list.rb
27 lib/chef/knife/cluster_list.rb
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.