summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-07-20 16:58:15 -0700
committerTim Smith <tsmith84@gmail.com>2020-07-20 16:58:15 -0700
commit9899f2e1232fcc0fa23a3e31e313193407cd5ee9 (patch)
tree29e0d5d5a2176fce24d41cb19b75cd02f5d1339b
parent0e7c7ed5afa78dfb428780f5c4e5fdbf9c40ea90 (diff)
downloadchef-9899f2e1232fcc0fa23a3e31e313193407cd5ee9.tar.gz
Prevent failures when the key doesn't exist
Setting it to nil was throwing a required value error from the property validation Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/macos_userdefaults.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/chef/resource/macos_userdefaults.rb b/lib/chef/resource/macos_userdefaults.rb
index 1bf05194b8..15a0f17a39 100644
--- a/lib/chef/resource/macos_userdefaults.rb
+++ b/lib/chef/resource/macos_userdefaults.rb
@@ -114,7 +114,11 @@ class Chef
current_value_does_not_exist!
end
- value ::Plist.parse_xml(state.stdout)[key]
+ plist_data = ::Plist.parse_xml(state.stdout)
+
+ current_value_does_not_exist! unless current_value_does_not_exist!.key?(key)
+
+ value plist_data[key]
end
#