Sha256: 2a86e465c2ecb306f680139afdbf9a8b29c9a470a67a5924ed0e5ae0684859e8

Contents?: true

Size: 925 Bytes

Versions: 12

Compression:

Stored size: 925 Bytes

Contents

class KuberKit::Actions::KubectlConsole
  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 
      resources = kubectl_commands.get_resources(local_shell, "deployments", jsonpath: ".items[*].metadata.name")
      options   = resources.split(" ").map{|d| "deploy/#{d}" }
      pod_name  = ui.prompt("Please select deployment to attach", options)
    end

    kubectl_commands.exec(
      local_shell, pod_name, "bin/console", args: "-it", 
      kubeconfig_path: kubeconfig_path, 
      interactive: true,
      namespace: deployer_namespace
    )

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

Version data entries

12 entries across 12 versions & 1 rubygems

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