diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-20 12:38:22 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-20 12:38:22 -0700 |
commit | 62f18e4d6db732e3d86991f08815c4e091a9dd27 (patch) | |
tree | 29e102efa1ed05f9b9527f92ccc4620546180fe8 /lib | |
parent | 02ec917f9356d999c44aceb7f1ff43957b0fe832 (diff) | |
download | chef-62f18e4d6db732e3d86991f08815c4e091a9dd27.tar.gz |
Revert "Chef-13: remove more deprecated provider_resolver code"
forgot to branch and need more coffee
This reverts commit 02ec917f9356d999c44aceb7f1ff43957b0fe832.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/provider_resolver.rb | 26 | ||||
-rw-r--r-- | lib/chef/resource_resolver.rb | 21 |
2 files changed, 46 insertions, 1 deletions
diff --git a/lib/chef/provider_resolver.rb b/lib/chef/provider_resolver.rb index 465f88606b..439a7e9f5f 100644 --- a/lib/chef/provider_resolver.rb +++ b/lib/chef/provider_resolver.rb @@ -137,5 +137,31 @@ class Chef def overrode_provides?(handler) handler.method(:provides?).owner != Chef::Provider.method(:provides?).owner end + + module Deprecated + # return a deterministically sorted list of Chef::Provider subclasses + def providers + @providers ||= Chef::Provider.descendants + end + + def enabled_handlers + @enabled_handlers ||= begin + handlers = super + if handlers.empty? + # Look through all providers, and find ones that return true to provides. + # Don't bother with ones that don't override provides?, since they + # would have been in enabled_handlers already if that were so. (It's a + # perf concern otherwise.) + handlers = providers.select { |handler| overrode_provides?(handler) && handler.provides?(node, resource) } + handlers.each do |handler| + message = "#{handler}.provides? returned true when asked if it provides DSL #{resource.resource_name}, but provides #{resource.resource_name.inspect} was never called! In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself." + Chef.deprecated(:custom_resource, message) + end + end + handlers + end + end + end + prepend Deprecated end end diff --git a/lib/chef/resource_resolver.rb b/lib/chef/resource_resolver.rb index 10b8c0f22e..fca6c6db81 100644 --- a/lib/chef/resource_resolver.rb +++ b/lib/chef/resource_resolver.rb @@ -1,6 +1,6 @@ # # Author:: Lamont Granquist (<lamont@chef.io>) -# Copyright:: Copyright 2015-2017, Chef Software Inc. +# Copyright:: Copyright 2015-2016, Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -161,5 +161,24 @@ class Chef def overrode_provides?(handler) handler.method(:provides?).owner != Chef::Resource.method(:provides?).owner end + + module Deprecated + # return a deterministically sorted list of Chef::Resource subclasses + def resources + Chef::Resource.sorted_descendants + end + + def enabled_handlers + handlers = super + if handlers.empty? + handlers = resources.select { |handler| overrode_provides?(handler) && handler.provides?(node, resource_name) } + handlers.each do |handler| + Chef.deprecated(:custom_resource, "#{handler}.provides? returned true when asked if it provides DSL #{resource_name}, but provides #{resource_name.inspect} was never called! In Chef 13, this will break: you must call provides to mark the names you provide, even if you also override provides? yourself.") + end + end + handlers + end + end + prepend Deprecated end end |