diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2016-09-14 15:44:43 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2016-09-14 15:44:43 -0700 |
commit | 3eb0d2292bdb54709b1f88bc9335b24d2269f0b8 (patch) | |
tree | 163ca27e71dd9062a0745221418c59873e325d1e | |
parent | 3faabd74883c5f5d8b311478b86e37c120ebe4d1 (diff) | |
download | chef-3eb0d2292bdb54709b1f88bc9335b24d2269f0b8.tar.gz |
revert supports[:manage_home] behavior
even though i violently disagree that this is correct behavior and we're
just going to break everyone in one massive go when we hit Chef 13.
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
-rw-r--r-- | lib/chef/provider/user/linux.rb | 18 | ||||
-rw-r--r-- | lib/chef/resource/user/linux_user.rb | 17 | ||||
-rw-r--r-- | spec/unit/provider/user/linux_spec.rb | 30 |
3 files changed, 48 insertions, 17 deletions
diff --git a/lib/chef/provider/user/linux.rb b/lib/chef/provider/user/linux.rb index f09d86e98c..4a2491d806 100644 --- a/lib/chef/provider/user/linux.rb +++ b/lib/chef/provider/user/linux.rb @@ -52,14 +52,14 @@ class Chef opts << "-s" << new_resource.shell if should_set?(:shell) opts << "-u" << new_resource.uid if should_set?(:uid) opts << "-d" << new_resource.home if updating_home? - opts << "-o" if new_resource.non_unique + opts << "-o" if non_unique opts end def usermod_options opts = [] if updating_home? - if new_resource.manage_home + if manage_home opts << "-m" end end @@ -69,7 +69,7 @@ class Chef def useradd_options opts = [] opts << "-r" if new_resource.system - if new_resource.manage_home + if manage_home opts << "-m" else opts << "-M" @@ -79,7 +79,7 @@ class Chef def userdel_options opts = [] - opts << "-r" if new_resource.manage_home + opts << "-r" if manage_home opts << "-f" if new_resource.force opts end @@ -122,6 +122,16 @@ class Chef # FIXME: should probably go on the current_resource @locked end + + def non_unique + # XXX: THIS GOES AWAY IN CHEF-13 AND BECOMES JUST new_resource.non_unique + new_resource.non_unique || new_resource.supports[:non_unique] + end + + def manage_home + # XXX: THIS GOES AWAY IN CHEF-13 AND BECOMES JUST new_resource.manage_home + new_resource.manage_home || new_resource.supports[:manage_home] + end end end end diff --git a/lib/chef/resource/user/linux_user.rb b/lib/chef/resource/user/linux_user.rb index 23d6129373..dc73671d4b 100644 --- a/lib/chef/resource/user/linux_user.rb +++ b/lib/chef/resource/user/linux_user.rb @@ -29,21 +29,24 @@ class Chef def initialize(name, run_context = nil) super @supports = { - manage_home: true, - non_unique: true, + manage_home: false, + non_unique: false, } @manage_home = false end def supports(args = {}) - Chef.log_deprecation "setting supports on the linux_user resource is deprecated" - # setting is deliberately disabled - super({}) + if args.key?(:manage_home) + Chef.log_deprecation "supports { manage_home: #{args[:manage_home]} } on the user resource is deprecated and will be removed in Chef 13, set manage_home: #{args[:manage_home]} instead" + end + if args.key?(:non_unique) + Chef.log_deprecation "supports { manage_home: #{args[:non_unique]} } on the user resource is deprecated and will be removed in Chef 13, set manage_home: #{args[:non_unique]} instead" + end + super end def supports=(args) - # setting is deliberately disabled - supports({}) + supports(args) end end end diff --git a/spec/unit/provider/user/linux_spec.rb b/spec/unit/provider/user/linux_spec.rb index ac94592859..2470b26e2c 100644 --- a/spec/unit/provider/user/linux_spec.rb +++ b/spec/unit/provider/user/linux_spec.rb @@ -45,17 +45,35 @@ describe Chef::Provider::User::Linux do @current_resource = Chef::Resource::User::LinuxUser.new("adam", @run_context) end - it "sets supports manage_home to true" do - Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect( @new_resource.supports[:manage_home] ).to be true + it "supports manage_home does not exist", chef: ">= 13" do + expect( @new_resource.supports.key?(:manage_home) ).to be false + end + + it "supports non_unique does not exist", chef: ">= 13" do + expect( @new_resource.supports.key?(:non_unique) ).to be false + end + + # supports is a method on the superclass so can't totally be removed, but we should aggressively NOP it to decisively break it + it "disables the supports API", chef: ">= 13" do + @new_resource.supports( { manage_home: true } ) + expect( @new_resource.supports.key?(:manage_home) ).to be false + end + + it "sets supports manage_home to false" do + expect( @new_resource.supports[:manage_home] ).to be false + end + + it "sets supports non-unique to false" do + expect( @new_resource.supports[:non_unique] ).to be false end - it "sets supports non-unique to true" do + it "throws a deprecation warning on setting supports[:manage_home]" do Chef::Config[:treat_deprecation_warnings_as_errors] = false - expect( @new_resource.supports[:non_unique] ).to be true + expect(Chef).to receive(:log_deprecation).with("supports { manage_home: true } on the user resource is deprecated and will be removed in Chef 13, set manage_home: true instead") + @new_resource.supports( { :manage_home => true } ) end - it "defaults manage_home to true" do + it "defaults manage_home to false" do expect( @new_resource.manage_home ).to be false end |