Sha256: 50ab8ffaf6553b9f7eb0d4bb23ec39a222d8bdaddd932533347231a4c4a3cbcc

Contents?: true

Size: 973 Bytes

Versions: 11

Compression:

Stored size: 973 Bytes

Contents

class KuberKit::Actions::KubectlLogs
  include KuberKit::Import[
    "shell.kubectl_commands",
    "shell.local_shell",
    "ui"
  ]

  Contract Maybe[String], Hash => Any
  def call(pod_name, options)
    kubeconfig_path = KuberKit.current_configuration.kubeconfig_path
    deployer_namespace = KuberKit.current_configuration.deployer_namespace

    if !pod_name 
      deployments     = kubectl_commands.get_resources(local_shell, "deployments", jsonpath: ".items[*].metadata.name")
      deploy_options  = deployments.split(" ").map{|d| "deploy/#{d}" }
      pod_name  = ui.prompt("Please select deployment to attach", deploy_options)
    end

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

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

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

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
kuber_kit-0.4.5 lib/kuber_kit/actions/kubectl_logs.rb
kuber_kit-0.4.4 lib/kuber_kit/actions/kubectl_logs.rb
kuber_kit-0.4.3 lib/kuber_kit/actions/kubectl_logs.rb
kuber_kit-0.4.2 lib/kuber_kit/actions/kubectl_logs.rb
kuber_kit-0.4.1 lib/kuber_kit/actions/kubectl_logs.rb
kuber_kit-0.4.0 lib/kuber_kit/actions/kubectl_logs.rb
kuber_kit-0.3.11 lib/kuber_kit/actions/kubectl_logs.rb
kuber_kit-0.3.10 lib/kuber_kit/actions/kubectl_logs.rb
kuber_kit-0.3.9 lib/kuber_kit/actions/kubectl_logs.rb
kuber_kit-0.3.8 lib/kuber_kit/actions/kubectl_logs.rb
kuber_kit-0.3.7 lib/kuber_kit/actions/kubectl_logs.rb