Class: Captive::Commands::DbExec

Inherits:
Object
  • Object
show all
Defined in:
lib/captive/commands/db_exec.rb

Instance Method Summary collapse

Constructor Details

#initialize(kubectl:, target: DbTarget.new(kubectl: kubectl)) ⇒ DbExec

Returns a new instance of DbExec.



9
10
11
12
# File 'lib/captive/commands/db_exec.rb', line 9

def initialize(kubectl:, target: DbTarget.new(kubectl: kubectl))
  @kubectl = kubectl
  @target  = target
end

Instance Method Details

#run(app, file, single_transaction: true) ⇒ Object

Raises:



14
15
16
17
18
19
20
21
# File 'lib/captive/commands/db_exec.rb', line 14

def run(app, file, single_transaction: true)
  pod, user, password = @target.resolve(app)
  ok = @kubectl.psql_file(app, pod, file,
                          user: user, password: password, single_transaction: single_transaction)
  raise ExecError, "L'exécution de #{file} a échoué" if ok == false

  file
end