diff options
author | Davin Taddeo <davin@chef.io> | 2020-09-11 12:10:18 -0400 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-09-11 17:15:46 -0700 |
commit | 8b5e660461118a81802fbe7d93b4939b8092b381 (patch) | |
tree | 94993e596ccac8d745c18385097bb1cf8b21d47f | |
parent | 0d75ac5bf0c02ff48f7fe253a3e5a1fc0ca04a0d (diff) | |
download | chef-8b5e660461118a81802fbe7d93b4939b8092b381.tar.gz |
another rewrite of the validation of the privilege property.
Signed-off-by: Davin Taddeo <davin@chef.io>
-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)) |