Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Added --with-facet option to knife cluster list #224

Merged
merged 1 commit into from

2 participants

@kornypoet
Owner

No description provided.

@temujin9 temujin9 merged commit 372b82f into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2012
  1. @kornypoet
This page is out of date. Refresh to see the latest.
Showing with 17 additions and 10 deletions.
  1. +17 −10 lib/chef/knife/cluster_list.rb
View
27 lib/chef/knife/cluster_list.rb
@@ -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
Something went wrong with that request. Please try again.