Class: KBE::CLI::ListCommand

Inherits:
Clamp::Command
  • Object
show all
Defined in:
lib/kbe/cli/list_command.rb

Instance Method Summary collapse

Instance Method Details

#executeObject



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/kbe/cli/list_command.rb', line 15

def execute
  if selector
    pod = KBE.pod_by(selector, only_running: false)
    json = JSON.parse(`kubectl get pod #{pod} -o json`)
    for container in json["spec"]["containers"]
      puts container["name"]
    end
  else
    KBE.kubectl ["get pod"]
  end
rescue JSON::ParserError
end