diff options
author | John Keiser <john@johnkeiser.com> | 2015-05-28 12:28:09 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-01 08:02:05 -0700 |
commit | 305052f3dc2c4f9f705706ec478d84ee830e6fad (patch) | |
tree | a3908bd1d6e95aafe5ed337a1aa88cd29f4cc4ec | |
parent | 46e3f2258b1b04ca6030b5ef1575adadaa920e08 (diff) | |
download | chef-305052f3dc2c4f9f705706ec478d84ee830e6fad.tar.gz |
Deprecate provider_basejk/resource_name
-rw-r--r-- | lib/chef/resource.rb | 5 | ||||
-rw-r--r-- | lib/chef/resource/deploy.rb | 8 | ||||
-rw-r--r-- | spec/unit/resource_spec.rb | 21 |
3 files changed, 26 insertions, 8 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 85b1b02106..ac98df5513 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -937,7 +937,12 @@ class Chef # # ...other stuff # end # + # @deprecated Use `provides` on the provider, or `provider` on the resource, instead. + # def provider_base(arg=nil) + if arg + Chef::Log.deprecation("Resource.provider_base is deprecated and will be removed in Chef 13. Use provides on the provider, or provider on the resource, instead.") + end @provider_base ||= arg || Chef::Provider end end diff --git a/lib/chef/resource/deploy.rb b/lib/chef/resource/deploy.rb index 014e690e65..8d007df348 100644 --- a/lib/chef/resource/deploy.rb +++ b/lib/chef/resource/deploy.rb @@ -52,8 +52,6 @@ class Chef class Deploy < Chef::Resource use_automatic_resource_name - provider_base Chef::Provider::Deploy - identity_attr :repository state_attrs :deploy_to, :revision @@ -281,6 +279,12 @@ class Chef ) end + # This is to support "provider :revision" without deprecation warnings. + # Do NOT copy this. + def self.provider_base + Chef::Provider::Deploy + end + def svn_force_export(arg=nil) set_or_return( :svn_force_export, diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index bc5567b73a..fefe78fbda 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -21,10 +21,6 @@ require 'spec_helper' -class ResourceTestHarness < Chef::Resource - provider_base Chef::Provider::Package -end - describe Chef::Resource do before(:each) do @cookbook_repo_path = File.join(CHEF_SPEC_DATA, 'cookbooks') @@ -538,8 +534,21 @@ describe Chef::Resource do expect(Chef::Resource.provider_base).to eq(Chef::Provider) end - it "allows the base provider to be overriden by a " do - expect(ResourceTestHarness.provider_base).to eq(Chef::Provider::Package) + it "allows the base provider to be overridden" do + Chef::Config.treat_deprecation_warnings_as_errors(false) + class OverrideProviderBaseTest < Chef::Resource + provider_base Chef::Provider::Package + end + + expect(OverrideProviderBaseTest.provider_base).to eq(Chef::Provider::Package) + end + + it "warns when setting provider_base" do + expect { + class OverrideProviderBaseTest2 < Chef::Resource + provider_base Chef::Provider::Package + end + }.to raise_error(Chef::Exceptions::DeprecatedFeatureError) end end |