Class: KuberKit::Actions::KubectlLogs

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/actions/kubectl_logs.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
32
33
34
35
36
37
38
# File 'lib/kuber_kit/actions/kubectl_logs.rb', line 10

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

  if !resource_name 
    resource_name  = resource_selector.call("attach", additional_resources: [
      KuberKit::Kubernetes::Resources::POD,
      KuberKit::Kubernetes::Resources::JOB
    ])
  end

  args = nil
  if options[:follow]
    args = "-f"
  end

  kubectl_commands.logs(
    local_shell, resource_name,
    args: args,
    kubeconfig_path: kubeconfig_path, 
    namespace: deployer_namespace
  )

  true
rescue KuberKit::Error => e
  ui.print_error("Error", e.message)
  
  false
end