summaryrefslogtreecommitdiff
path: root/lib/chef/chef_class.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/chef_class.rb')
-rw-r--r--lib/chef/chef_class.rb35
1 files changed, 27 insertions, 8 deletions
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb
index d3f7ee55c7..7c0a2bf944 100644
--- a/lib/chef/chef_class.rb
+++ b/lib/chef/chef_class.rb
@@ -26,6 +26,9 @@
# injected" into this class by other objects and do not reference the class symbols in those files
# directly and we do not need to require those files here.
+require 'chef/platform/provider_priority_map'
+require 'chef/platform/resource_priority_map'
+
class Chef
class << self
@@ -48,7 +51,7 @@ class Chef
# @param resource_name [Symbol] name of the resource as a symbol
# @return [Array<Class>] Priority Array of Provider Classes to use for the resource_name on the node
def get_provider_priority_array(resource_name)
- @provider_priority_map.get_priority_array(node, resource_name).dup
+ provider_priority_map.get_priority_array(node, resource_name).dup
end
# Get the array of resources associated with a resource_name for the current node
@@ -56,27 +59,27 @@ class Chef
# @param resource_name [Symbol] name of the resource as a symbol
# @return [Array<Class>] Priority Array of Resource Classes to use for the resource_name on the node
def get_resource_priority_array(resource_name)
- @resource_priority_map.get_priority_array(node, resource_name).dup
+ resource_priority_map.get_priority_array(node, resource_name).dup
end
# Set the array of providers associated with a resource_name for the current node
#
# @param resource_name [Symbol] name of the resource as a symbol
- # @param priority_array [Array<Class>] Array of Classes to set as the priority for resource_name on the node
+ # @param priority_array [Class, Array<Class>] Class or Array of Classes to set as the priority for resource_name on the node
# @param filter [Hash] Chef::Nodearray-style filter
# @return [Array<Class>] Modified Priority Array of Provider Classes to use for the resource_name on the node
- def set_provider_priority_array(resource_name, priority_array, *filter)
- @provider_priority_map.set_priority_array(resource_name, priority_array, *filter).dup
+ def set_provider_priority_array(resource_name, priority_array, *filter, &block)
+ provider_priority_map.set_priority_array(resource_name, priority_array, *filter, &block).dup
end
# Get the array of resources associated with a resource_name for the current node
#
# @param resource_name [Symbol] name of the resource as a symbol
- # @param priority_array [Array<Class>] Array of Classes to set as the priority for resource_name on the node
+ # @param priority_array [Class, Array<Class>] Class or Array of Classes to set as the priority for resource_name on the node
# @param filter [Hash] Chef::Nodearray-style filter
# @return [Array<Class>] Modified Priority Array of Resource Classes to use for the resource_name on the node
- def set_resource_priority_array(resource_name, priority_array, *filter)
- @resource_priority_map.set_priority_array(resource_name, priority_array, *filter).dup
+ def set_resource_priority_array(resource_name, priority_array, *filter, &block)
+ resource_priority_map.set_priority_array(resource_name, priority_array, *filter, &block).dup
end
#
@@ -126,5 +129,21 @@ class Chef
@provider_priority_map = nil
@resource_priority_map = nil
end
+
+ private
+
+ def provider_priority_map
+ @provider_priority_map ||= begin
+ # these slurp in the resource+provider world, so be exceedingly lazy about requiring them
+ Chef::Platform::ProviderPriorityMap.instance
+ end
+ end
+ def resource_priority_map
+ @resource_priority_map ||= begin
+ Chef::Platform::ResourcePriorityMap.instance
+ end
+ end
end
+
+ reset!
end