diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-20 12:36:33 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-29 12:48:24 -0700 |
commit | 6f11e1c36caba0b56ed304746551868c0ff1a546 (patch) | |
tree | fe55b9af9dd8d372c321d7e1c4a43a7fcc24ea44 | |
parent | 6681797f2154b5a3ded6ee9c91568428bc3c0dab (diff) | |
download | chef-6f11e1c36caba0b56ed304746551868c0ff1a546.tar.gz |
Chef-13: remove more deprecated provider_resolver code
I think this nukes descendants tracker, although might need to clean it
up in a few more spots.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/provider_resolver.rb | 26 | ||||
-rw-r--r-- | lib/chef/resource_resolver.rb | 21 | ||||
-rw-r--r-- | spec/integration/recipes/recipe_dsl_spec.rb | 75 |
3 files changed, 1 insertions, 121 deletions
diff --git a/lib/chef/provider_resolver.rb b/lib/chef/provider_resolver.rb index 16e57b00b8..dacdb2b54f 100644 --- a/lib/chef/provider_resolver.rb +++ b/lib/chef/provider_resolver.rb @@ -142,31 +142,5 @@ 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 fca6c6db81..10b8c0f22e 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-2016, Chef Software, Inc. +# Copyright:: Copyright 2015-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -161,24 +161,5 @@ 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 diff --git a/spec/integration/recipes/recipe_dsl_spec.rb b/spec/integration/recipes/recipe_dsl_spec.rb index 32283393ce..a408bbb0d7 100644 --- a/spec/integration/recipes/recipe_dsl_spec.rb +++ b/spec/integration/recipes/recipe_dsl_spec.rb @@ -1295,81 +1295,6 @@ describe "Recipe DSL methods" do end end end - - context "with provides? returning true" do - before do - temp_my_resource = my_resource - provider_class.define_singleton_method(:provides?) do |node, resource| - @called_provides = true - resource.declared_type == temp_my_resource - end - end - - context "that provides :my_resource" do - before do - provider_class.provides my_resource - end - - it "my_resource calls the provider (and calls provides?), but does not emit a warning" do - temp_my_resource = my_resource - recipe = converge do - instance_eval("#{temp_my_resource} 'foo'") - end - expect(recipe.logged_warnings).to eq "" - expect(BaseThingy.created_provider).to eq provider_class - expect(provider_class.called_provides).to be_truthy - end - end - - context "that does not call provides :my_resource" do - it "my_resource calls the provider (and calls provides?), and emits a warning" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - temp_my_resource = my_resource - recipe = converge do - instance_eval("#{temp_my_resource} 'foo'") - end - expect(recipe.logged_warnings).to include("WARN: #{provider_class}.provides? returned true when asked if it provides DSL #{my_resource}, but provides :#{my_resource} was never called!") - expect(BaseThingy.created_provider).to eq provider_class - expect(provider_class.called_provides).to be_truthy - end - end - end - - context "with provides? returning false to my_resource" do - before do - temp_my_resource = my_resource - provider_class.define_singleton_method(:provides?) do |node, resource| - @called_provides = true - false - end - end - - context "that provides :my_resource" do - before do - provider_class.provides my_resource - end - - it "my_resource fails to find a provider (and calls provides)" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - temp_my_resource = my_resource - expect_converge do - instance_eval("#{temp_my_resource} 'foo'") - end.to raise_error(Chef::Exceptions::ProviderNotFound) - expect(provider_class.called_provides).to be_truthy - end - end - - context "that does not provide :my_resource" do - it "my_resource fails to find a provider (and calls provides)" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - temp_my_resource = my_resource - expect_converge do - instance_eval("#{temp_my_resource} 'foo'") - end.to raise_error(Chef::Exceptions::ProviderNotFound) - expect(provider_class.called_provides).to be_truthy - end - end - end end end end |