diff options
author | John Keiser <john@johnkeiser.com> | 2015-05-06 07:59:33 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-02 09:53:39 -0700 |
commit | 9028823f7b046c4c081b1cb1df005d61fbfa1db2 (patch) | |
tree | 74d1fa52adb202a6841148be3b82638a578b1b4e /lib/chef/chef_class.rb | |
parent | 93f7b74349362d0c698a1080177b94e64248dac6 (diff) | |
download | chef-9028823f7b046c4c081b1cb1df005d61fbfa1db2.tar.gz |
Use the central priority map for `provides`
Diffstat (limited to 'lib/chef/chef_class.rb')
-rw-r--r-- | lib/chef/chef_class.rb | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/lib/chef/chef_class.rb b/lib/chef/chef_class.rb index d3f7ee55c7..96c0899d5d 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 + provider_priority_map.set_priority_array(resource_name, priority_array, *filter).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 + resource_priority_map.set_priority_array(resource_name, priority_array, *filter).dup end # @@ -126,5 +129,23 @@ 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 + require 'chef/platform/provider_priority_map' + Chef::Platform::ProviderPriorityMap.instance + end + end + def resource_priority_map + @resource_priority_map ||= begin + require 'chef/platform/resource_priority_map' + Chef::Platform::ResourcePriorityMap.instance + end + end end + + reset! end |