diff options
author | rishichawda <rishichawda@users.noreply.github.com> | 2021-08-09 22:06:00 +0530 |
---|---|---|
committer | rishichawda <rishichawda@users.noreply.github.com> | 2021-09-24 16:44:13 +0530 |
commit | 9bf47c78929d7fefb790356938440554d85c3d93 (patch) | |
tree | 200880568b187bb3bbe29c28c3a38fc745fb002e | |
parent | f1763c759c2a3378f21a2dee6063b5ae6efed193 (diff) | |
download | chef-9bf47c78929d7fefb790356938440554d85c3d93.tar.gz |
refactor(macos_userdefaults): remove valid key check
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
-rw-r--r-- | lib/chef/resource/macos_userdefaults.rb | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/lib/chef/resource/macos_userdefaults.rb b/lib/chef/resource/macos_userdefaults.rb index d23d384a24..b30ee2f5a0 100644 --- a/lib/chef/resource/macos_userdefaults.rb +++ b/lib/chef/resource/macos_userdefaults.rb @@ -105,13 +105,11 @@ class Chef load_current_value do |new_resource| Chef::Log.debug "#load_current_value: attempting to read \"#{new_resource.domain}\" value from preferences to determine state" - if valid_key?(new_resource) - key new_resource.key - else - current_value_does_not_exist! - end + pref = get_preference(new_resource) + current_value_does_not_exist! if pref.nil? - value get_preference(new_resource) + key new_resource.key + value pref end action :write, description: "Write the value to the specified domain/key." do @@ -123,7 +121,7 @@ class Chef action :delete, description: "Delete a key from a domain." do # if it's not there there's nothing to remove - return if current_resource.value.nil? + return if current_resource.nil? converge_by("delete domain:#{new_resource.domain} key:#{new_resource.key}") do Chef::Log.debug("Removing defaults key: #{new_resource.key}") @@ -168,13 +166,6 @@ class Chef value end end - - def valid_key?(new_resource) - user = to_cf_user new_resource.user - host = to_cf_host new_resource.host - CF::Preferences.valid_key?(new_resource.key, new_resource.domain, user, host) - end - end end end |