summaryrefslogtreecommitdiff
path: root/lib/chef/resource_resolver.rb
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-06-05 14:01:01 -0700
committerJohn Keiser <john@johnkeiser.com>2015-06-08 09:01:55 -0700
commitc65de79dbd662d895c8a10ef496d7eb9c69376c2 (patch)
treec0d171b5e87bd103660369a7497972e695379d1b /lib/chef/resource_resolver.rb
parent01f575ce28a55dcdc7b3945c5f49ebb652a1fff3 (diff)
downloadchef-c65de79dbd662d895c8a10ef496d7eb9c69376c2.tar.gz
Overwrite resource_name with provides
Diffstat (limited to 'lib/chef/resource_resolver.rb')
-rw-r--r--lib/chef/resource_resolver.rb31
1 files changed, 23 insertions, 8 deletions
diff --git a/lib/chef/resource_resolver.rb b/lib/chef/resource_resolver.rb
index 12618d693b..22fed7e587 100644
--- a/lib/chef/resource_resolver.rb
+++ b/lib/chef/resource_resolver.rb
@@ -28,10 +28,9 @@ class Chef
attr_reader :action
attr_reader :canonical
- def initialize(node, resource, canonical: nil)
+ def initialize(node, resource)
@node = node
@resource = resource.to_sym
- @canonical = canonical
end
def resolve
@@ -49,6 +48,12 @@ class Chef
handler
end
+ def list
+ Chef::Log.debug "Resources for generic #{resource} resource enabled on node include: #{enabled_handlers}"
+ Chef::Log.debug "Resources for #{resource}: #{prioritized_handlers}"
+ prioritized_handlers
+ end
+
def provided_by?(resource_class)
!prioritized_handlers.include?(resource_class)
end
@@ -56,14 +61,24 @@ class Chef
#
# Resolve a resource by name.
#
- # @param resource_name [Symbol] The resource DSL name (e.g. `:file`)
+ # @param resource_name [Symbol] The resource DSL name (e.g. `:file`).
# @param node [Chef::Node] The node on which the resource will run. If not
# passed, will return the first match.
- # @param canonical [Boolean] Whether to restrict the search to the canonical
- # name (the one set by `resource_name`)
#
- def self.resolve(resource_name, node: Chef.node, canonical: false)
- new(node, resource_name, canonical: canonical).resolve
+ def self.resolve(resource_name, node: nil)
+ new(node, resource_name).resolve
+ end
+
+ #
+ # Resolve a list of all resources that implement the given DSL (in order of
+ # preference).
+ #
+ # @param resource_name [Symbol] The resource DSL name (e.g. `:file`).
+ # @param node [Chef::Node] The node on which the resource will run. If not
+ # passed, will return all resources (ignoring filters).
+ #
+ def self.list(resource_name, node: nil)
+ new(node, resource_name).list
end
protected
@@ -74,7 +89,7 @@ class Chef
def prioritized_handlers
@prioritized_handlers ||=
- priority_map.list_handlers(node, resource, canonical: nil)
+ priority_map.list_handlers(node, resource)
end
module Deprecated