Class: Kettle::Family::CommandRunner
- Inherits:
-
Object
- Object
- Kettle::Family::CommandRunner
- Defined in:
- lib/kettle/family/command_runner.rb
Defined Under Namespace
Classes: OtpCoordinator
Constant Summary collapse
- SENSITIVE_ENV_KEYS =
[ "KETTLE_RELEASE_GEM_SIGNING_PASSPHRASE" ].freeze
Instance Method Summary collapse
- #call(member:, phase:, command:, env: {}, interactive: false, stdout_line_handler: nil, log_path: nil, passthrough_output: true) ⇒ Object
-
#initialize(execute: false, accept: true, gem_signing_password: nil, otp_coordinator: nil) ⇒ CommandRunner
constructor
A new instance of CommandRunner.
Constructor Details
#initialize(execute: false, accept: true, gem_signing_password: nil, otp_coordinator: nil) ⇒ CommandRunner
Returns a new instance of CommandRunner.
226 227 228 229 230 231 |
# File 'lib/kettle/family/command_runner.rb', line 226 def initialize(execute: false, accept: true, gem_signing_password: nil, otp_coordinator: nil) @execute = execute @accept = accept @gem_signing_password = gem_signing_password @otp_coordinator = otp_coordinator end |
Instance Method Details
#call(member:, phase:, command:, env: {}, interactive: false, stdout_line_handler: nil, log_path: nil, passthrough_output: true) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/kettle/family/command_runner.rb', line 233 def call(member:, phase:, command:, env: {}, interactive: false, stdout_line_handler: nil, log_path: nil, passthrough_output: true) argv = command_argv(member: member, command: command, env: env) process_env = process_env(member: member, env: env) = return skipped_result(member: member, phase: phase, argv: argv) unless execute started = Process.clock_gettime(Process::CLOCK_MONOTONIC) stdout, stderr, status = with_transcript(log_path, argv: argv, chdir: member.root) do |log_io| if interactive run_interactive( env: process_env, argv: argv, chdir: member.root, member_name: member.name, process_options: , stdout_line_handler: stdout_line_handler, log_io: log_io, passthrough_output: passthrough_output ) elsif stdout_line_handler run_streaming(env: process_env, argv: argv, chdir: member.root, process_options: , stdout_line_handler: stdout_line_handler, log_io: log_io) else result = Open3.capture3(process_env, *argv, chdir: member.root, **) transcript_write(log_io, result[0]) transcript_write(log_io, result[1]) result end end stdout = normalize_output(stdout) stderr = normalize_output(stderr) elapsed = Process.clock_gettime(Process::CLOCK_MONOTONIC) - started CommandResult.new( member_name: member.name, phase: phase, command: argv, workdir: member.root, status: status.exitstatus, success: status.success?, stdout: stdout, stderr: stderr, elapsed_seconds: elapsed.round(3), skipped: false, reason: status.success? ? nil : "command failed", output_streamed: interactive, log_path: log_path ) end |