train-core 3.5.4 → 3.5.5
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/lib/train/transports/local.rb +18 -7
- data/lib/train/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dbe3fad014697c3f0a1d5fb5d3f4ff422f9e552362179f72019f7c2f9784f975
|
|
4
|
+
data.tar.gz: 337a74095aa5e41b4dd4f24ba2e41857190161a035c2adaf809617205525e442
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a066352b95be252da1de517176e98fe67804484bfb7f9371a23762b04a5050e7a3a7ca814eb27c773c5b23e7eb85a6eb26fd251df67bfd25c500e34a1075f7dc
|
|
7
|
+
data.tar.gz: fdfa95f6c1278dd04760e5dface6b4feacac3d0dd2b77f8844215d6f9b17760967afa482181415368fd8c3ca869e697e205c5abd45913e6cbfb12dcfc93044c1
|
|
@@ -86,9 +86,9 @@ module Train::Transports
|
|
|
86
86
|
end
|
|
87
87
|
end
|
|
88
88
|
|
|
89
|
-
def run_command_via_connection(cmd, &_data_handler)
|
|
89
|
+
def run_command_via_connection(cmd, opts, &_data_handler)
|
|
90
90
|
# Use the runner if it is available
|
|
91
|
-
return @runner.run_command(cmd) if defined?(@runner)
|
|
91
|
+
return @runner.run_command(cmd, opts) if defined?(@runner)
|
|
92
92
|
|
|
93
93
|
# If we don't have a runner, such as at the beginning of setting up the
|
|
94
94
|
# transport and performing the first few steps of OS detection, fall
|
|
@@ -115,13 +115,18 @@ module Train::Transports
|
|
|
115
115
|
@cmd_wrapper = Local::CommandWrapper.load(connection, options)
|
|
116
116
|
end
|
|
117
117
|
|
|
118
|
-
def run_command(cmd)
|
|
118
|
+
def run_command(cmd, opts = {})
|
|
119
119
|
if defined?(@cmd_wrapper) && !@cmd_wrapper.nil?
|
|
120
120
|
cmd = @cmd_wrapper.run(cmd)
|
|
121
121
|
end
|
|
122
122
|
|
|
123
123
|
res = Mixlib::ShellOut.new(cmd)
|
|
124
|
-
res.
|
|
124
|
+
res.timeout = opts[:timeout]
|
|
125
|
+
begin
|
|
126
|
+
res.run_command
|
|
127
|
+
rescue Mixlib::ShellOut::CommandTimeout
|
|
128
|
+
raise Train::CommandTimeoutReached
|
|
129
|
+
end
|
|
125
130
|
Local::CommandResult.new(res.stdout, res.stderr, res.exitstatus)
|
|
126
131
|
end
|
|
127
132
|
|
|
@@ -138,7 +143,7 @@ module Train::Transports
|
|
|
138
143
|
@powershell_cmd = powershell_cmd
|
|
139
144
|
end
|
|
140
145
|
|
|
141
|
-
def run_command(script)
|
|
146
|
+
def run_command(script, opts)
|
|
142
147
|
# Prevent progress stream from leaking into stderr
|
|
143
148
|
script = "$ProgressPreference='SilentlyContinue';" + script
|
|
144
149
|
|
|
@@ -149,7 +154,12 @@ module Train::Transports
|
|
|
149
154
|
cmd = "#{@powershell_cmd} -NoProfile -EncodedCommand #{base64_script}"
|
|
150
155
|
|
|
151
156
|
res = Mixlib::ShellOut.new(cmd)
|
|
152
|
-
res.
|
|
157
|
+
res.timeout = opts[:timeout]
|
|
158
|
+
begin
|
|
159
|
+
res.run_command
|
|
160
|
+
rescue Mixlib::ShellOut::CommandTimeout
|
|
161
|
+
raise Train::CommandTimeoutReached
|
|
162
|
+
end
|
|
153
163
|
Local::CommandResult.new(res.stdout, res.stderr, res.exitstatus)
|
|
154
164
|
end
|
|
155
165
|
|
|
@@ -176,9 +186,10 @@ module Train::Transports
|
|
|
176
186
|
# A command that succeeds without setting an exit code will have exitstatus 0
|
|
177
187
|
# A command that exits with an exit code will have that value as exitstatus
|
|
178
188
|
# A command that fails (e.g. throws exception) before setting an exit code will have exitstatus 1
|
|
179
|
-
def run_command(cmd)
|
|
189
|
+
def run_command(cmd, _opts)
|
|
180
190
|
script = "$ProgressPreference='SilentlyContinue';" + cmd
|
|
181
191
|
encoded_script = Base64.strict_encode64(script)
|
|
192
|
+
# TODO: no way to safely implement timeouts here.
|
|
182
193
|
@pipe.puts(encoded_script)
|
|
183
194
|
@pipe.flush
|
|
184
195
|
res = OpenStruct.new(JSON.parse(Base64.decode64(@pipe.readline)))
|
data/lib/train/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: train-core
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.5.
|
|
4
|
+
version: 3.5.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chef InSpec Team
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2021-03-
|
|
11
|
+
date: 2021-03-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: addressable
|