Class: KuberKit::Actions::KubectlGet

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/actions/kubectl_get.rb

Instance Method Summary collapse

Instance Method Details

#call(resource_name, options) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kuber_kit/actions/kubectl_get.rb', line 10

def call(resource_name, options)
  kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
  deployer_namespace = KuberKit.current_configuration.deployer_namespace

  resources = kubectl_commands.get_resources(
    local_shell, "pod",
    kubeconfig_path: kubeconfig_path, 
    namespace: deployer_namespace
  )
  
  if resource_name
    resources = resources.select{|r| r.include?(resource_name) }
  end

  ui.print_info("Pods", resources.join("\n"))

  resources
rescue KuberKit::Error => e
  ui.print_error("Error", e.message)
  
  []
end