summaryrefslogtreecommitdiff
path: root/lib/chef/resource.rb
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-01-12 15:13:40 -0800
committerLamont Granquist <lamont@scriptkiddie.org>2015-01-12 15:13:59 -0800
commit5a2f19a85fbee9f4517aa471378e40cf32d030e0 (patch)
tree6c1824aee7a5f9de882e1e8096d9b6c7e050b663 /lib/chef/resource.rb
parent153764d26ed639dfd58945fdc5c4cc5ae51ef5e2 (diff)
downloadchef-5a2f19a85fbee9f4517aa471378e40cf32d030e0.tar.gz
Skip 3694 warnings on trivial resource cloning
Turns the 3694 warning into a debug message if the prior resource is identical to the current resource. Suggestion for opscode/chef-rfc#76 This also moves resource building out to its own class.
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r--lib/chef/resource.rb20
1 files changed, 4 insertions, 16 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 17f109242f..bf49cd9d26 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -213,23 +213,11 @@ class Chef
end
end
- def load_prior_resource(resource_type, instance_name)
- begin
- key = "#{resource_type}[#{instance_name}]"
- prior_resource = run_context.resource_collection.lookup(key)
- # if we get here, there is a prior resource (otherwise we'd have jumped
- # to the rescue clause).
- Chef::Log.warn("Cloning resource attributes for #{key} from prior resource (CHEF-3694)")
- Chef::Log.warn("Previous #{prior_resource}: #{prior_resource.source_line}") if prior_resource.source_line
- Chef::Log.warn("Current #{self}: #{self.source_line}") if self.source_line
- prior_resource.instance_variables.each do |iv|
- unless iv.to_sym == :@source_line || iv.to_sym == :@action || iv.to_sym == :@not_if || iv.to_sym == :@only_if
- self.instance_variable_set(iv, prior_resource.instance_variable_get(iv))
- end
+ def load_from(resource)
+ resource.instance_variables.each do |iv|
+ unless iv == :@source_line || iv == :@action || iv == :@not_if || iv == :@only_if
+ self.instance_variable_set(iv, resource.instance_variable_get(iv))
end
- true
- rescue Chef::Exceptions::ResourceNotFound
- true
end
end