diff options
author | rishichawda <rishichawda@users.noreply.github.com> | 2021-11-08 15:49:26 +0530 |
---|---|---|
committer | rishichawda <rishichawda@users.noreply.github.com> | 2021-11-11 23:23:43 +0530 |
commit | 64f64ccc3fe4e4e30b8e6ba6dc9b46a6ae1c21d4 (patch) | |
tree | 87faaebe46414010f2a939f10836de38d3b35b12 | |
parent | ade944d8fe6c554a34c362a0a22ebf5e95e105c6 (diff) | |
download | chef-64f64ccc3fe4e4e30b8e6ba6dc9b46a6ae1c21d4.tar.gz |
remove coerce, transform as needed
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
-rw-r--r-- | lib/chef/resource/macos_userdefaults.rb | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/chef/resource/macos_userdefaults.rb b/lib/chef/resource/macos_userdefaults.rb index b0b9c32fe0..0ac35d90b1 100644 --- a/lib/chef/resource/macos_userdefaults.rb +++ b/lib/chef/resource/macos_userdefaults.rb @@ -18,6 +18,7 @@ require_relative "../resource" require "chef-utils/dist" unless defined?(ChefUtils::Dist) require "corefoundation" if RUBY_PLATFORM.match?(/darwin/) +require "ffi" unless defined?(FFI) autoload :Plist, "plist" class Chef @@ -81,8 +82,7 @@ class Chef property :host, [String, Symbol], description: "Set either :current, :all or a hostname to set the user default at the host level.", desired_state: false, - introduced: "16.3", - coerce: proc { |value| to_cf_host(value) } + introduced: "16.3" property :value, [Integer, Float, String, TrueClass, FalseClass, Hash, Array], description: "The value of the key. Note: With the `type` property set to `bool`, `String` forms of Boolean true/false values that Apple accepts in the defaults command will be coerced: 0/1, 'TRUE'/'FALSE,' 'true'/false', 'YES'/'NO', or 'yes'/'no'.", @@ -96,8 +96,7 @@ class Chef property :user, [String, Symbol], description: "The system user that the default will be applied to. Set :current for current user, :all for all users or pass a valid username", - desired_state: false, - coerce: proc { |value| to_cf_user(value) } + desired_state: false property :sudo, [TrueClass, FalseClass], description: "Set to true if the setting you wish to modify requires privileged access. This requires passwordless sudo for the `/usr/bin/defaults` command to be setup for the user running #{ChefUtils::Dist::Infra::PRODUCT}.", @@ -118,7 +117,7 @@ class Chef action :write, description: "Write the value to the specified domain/key." do converge_if_changed do Chef::Log.debug("Updating defaults value for #{new_resource.key} in #{new_resource.domain}") - CF::Preferences.set!(new_resource.key, new_resource.value, new_resource.domain, new_resource.user, new_resource.host) + CF::Preferences.set!(new_resource.key, new_resource.value, new_resource.domain, to_cf_user(new_resource.user), to_cf_host(new_resource.host)) end end @@ -128,12 +127,12 @@ class Chef converge_by("delete domain:#{new_resource.domain} key:#{new_resource.key}") do Chef::Log.debug("Removing defaults key: #{new_resource.key}") - CF::Preferences.set!(new_resource.key, nil, new_resource.domain, new_resource.user, new_resource.host) + CF::Preferences.set!(new_resource.key, nil, new_resource.domain, to_cf_user(new_resource.user), to_cf_host(new_resource.host)) end end def get_preference(new_resource) - CF::Preferences.get(new_resource.key, new_resource.domain, new_resource.user, new_resource.host) + CF::Preferences.get(new_resource.key, new_resource.domain, to_cf_user(new_resource.user), to_cf_host(new_resource.host)) end # Return valid hostname based on the input from host property |