summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith84@gmail.com>2020-07-21 16:47:43 -0700
committerTim Smith <tsmith84@gmail.com>2020-07-21 16:47:43 -0700
commit960b4227b512651621676757d9d01e6d087a5ccd (patch)
treef052f9dd9cf9439033527c3bf8ba78ccd7d82c69
parent5b148d997d081473b6b4f7533778c771768a575c (diff)
downloadchef-960b4227b512651621676757d9d01e6d087a5ccd.tar.gz
Simplify the shell_out usage
Lamont was right. If you pass a nil user it just skips it. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/resource/macos_userdefaults.rb18
1 files changed, 3 insertions, 15 deletions
diff --git a/lib/chef/resource/macos_userdefaults.rb b/lib/chef/resource/macos_userdefaults.rb
index 835e28a39c..6478a37a7f 100644
--- a/lib/chef/resource/macos_userdefaults.rb
+++ b/lib/chef/resource/macos_userdefaults.rb
@@ -103,11 +103,7 @@ class Chef
load_current_value do |desired|
Chef::Log.debug "#load_current_value: shelling out \"#{defaults_export_cmd(desired).join(" ")}\" to determine state"
- state = if desired.user.nil?
- shell_out(defaults_export_cmd(desired))
- else
- shell_out(defaults_export_cmd(desired), user: desired.user)
- end
+ state = shell_out(defaults_export_cmd(desired), user: desired.user)
if state.error? || state.stdout.empty?
Chef::Log.debug "#load_current_value: #{defaults_export_cmd(desired).join(" ")} returned stdout: #{state.stdout} and stderr: #{state.stderr}"
@@ -151,11 +147,7 @@ class Chef
cmd = defaults_modify_cmd
Chef::Log.debug("Updating defaults value by shelling out: #{cmd.join(" ")}")
- if new_resource.user.nil?
- shell_out!(cmd)
- else
- shell_out!(cmd, user: new_resource.user)
- end
+ shell_out!(cmd, user: new_resource.user)
end
end
@@ -170,11 +162,7 @@ class Chef
cmd = defaults_modify_cmd
Chef::Log.debug("Removing defaults key by shelling out: #{cmd.join(" ")}")
- if new_resource.user.nil?
- shell_out!(cmd)
- else
- shell_out!(cmd, user: new_resource.user)
- end
+ shell_out!(cmd, user: new_resource.user)
end
end