Class: Captive::Commands::Run
- Inherits:
-
Object
- Object
- Captive::Commands::Run
- Defined in:
- lib/captive/commands/run.rb
Overview
Verbe unique des one-off (ADR 0017) : la commande passe par sh -c, comme scalingo run, et la session n'est interactive que devant un TTY.
Instance Method Summary collapse
-
#initialize(kubectl:, trail:, one_off: OneOffSession.new(kubectl: kubectl)) ⇒ Run
constructor
A new instance of Run.
-
#run(app, *cmd) ⇒ Integer?
Exit code of the one-off command (nil when attached).
Constructor Details
#initialize(kubectl:, trail:, one_off: OneOffSession.new(kubectl: kubectl)) ⇒ Run
Returns a new instance of Run.
10 11 12 13 |
# File 'lib/captive/commands/run.rb', line 10 def initialize(kubectl:, trail:, one_off: OneOffSession.new(kubectl: kubectl)) @trail = trail @one_off = one_off end |
Instance Method Details
#run(app, *cmd) ⇒ Integer?
Returns exit code of the one-off command (nil when attached).
16 17 18 19 20 21 |
# File 'lib/captive/commands/run.rb', line 16 def run(app, *cmd) script = cmd.join(" ") @one_off.run(app, [ "sh", "-c", script ]) do |session| @trail.command_run(app, [ script ], session: session) end end |