summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrishichawda <rishichawda@users.noreply.github.com>2021-09-29 23:11:21 +0530
committerLamont Granquist <lamont@scriptkiddie.org>2021-11-03 16:50:59 -0700
commit8f27f824c8cf2965572cf0f11b49927c50ec4031 (patch)
treedcdd5f2c51a51f66b562da725dfe6d78aef3212b
parent426272c9f672a7240f5fa12d21a9c6c559d2817b (diff)
downloadchef-8f27f824c8cf2965572cf0f11b49927c50ec4031.tar.gz
review updates
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
-rw-r--r--lib/chef/powershell.rb7
1 files changed, 4 insertions, 3 deletions
diff --git a/lib/chef/powershell.rb b/lib/chef/powershell.rb
index 0797846b4d..2a097c2657 100644
--- a/lib/chef/powershell.rb
+++ b/lib/chef/powershell.rb
@@ -34,7 +34,7 @@ class Chef
#
# @param script [String] script to run
# @return [Object] output
- def initialize(script, timeout = -1)
+ def initialize(script, timeout: nil)
# This Powershell DLL source lives here: https://github.com/chef/chef-powershell-shim
# Every merge into that repo triggers a Habitat build and promotion. Running
# the rake :update_chef_exec_dll task in this (chef/chef) repo will pull down
@@ -64,11 +64,12 @@ class Chef
raise Chef::PowerShell::CommandFailed, "Unexpected exit in PowerShell command: #{@errors}" if error?
end
- protected
+ private
- def exec(script, timeout)
+ def exec(script, timeout: nil)
FFI.ffi_lib @dll
FFI.attach_function :execute_powershell, :ExecuteScript, [:string, :int], :pointer
+ timeout = timeout&.nonzero? ? timeout : -1
execution = FFI.execute_powershell(script, timeout).read_utf16string
hashed_outcome = Chef::JSONCompat.parse(execution)
@result = Chef::JSONCompat.parse(hashed_outcome["result"])