summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrishichawda <rishichawda@users.noreply.github.com>2021-09-15 22:26:42 +0530
committerLamont Granquist <lamont@scriptkiddie.org>2021-11-03 16:50:59 -0700
commit426272c9f672a7240f5fa12d21a9c6c559d2817b (patch)
tree28688f4072392990a719ff448fa33b17453f1aff
parent20aefd7c53f7c5ab8175fded6b04c66ad9949292 (diff)
downloadchef-426272c9f672a7240f5fa12d21a9c6c559d2817b.tar.gz
update powershell class to support optional timeout parameter
Signed-off-by: rishichawda <rishichawda@users.noreply.github.com>
-rw-r--r--lib/chef/powershell.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/chef/powershell.rb b/lib/chef/powershell.rb
index b49d3c58e4..0797846b4d 100644
--- a/lib/chef/powershell.rb
+++ b/lib/chef/powershell.rb
@@ -34,14 +34,14 @@ class Chef
#
# @param script [String] script to run
# @return [Object] output
- def initialize(script)
+ def initialize(script, timeout = -1)
# 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
# the built packages and copy the binaries to distro/ruby_bin_folder. Bundle install
# ensures that the correct architecture binaries are installed into the path.
@dll ||= "Chef.PowerShell.Wrapper.dll"
- exec(script)
+ exec(script, timeout)
end
#
@@ -66,10 +66,10 @@ class Chef
protected
- def exec(script)
+ def exec(script, timeout)
FFI.ffi_lib @dll
- FFI.attach_function :execute_powershell, :ExecuteScript, [:string], :pointer
- execution = FFI.execute_powershell(script).read_utf16string
+ FFI.attach_function :execute_powershell, :ExecuteScript, [:string, :int], :pointer
+ execution = FFI.execute_powershell(script, timeout).read_utf16string
hashed_outcome = Chef::JSONCompat.parse(execution)
@result = Chef::JSONCompat.parse(hashed_outcome["result"])
@errors = hashed_outcome["errors"]