Class: Captive::Commands::Run

Inherits:
Object
  • Object
show all
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

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).

Returns:

  • (Integer, nil) —

    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