Sha256: 9427f65b0ae1bf4af3e2c749b70adb862140e89b6ea2592b3e5f0c045e0285be

Contents?: true

Size: 801 Bytes

Versions: 21

Compression:

Stored size: 801 Bytes

Contents

class KuberKit::Actions::KubectlGet
  include KuberKit::Import[
    "shell.kubectl_commands",
    "shell.local_shell",
    "kubernetes.resource_selector",
    "ui"
  ]

  Contract Maybe[String], Hash => Array
  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
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
kuber_kit-1.2.1 lib/kuber_kit/actions/kubectl_get.rb