chef-powershell 18.0.3 → 18.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/ruby_bin_folder/AMD64/Chef.PowerShell.dll +0 -0
- data/bin/ruby_bin_folder/AMD64/Chef.Powershell.Wrapper.dll +0 -0
- data/bin/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll +0 -0
- data/chef-powershell.gemspec +1 -1
- data/lib/chef-powershell/powershell.rb +37 -19
- data/lib/chef-powershell/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f3943b91db500700d5fa545d1ac204c220f39f105ddffcfb3a9c1c7fa7d4a194
|
4
|
+
data.tar.gz: ee94470b0f02a82da5bb63aadefd4411b79398f6591f622d202264cf34a1f7ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd20e5f7adb2d459a8f0006a919d220a1a73cb99d75d3c651166053378ffafc1bd2859ac1bd1dcdaba8074e3b84f648d4c786ea1f2789303f05562f78c7a45ab
|
7
|
+
data.tar.gz: 9c2419d28ea984490a4263588476a58726d94e1cf6c6d9da985ad649d2711a2a88484a78dd46e1170adf455b4eb4c747b664c6c1be3a0b302cac429e24a9fe8f
|
Binary file
|
Binary file
|
data/bin/ruby_bin_folder/AMD64/shared/Microsoft.NETCore.App/5.0.0/Chef.PowerShell.Wrapper.Core.dll
CHANGED
Binary file
|
data/chef-powershell.gemspec
CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.required_ruby_version = ">= 2.6"
|
19
19
|
|
20
20
|
spec.add_runtime_dependency "ffi", "~> 1.15"
|
21
|
-
spec.add_runtime_dependency "ffi-yajl", "~> 2.
|
21
|
+
spec.add_runtime_dependency "ffi-yajl", "~> 2.4"
|
22
22
|
|
23
23
|
spec.metadata = {
|
24
24
|
"bug_tracker_uri" => "https://github.com/chef/chef/issues",
|
@@ -64,6 +64,10 @@ class ChefPowerShell
|
|
64
64
|
end
|
65
65
|
|
66
66
|
module PowerMod
|
67
|
+
class << self
|
68
|
+
attr_accessor :result_string, :retry_count, :exception, :result, :errors, :verbose, :hashed_outcome
|
69
|
+
end
|
70
|
+
|
67
71
|
extend FFI::Library
|
68
72
|
# FFI requires attaching to modules, not classes, so we need to
|
69
73
|
# have a module here. The module level variables *could* be refactored
|
@@ -72,17 +76,29 @@ class ChefPowerShell
|
|
72
76
|
@@ps_command = ""
|
73
77
|
@@ps_timeout = -1
|
74
78
|
|
75
|
-
|
76
|
-
#
|
77
|
-
#
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
79
|
+
StoreResultCallback = FFI::Function.new(:bool, %i{pointer size_t}) do |data, size|
|
80
|
+
# try parsing the result *first* before returning from the function, and if it fails,
|
81
|
+
# return false so that the function can be retried from the C++ side.
|
82
|
+
@result_string = data.get_bytes(0, size).force_encoding("UTF-16LE").encode("UTF-8")
|
83
|
+
@hashed_outcome = FFI_Yajl::Parser.parse(@result_string)
|
84
|
+
@result = FFI_Yajl::Parser.parse(@hashed_outcome["result"])
|
85
|
+
@errors = @hashed_outcome["errors"]
|
86
|
+
@verbose = @hashed_outcome["verbose"]
|
87
|
+
true
|
88
|
+
rescue NoMethodError, FFI_Yajl::ParseError => e
|
89
|
+
@retry_count += 1
|
90
|
+
# capture exception so that it can be raised later, since otherwise
|
91
|
+
# we will be raising back to C++.
|
92
|
+
@exception = e
|
93
|
+
return true if @retry_count > 3
|
94
|
+
|
95
|
+
puts "Retrying PowerShell command execution #{@retry_count}"
|
96
|
+
sleep 1
|
97
|
+
false
|
98
|
+
rescue => e
|
99
|
+
# no retry for other exceptions
|
100
|
+
@exception = e
|
101
|
+
true
|
86
102
|
end
|
87
103
|
|
88
104
|
def self.set_ps_dll(value)
|
@@ -98,10 +114,12 @@ class ChefPowerShell
|
|
98
114
|
end
|
99
115
|
|
100
116
|
def self.do_work
|
117
|
+
@exception = nil
|
118
|
+
@retry_count = 0
|
101
119
|
ffi_lib @@powershell_dll
|
102
120
|
attach_function :execute_powershell, :ExecuteScript, %i{string int pointer}, :pointer
|
103
121
|
|
104
|
-
execute_powershell(@@ps_command, @@ps_timeout,
|
122
|
+
execute_powershell(@@ps_command, @@ps_timeout, StoreResultCallback)
|
105
123
|
end
|
106
124
|
end
|
107
125
|
|
@@ -117,13 +135,13 @@ class ChefPowerShell
|
|
117
135
|
|
118
136
|
PowerMod.set_ps_command(script)
|
119
137
|
execution = PowerMod.do_work
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
@
|
125
|
-
|
126
|
-
PowerMod.
|
138
|
+
# we returned "true" to escape retry, but we still need to check the
|
139
|
+
# exception and raise it if it exists.
|
140
|
+
raise PowerMod.exception if PowerMod.exception
|
141
|
+
|
142
|
+
@result = PowerMod.result
|
143
|
+
@errors = PowerMod.errors
|
144
|
+
@verbose = PowerMod.verbose
|
127
145
|
end
|
128
146
|
end
|
129
147
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-powershell
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 18.0
|
4
|
+
version: 18.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chef Software, Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '2.
|
33
|
+
version: '2.4'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '2.
|
40
|
+
version: '2.4'
|
41
41
|
description:
|
42
42
|
email:
|
43
43
|
- oss@chef.io
|