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.
140 141 142 143 144 145 |
# File 'lib/kettle/family/command_runner.rb', line 140 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
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 |
# File 'lib/kettle/family/command_runner.rb', line 147 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 |