Class: Services::Console

Inherits:
Object
  • Object
show all
Defined in:
lib/busbar_cli/services/console.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_id, environment_name) ⇒ Console



7
8
9
10
11
12
13
14
# File 'lib/busbar_cli/services/console.rb', line 7

def initialize(app_id, environment_name)
  Services::Kube.setup

  @environment = EnvironmentsRepository.find(
    environment_name: environment_name,
    app_id: app_id
  )
end

Class Method Details

.call(app_id, environment_name) ⇒ Object



3
4
5
# File 'lib/busbar_cli/services/console.rb', line 3

def self.call(app_id, environment_name)
  new(app_id, environment_name).call
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/busbar_cli/services/console.rb', line 16

def call
  if @environment.nil?
    puts 'Environment or app not found. Please check your input'
    exit 0
  end

  lines    = `tput lines`.chomp
  columns  = `tput cols`.chomp

  Kernel.exec(
    "#{KUBECTL} run --context=#{Services::Kube.current_profile} #{command_options} -- " \
    "/usr/bin/env LINES=#{lines} COLUMNS=#{columns} " \
    "TERM=#{ENV['TERM']} #{environment_settings} /bin/bash -li"
  )
end