summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordheerajd-msys <dheeraj.dubey@msystechnologies.com>2018-06-11 17:40:50 +0530
committerTim Smith <tsmith@chef.io>2018-09-25 11:37:11 -0700
commit98dcb47109785f2d79e994701a8ebe791779d37e (patch)
tree7f63605d9b403580eae6377a6011081a0867f41a
parent9f9ecd1b31193b617326d9d2bb2115b7af91bd96 (diff)
downloadchef-98dcb47109785f2d79e994701a8ebe791779d37e.tar.gz
[MSYS-830] Fix package sensitive error
Signed-off-by: dheerajd-msys <dheeraj.dubey@msystechnologies.com>
-rw-r--r--lib/chef/provider/package/windows/exe.rb36
-rw-r--r--lib/chef/resource/windows_package.rb5
2 files changed, 29 insertions, 12 deletions
diff --git a/lib/chef/provider/package/windows/exe.rb b/lib/chef/provider/package/windows/exe.rb
index 0baea6bccd..8197ffa5cd 100644
--- a/lib/chef/provider/package/windows/exe.rb
+++ b/lib/chef/provider/package/windows/exe.rb
@@ -53,17 +53,27 @@ class Chef
def install_package
Chef::Log.debug("#{new_resource} installing #{new_resource.installer_type} package '#{new_resource.source}'")
- shell_out!(
- [
- "start",
- "\"\"",
- "/wait",
- "\"#{new_resource.source}\"",
- unattended_flags,
- expand_options(new_resource.options),
- "& exit %%%%ERRORLEVEL%%%%",
- ].join(" "), timeout: new_resource.timeout, returns: new_resource.returns
- )
+ begin
+ shell_out!(
+ [
+ "start",
+ "\"\"",
+ "/wait",
+ "\"#{new_resource.source}\"",
+ unattended_flags,
+ expand_options(new_resource.options),
+ "& exit %%%%ERRORLEVEL%%%%",
+ ].join(" "), timeout: new_resource.timeout, returns: new_resource.returns
+ )
+ rescue Mixlib::ShellOut::ShellCommandFailed
+ if sensitive?
+ ex = Mixlib::ShellOut::ShellCommandFailed.new("Command execution failed. STDOUT/STDERR suppressed for sensitive resource")
+ raise ex
+ else
+ raise
+ end
+ end
+ Chef::Log.info("#{new_resource} ran successfully")
end
def remove_package
@@ -77,6 +87,10 @@ class Chef
private
+ def sensitive?
+ !!new_resource.sensitive
+ end
+
def uninstall_command(uninstall_string)
uninstall_string = "\"#{uninstall_string}\"" if ::File.exist?(uninstall_string)
uninstall_string = [
diff --git a/lib/chef/resource/windows_package.rb b/lib/chef/resource/windows_package.rb
index d373e1f19c..e7cd4b739f 100644
--- a/lib/chef/resource/windows_package.rb
+++ b/lib/chef/resource/windows_package.rb
@@ -40,7 +40,10 @@ class Chef
end
# windows can't take array options yet
- property :options, String
+ property :options, String, sensitive: true
+
+ # lazy used to set default value of sensitive to true if options is set
+ property :sensitive, [ TrueClass, FalseClass ], default: lazy { |r| r.options ? true : false }
# Unique to this resource
property :installer_type, Symbol