143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/pdk/validate/base_validator.rb', line 143
def self.invoke(report, options = {})
targets, skipped, invalid = parse_targets(options)
process_skipped(report, skipped)
process_invalid(report, invalid)
return 0 if targets.empty?
PDK::Util::Bundler.ensure_binstubs!(cmd)
if self::INVOKE_STYLE == :per_target
targets = targets.combination(1).to_a
else
targets = targets.each_slice(1000).to_a
options[:split_exec] = PDK::CLI::ExecGroup.new(spinner_text(targets), parallel: false)
end
if options.fetch(:targets, []).empty? && allow_empty_targets?
targets = [[]]
end
exit_codes = []
targets.each do |invokation_targets|
cmd_argv = parse_options(options, invokation_targets).unshift(cmd_path).compact
cmd_argv.unshift(File.join(PDK::Util::RubyVersion.bin_path, 'ruby.exe'), '-W0') if Gem.win_platform?
command = PDK::CLI::Exec::Command.new(*cmd_argv).tap do |c|
c.context = :module
c.environment = { 'PUPPET_GEM_VERSION' => options[:puppet] } if options[:puppet]
unless options[:split_exec]
exec_group = options[:exec_group]
if exec_group
sub_spinner = exec_group.add_spinner(spinner_text(invokation_targets))
c.register_spinner(sub_spinner)
else
c.add_spinner(spinner_text(invokation_targets))
end
end
end
if options[:split_exec]
options[:split_exec].register do
result = command.execute!
begin
parse_output(report, result, invokation_targets.compact)
rescue PDK::Validate::ParseOutputError => e
$stderr.puts e.message
end
result[:exit_code]
end
else
result = command.execute!
exit_codes << result[:exit_code]
begin
parse_output(report, result, invokation_targets.compact)
rescue PDK::Validate::ParseOutputError => e
$stderr.puts e.message
end
end
end
options.key?(:split_exec) ? options[:split_exec].exit_code : exit_codes.max
end
|