diff options
-rw-r--r-- | lib/chef/resource.rb | 24 | ||||
-rw-r--r-- | lib/chef/resource/mount.rb | 16 | ||||
-rw-r--r-- | lib/chef/resource/service.rb | 16 | ||||
-rw-r--r-- | lib/chef/resource/user.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/user/linux_spec.rb | 4 | ||||
-rw-r--r-- | spec/unit/resource/mount_spec.rb | 14 | ||||
-rw-r--r-- | spec/unit/resource/service_spec.rb | 9 | ||||
-rw-r--r-- | spec/unit/resource_spec.rb | 20 |
8 files changed, 14 insertions, 93 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 40911cd2cc..f9fb5926aa 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -138,7 +138,6 @@ class Chef @action = self.class.default_action @updated = false @updated_by_last_action = false - @supports = {} @ignore_failure = false @retries = 0 @retry_delay = 2 @@ -955,29 +954,6 @@ class Chef end # - # Sets a list of capabilities of the real resource. For example, `:remount` - # (for filesystems) and `:restart` (for services). - # - # TODO Calling resource.supports({}) will not set this to empty; it will do - # a get instead. That's wrong. - # - # @param args Hash{Symbol=>Boolean} If non-empty, sets the capabilities of - # this resource. Default: {} - # @return Hash{Symbol=>Boolean} An array of things this resource supports. - # - def supports(args = {}) - if args.any? - @supports = args - else - @supports - end - end - - def supports=(args) - supports(args) - end - - # # A hook called after a resource is created. Meant to be overriden by # subclasses. # diff --git a/lib/chef/resource/mount.rb b/lib/chef/resource/mount.rb index 3e35325246..32ffee931b 100644 --- a/lib/chef/resource/mount.rb +++ b/lib/chef/resource/mount.rb @@ -1,7 +1,7 @@ # # Author:: Joshua Timberman (<joshua@chef.io>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2009-2016, Chef Software Inc. +# Copyright:: Copyright 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,6 +30,9 @@ class Chef default_action :mount allowed_actions :mount, :umount, :unmount, :remount, :enable, :disable + # this is a poor API please do not re-use this pattern + property :supports, Hash, default: { remount: false } + def initialize(name, run_context = nil) super @mount_point = name @@ -42,7 +45,6 @@ class Chef @pass = 2 @mounted = false @enabled = false - @supports = { :remount => false } @username = nil @password = nil @domain = nil @@ -140,16 +142,6 @@ class Chef ) end - def supports(args = {}) - if args.is_a? Array - args.each { |arg| @supports[arg] = true } - elsif args.any? - @supports = args - else - @supports - end - end - def username(arg = nil) set_or_return( :username, diff --git a/lib/chef/resource/service.rb b/lib/chef/resource/service.rb index 1ca4b84af0..77c99fbdc6 100644 --- a/lib/chef/resource/service.rb +++ b/lib/chef/resource/service.rb @@ -1,7 +1,7 @@ # # Author:: AJ Christensen (<aj@hjksolutions.com>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -30,6 +30,8 @@ class Chef allowed_actions :enable, :disable, :start, :stop, :restart, :reload, :mask, :unmask + property :supports, Hash, default: { restart: nil, reload: nil, status: nil } + def initialize(name, run_context = nil) super @service_name = name @@ -48,7 +50,6 @@ class Chef @timeout = nil @run_levels = nil @user = nil - @supports = { :restart => nil, :reload => nil, :status => nil } end def service_name(arg = nil) @@ -201,17 +202,6 @@ class Chef :kind_of => [ String ] ) end - - def supports(args = {}) - if args.is_a? Array - args.each { |arg| @supports[arg] = true } - elsif args.any? - @supports = args - else - @supports - end - end - end end end diff --git a/lib/chef/resource/user.rb b/lib/chef/resource/user.rb index 288335a599..a1e315ef50 100644 --- a/lib/chef/resource/user.rb +++ b/lib/chef/resource/user.rb @@ -151,10 +151,6 @@ class Chef :kind_of => [ TrueClass, FalseClass ] ) end - - def supports(args = {}) - raise Chef::Exceptions::User, "calling supports on a user resource is no longer supported in Chef-13, you probably need to use the manage_home or non_unique properties directly" - end end end end diff --git a/spec/unit/provider/user/linux_spec.rb b/spec/unit/provider/user/linux_spec.rb index 063ca934c3..5092c8f4b9 100644 --- a/spec/unit/provider/user/linux_spec.rb +++ b/spec/unit/provider/user/linux_spec.rb @@ -46,11 +46,11 @@ describe Chef::Provider::User::Linux do end it "throws an error when trying to set supports manage_home: true" do - expect { @new_resource.supports( manage_home: true ) }.to raise_error(Chef::Exceptions::User) + expect { @new_resource.supports( manage_home: true ) }.to raise_error(NoMethodError) end it "throws an error when trying to set supports non_unique: true" do - expect { @new_resource.supports( non_unique: true ) }.to raise_error(Chef::Exceptions::User) + expect { @new_resource.supports( non_unique: true ) }.to raise_error(NoMethodError) end it "defaults manage_home to false" do diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index 832f7644ac..50e706cfd5 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -1,7 +1,7 @@ # # Author:: Joshua Timberman (<joshua@chef.io>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2009-2016, Chef Software Inc. +# Copyright:: Copyright 2009-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -87,11 +87,6 @@ describe Chef::Resource::Mount do expect(@resource.options).to be_a_kind_of(Array) end - it "should allow options attribute as an array" do - @resource.options %w{ro nosuid} - expect(@resource.options).to be_a_kind_of(Array) - end - it "should allow options to be sent as a delayed evaluator" do @resource.options Chef::DelayedEvaluator.new { %w{rw noexec} } expect(@resource.options).to eql(%w{rw noexec}) @@ -144,13 +139,6 @@ describe Chef::Resource::Mount do expect(@resource.supports).to eq(support_hash) end - it "should allow you to set feature support as an array" do - support_array = [ :remount ] - support_hash = { :remount => true } - @resource.supports(support_array) - expect(@resource.supports).to eq(support_hash) - end - it "should allow you to set feature support as a hash" do support_hash = { :remount => true } @resource.supports(support_hash) diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb index 7aadc55532..fd38fb2faf 100644 --- a/spec/unit/resource/service_spec.rb +++ b/spec/unit/resource/service_spec.rb @@ -1,7 +1,7 @@ # # Author:: AJ Christensen (<aj@hjksolutions.com>) # Author:: Tyler Cloke (<tyler@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -144,13 +144,6 @@ describe Chef::Resource::Service do expect(@resource.supports).to eq(support_hash) end - it "should allow you to set what features this resource supports as a array" do - support_array = [ :status, :restart ] - support_hash = { :status => true, :restart => true, :reload => nil } - @resource.supports(support_array) - expect(@resource.supports).to eq(support_hash) - end - it "should allow you to set what features this resource supports as a hash" do support_hash = { :status => true, :restart => true, :reload => false } @resource.supports(support_hash) diff --git a/spec/unit/resource_spec.rb b/spec/unit/resource_spec.rb index 2f75ba0241..0f8540b855 100644 --- a/spec/unit/resource_spec.rb +++ b/spec/unit/resource_spec.rb @@ -3,7 +3,7 @@ # Author:: Christopher Walters (<cw@chef.io>) # Author:: Tim Hinderliter (<tim@chef.io>) # Author:: Seth Chisamore (<schisamo@chef.io>) -# Copyright:: Copyright 2008-2016, Chef Software Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -192,7 +192,6 @@ describe Chef::Resource do describe "load_from" do let(:prior_resource) do prior_resource = Chef::Resource.new("funk") - prior_resource.supports(:funky => true) prior_resource.source_line prior_resource.allowed_actions << :funkytown prior_resource.action(:funkytown) @@ -205,7 +204,6 @@ describe Chef::Resource do it "should load the attributes of a prior resource" do resource.load_from(prior_resource) - expect(resource.supports).to eq({ :funky => true }) end it "should not inherit the action from the prior resource" do @@ -481,7 +479,7 @@ describe Chef::Resource do let(:resource_class) { Class.new(Chef::Resource) { property :a, default: 1 } } it "should include the default in the hash" do expect(resource.to_hash.keys.sort).to eq([:a, :allowed_actions, :params, :provider, :updated, - :updated_by_last_action, :before, :supports, + :updated_by_last_action, :before, :noop, :ignore_failure, :name, :source_line, :action, :retries, :retry_delay, :elapsed_time, :default_guard_interpreter, :guard_interpreter, :sensitive].sort) @@ -493,7 +491,7 @@ describe Chef::Resource do it "should convert to a hash" do hash = resource.to_hash expected_keys = [ :allowed_actions, :params, :provider, :updated, - :updated_by_last_action, :before, :supports, + :updated_by_last_action, :before, :noop, :ignore_failure, :name, :source_line, :action, :retries, :retry_delay, :elapsed_time, :default_guard_interpreter, :guard_interpreter, :sensitive ] @@ -512,18 +510,6 @@ describe Chef::Resource do end end - describe "supports" do - it "should allow you to set what features this resource supports" do - support_hash = { :one => :two } - resource.supports(support_hash) - expect(resource.supports).to eql(support_hash) - end - - it "should return the current value of supports" do - expect(resource.supports).to eq({}) - end - end - describe "ignore_failure" do it "should default to throwing an error if a provider fails for a resource" do expect(resource.ignore_failure).to eq(false) |