diff options
author | Tim Smith <tsmith84@gmail.com> | 2020-07-20 16:58:15 -0700 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2020-07-20 16:58:15 -0700 |
commit | 9899f2e1232fcc0fa23a3e31e313193407cd5ee9 (patch) | |
tree | 29e0d5d5a2176fce24d41cb19b75cd02f5d1339b /lib/chef/resource/macos_userdefaults.rb | |
parent | 0e7c7ed5afa78dfb428780f5c4e5fdbf9c40ea90 (diff) | |
download | chef-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>
Diffstat (limited to 'lib/chef/resource/macos_userdefaults.rb')
-rw-r--r-- | lib/chef/resource/macos_userdefaults.rb | 6 |
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 # |