summaryrefslogtreecommitdiff
path: root/lib/chef/dsl
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2018-04-12 18:01:38 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2018-04-12 18:01:38 -0700
commitdd93333a3fc0851a0b63ec5bf63f67ce82ea4a21 (patch)
treef98a02afa5b7ae362f4bc67f471a5315d7ede5fa /lib/chef/dsl
parent84657b2e7ef92ac81d98e265db4305dfb6b5aab3 (diff)
downloadchef-dd93333a3fc0851a0b63ec5bf63f67ce82ea4a21.tar.gz
add the resources() dsl method to providerslcg/fix-resources-dsl-method
Custom resource actions were picking this up via delegation to the wrapping resource, and that wiring was removed in 14, so that API then got dropped accidentally. This should fix that back up. It also consistently injects the resource APIs into resources and providers both now (and consistently across core resources and custom resources). Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/dsl')
-rw-r--r--lib/chef/dsl/declare_resource.rb24
1 files changed, 23 insertions, 1 deletions
diff --git a/lib/chef/dsl/declare_resource.rb b/lib/chef/dsl/declare_resource.rb
index 0d727b4861..dc95489d52 100644
--- a/lib/chef/dsl/declare_resource.rb
+++ b/lib/chef/dsl/declare_resource.rb
@@ -1,7 +1,7 @@
#--
# Author:: Adam Jacob (<adam@chef.io>)
# Author:: Christopher Walters
-# Copyright:: Copyright 2008-2017, Chef Software Inc.
+# Copyright:: Copyright 2008-2018, Chef Software Inc.
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -166,6 +166,27 @@ class Chef
resource
end
+ # Find existing resources by searching the list of existing resources. Possible
+ # forms are:
+ #
+ # find(:file => "foobar")
+ # find(:file => [ "foobar", "baz" ])
+ # find("file[foobar]", "file[baz]")
+ # find("file[foobar,baz]")
+ #
+ # Calls `run_context.resource_collection.find(*args)`
+ #
+ # The is backcompat API, the use of find_resource, below, is encouraged.
+ #
+ # @return the matching resource, or an Array of matching resources.
+ #
+ # @raise ArgumentError if you feed it bad lookup information
+ # @raise RuntimeError if it can't find the resources you are looking for.
+ #
+ def resources(*args)
+ run_context.resource_collection.find(*args)
+ end
+
# Lookup a resource in the resource collection by name. If the resource is not
# found this will raise Chef::Exceptions::ResourceNotFound. This API is identical to the
# resources() call and while it is a synonym it is not intended to deprecate that call.
@@ -292,6 +313,7 @@ class Chef
enclosing_provider: is_a?(Chef::Provider) ? self : nil
).build(&resource_attrs_block)
end
+
end
end
end