diff options
Diffstat (limited to 'lib/chef/run_list/run_list_expansion.rb')
-rw-r--r-- | lib/chef/run_list/run_list_expansion.rb | 33 |
1 files changed, 11 insertions, 22 deletions
diff --git a/lib/chef/run_list/run_list_expansion.rb b/lib/chef/run_list/run_list_expansion.rb index bac748096d..2a29839b35 100644 --- a/lib/chef/run_list/run_list_expansion.rb +++ b/lib/chef/run_list/run_list_expansion.rb @@ -29,7 +29,6 @@ class Chef # Abstract Base class for expanding a run list. Subclasses must handle # fetching roles from a data source by defining +fetch_role+ class RunListExpansion - attr_reader :run_list_items # A VersionedRecipeList of recipes. Populated only after #expand @@ -62,7 +61,7 @@ class Chef attr_reader :all_missing_roles attr_reader :role_errors - def initialize(environment, run_list_items, source=nil) + def initialize(environment, run_list_items, source = nil) @environment = environment @missing_roles_with_including_role = Array.new @@ -75,8 +74,8 @@ class Chef @recipes = Chef::RunList::VersionedRecipeList.new @applied_roles = {} - @run_list_trace = Hash.new {|h, key| h[key] = [] } - @better_run_list_trace = Hash.new {|h, key| h[key] = [] } + @run_list_trace = Hash.new { |h, key| h[key] = [] } + @better_run_list_trace = Hash.new { |h, key| h[key] = [] } @all_missing_roles = {} @role_errors = {} end @@ -140,7 +139,7 @@ class Chef end def errors - @missing_roles_with_including_role.map {|item| item.first } + @missing_roles_with_including_role.map { |item| item.first } end def to_json(*a) @@ -148,8 +147,8 @@ class Chef end def to_hash - seen_items = {:recipe => {}, :role => {}} - {:id => @environment, :run_list => convert_run_list_trace("top level", seen_items)} + seen_items = { :recipe => {}, :role => {} } + { :id => @environment, :run_list => convert_run_list_trace("top level", seen_items) } end private @@ -160,11 +159,10 @@ class Chef @applied_roles[role_name] = true end - def expand_run_list_items(items, included_by="top level") - + def expand_run_list_items(items, included_by = "top level") if entry = items.shift @run_list_trace[included_by.to_s] << entry.to_s - @better_run_list_trace[included_by.to_s] << entry + @better_run_list_trace[included_by.to_s] << entry case entry.type when :recipe @@ -186,33 +184,28 @@ class Chef seen_items[item.type][item.name] = true case item.type when :recipe - {:type => "recipe", :name => item.name, :version => item.version, :skipped => !!skipped} + { :type => "recipe", :name => item.name, :version => item.version, :skipped => !!skipped } when :role error = @role_errors[item.name] missing = @all_missing_roles[item.name] - {:type => :role, :name => item.name, :children => (missing || error || skipped) ? [] : convert_run_list_trace(item.to_s, seen_items), - :missing => missing, :error => error, :skipped => skipped} + { :type => :role, :name => item.name, :children => (missing || error || skipped) ? [] : convert_run_list_trace(item.to_s, seen_items), + :missing => missing, :error => error, :skipped => skipped } end end end - end - # Expand a run list from disk. Suitable for chef-solo class RunListExpansionFromDisk < RunListExpansion - def fetch_role(name, included_by) Chef::Role.from_disk(name) rescue Chef::Exceptions::RoleNotFound role_not_found(name, included_by) end - end # Expand a run list from the chef-server API. class RunListExpansionFromAPI < RunListExpansion - def rest @rest ||= (source || Chef::ServerAPI.new(Chef::Config[:chef_server_url])) end @@ -229,10 +222,6 @@ class Chef @role_errors[name] = e.to_s raise end - end - end end - - |