diff options
author | Davin Taddeo <davin@chef.io> | 2020-09-11 12:10:18 -0400 |
---|---|---|
committer | Davin Taddeo <davin@chef.io> | 2020-09-11 12:10:18 -0400 |
commit | 1f147b43fa93d716c52a6d4c7cca07e7beedd925 (patch) | |
tree | 73cc06d3634b325e8c2698e8294aad31ca91b868 /lib | |
parent | 3c0c11fec278a8d3a4458b66ee0dddb5dc3e5786 (diff) | |
download | chef-1f147b43fa93d716c52a6d4c7cca07e7beedd925.tar.gz |
another rewrite of the validation of the privilege property.
Signed-off-by: Davin Taddeo <davin@chef.io>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/chef/resource/windows_user_privilege.rb | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/chef/resource/windows_user_privilege.rb b/lib/chef/resource/windows_user_privilege.rb index 5a9dda0a4a..142a49639b 100644 --- a/lib/chef/resource/windows_user_privilege.rb +++ b/lib/chef/resource/windows_user_privilege.rb @@ -136,7 +136,21 @@ class Chef description: "Privilege to set for users.", required: true, coerce: proc { |v| v.is_a?(String) ? Array[v] : v }, - callbacks: { "Option privilege must include any of the: #{privilege_opts}" => proc { |n| (Array(n) - privilege_opts).empty? } } + callbacks: { + "Option privilege must include any of the: #{privilege_opts}" => lambda { |n| + if n.is_a?(String) + these_options = Array[n] + else + these_options = n + end + + if (these_options - privilege_opts).empty? + true + else + false + end + }, + } load_current_value do |new_resource| if new_resource.principal && (new_resource.action.include?(:add) || new_resource.action.include?(:remove)) |