diff options
author | sersut <serdar@opscode.com> | 2014-07-01 13:03:25 -0700 |
---|---|---|
committer | sersut <serdar@opscode.com> | 2014-07-02 11:41:27 -0700 |
commit | b605fdfc8bd67fe9db0b1057d481a8bc9b937bdc (patch) | |
tree | b75162be45940670302849fa84b5a9d06fa55ecc | |
parent | d59714c9b45d0c7cb1c5d85164f218a682433a75 (diff) | |
download | chef-sersut/chef-1580-11-stable.tar.gz |
Revert the provider indirection logic while keeping the timeout functionality to fix resource notifications and ChefSpec stubs.sersut/chef-1580-11-stable
-rw-r--r-- | lib/chef/platform/provider_mapping.rb | 6 | ||||
-rw-r--r-- | lib/chef/provider/package/apt.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource/apt_package.rb | 11 | ||||
-rw-r--r-- | lib/chef/resource/package.rb | 18 | ||||
-rw-r--r-- | spec/unit/provider/package/apt_spec.rb | 6 | ||||
-rw-r--r-- | spec/unit/resource/apt_package_spec.rb | 8 | ||||
-rw-r--r-- | spec/unit/resource/package_spec.rb | 44 |
7 files changed, 51 insertions, 46 deletions
diff --git a/lib/chef/platform/provider_mapping.rb b/lib/chef/platform/provider_mapping.rb index b7918a84af..ebcc8c2fe3 100644 --- a/lib/chef/platform/provider_mapping.rb +++ b/lib/chef/platform/provider_mapping.rb @@ -64,6 +64,7 @@ class Chef }, :ubuntu => { :default => { + :package => Chef::Provider::Package::Apt, :service => Chef::Provider::Service::Debian, :cron => Chef::Provider::Cron, :mdadm => Chef::Provider::Mdadm @@ -79,6 +80,7 @@ class Chef }, :gcel => { :default => { + :package => Chef::Provider::Package::Apt, :service => Chef::Provider::Service::Debian, :cron => Chef::Provider::Cron, :mdadm => Chef::Provider::Mdadm @@ -86,6 +88,7 @@ class Chef }, :linaro => { :default => { + :package => Chef::Provider::Package::Apt, :service => Chef::Provider::Service::Debian, :cron => Chef::Provider::Cron, :mdadm => Chef::Provider::Mdadm @@ -93,6 +96,7 @@ class Chef }, :raspbian => { :default => { + :package => Chef::Provider::Package::Apt, :service => Chef::Provider::Service::Debian, :cron => Chef::Provider::Cron, :mdadm => Chef::Provider::Mdadm @@ -100,6 +104,7 @@ class Chef }, :linuxmint => { :default => { + :package => Chef::Provider::Package::Apt, :service => Chef::Provider::Service::Upstart, :cron => Chef::Provider::Cron, :mdadm => Chef::Provider::Mdadm @@ -107,6 +112,7 @@ class Chef }, :debian => { :default => { + :package => Chef::Provider::Package::Apt, :service => Chef::Provider::Service::Debian, :cron => Chef::Provider::Cron, :mdadm => Chef::Provider::Mdadm diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb index 06d86aa44c..76d90a5a97 100644 --- a/lib/chef/provider/package/apt.rb +++ b/lib/chef/provider/package/apt.rb @@ -18,7 +18,7 @@ require 'chef/provider/package' require 'chef/mixin/command' -require 'chef/resource/apt_package' +require 'chef/resource/package' require 'chef/mixin/shell_out' @@ -31,7 +31,7 @@ class Chef attr_accessor :is_virtual_package def load_current_resource - @current_resource = Chef::Resource::AptPackage.new(@new_resource.name) + @current_resource = Chef::Resource::Package.new(@new_resource.name) @current_resource.package_name(@new_resource.package_name) check_package_state(@new_resource.package_name) @current_resource diff --git a/lib/chef/resource/apt_package.rb b/lib/chef/resource/apt_package.rb index 0b91b0cdbf..050cf838ae 100644 --- a/lib/chef/resource/apt_package.rb +++ b/lib/chef/resource/apt_package.rb @@ -23,22 +23,11 @@ class Chef class Resource class AptPackage < Chef::Resource::Package - provides :package, :on_platforms => ["ubuntu", "gcel", "linaro", "raspbian", "linuxmint", "debian"] - def initialize(name, run_context=nil) super @resource_name = :apt_package @provider = Chef::Provider::Package::Apt @default_release = nil - @timeout = 900 - end - - def timeout(arg=nil) - set_or_return( - :timeout, - arg, - :kind_of => [String, Integer] - ) end def default_release(arg=nil) diff --git a/lib/chef/resource/package.rb b/lib/chef/resource/package.rb index f9fdd1ab59..772439b06c 100644 --- a/lib/chef/resource/package.rb +++ b/lib/chef/resource/package.rb @@ -39,6 +39,7 @@ class Chef @response_file_variables = Hash.new @source = nil @version = nil + @timeout = 900 end def package_name(arg=nil) @@ -83,11 +84,20 @@ class Chef def options(arg=nil) set_or_return( - :options, - arg, - :kind_of => [ String ] - ) + :options, + arg, + :kind_of => [ String ] + ) end + + def timeout(arg=nil) + set_or_return( + :timeout, + arg, + :kind_of => [String, Integer] + ) + end + end end end diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index 245cd3aff8..a94b248418 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -24,7 +24,7 @@ describe Chef::Provider::Package::Apt do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - @new_resource = Chef::Resource::AptPackage.new("irssi", @run_context) + @new_resource = Chef::Resource::Package.new("irssi", @run_context) @status = double("Status", :exitstatus => 0) @provider = Chef::Provider::Package::Apt.new(@new_resource, @run_context) @@ -52,7 +52,7 @@ PKG_STATUS @provider.load_current_resource current_resource = @provider.current_resource - current_resource.should be_a(Chef::Resource::AptPackage) + current_resource.should be_a(Chef::Resource::Package) current_resource.name.should == "irssi" current_resource.package_name.should == "irssi" current_resource.version.should be_nil @@ -201,7 +201,7 @@ SHOWPKG_STDOUT context "after loading the current resource" do before do - @current_resource = Chef::Resource::AptPackage.new("irssi", @run_context) + @current_resource = Chef::Resource::Package.new("irssi", @run_context) @provider.current_resource = @current_resource end diff --git a/spec/unit/resource/apt_package_spec.rb b/spec/unit/resource/apt_package_spec.rb index 81df04c59f..58b007c327 100644 --- a/spec/unit/resource/apt_package_spec.rb +++ b/spec/unit/resource/apt_package_spec.rb @@ -40,12 +40,4 @@ describe Chef::Resource::AptPackage, "initialize" do @resource.default_release("lenny-backports") @resource.default_release.should eql("lenny-backports") end - - # String, Integer - [ "600", 600 ].each do |val| - it "supports setting a timeout as a #{val.class}" do - @resource.timeout(val) - expect(@resource.timeout).to eql(val) - end - end end diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb index 2884c94393..8a1a13394e 100644 --- a/spec/unit/resource/package_spec.rb +++ b/spec/unit/resource/package_spec.rb @@ -64,22 +64,30 @@ describe Chef::Resource::Package do @resource.options.should eql("something") end - describe "when it has a package_name and version" do - before do - @resource.package_name("tomcat") - @resource.version("10.9.8") - @resource.options("-al") - end - - it "describes its state" do - state = @resource.state - state[:version].should == "10.9.8" - state[:options].should == "-al" - end - - it "returns the file path as its identity" do - @resource.identity.should == "tomcat" - end - - end + describe "when it has a package_name and version" do + before do + @resource.package_name("tomcat") + @resource.version("10.9.8") + @resource.options("-al") + end + + it "describes its state" do + state = @resource.state + state[:version].should == "10.9.8" + state[:options].should == "-al" + end + + it "returns the file path as its identity" do + @resource.identity.should == "tomcat" + end + end + + # String, Integer + [ "600", 600 ].each do |val| + it "supports setting a timeout as a #{val.class}" do + @resource.timeout(val) + expect(@resource.timeout).to eql(val) + end + end + end |