Sha256: a52d0734289569ac747bc44b8adf8e8f9f16d26498126eff1fd2a5cccc70f08f

Contents?: true

Size: 1.07 KB

Versions: 36

Compression:

Stored size: 1.07 KB

Contents

class KuberKit::Kubernetes::ResourceSelector
  include KuberKit::Import[
    "kubernetes.resources_fetcher",
    "shell.local_shell",
    "ui"
  ]

  Contract String, KeywordArgs[
    include_ingresses: Optional[Bool],
    include_pods:      Optional[Bool]
  ] => Any
  def call(action_name, include_ingresses: false, include_pods: false)
    deployments = resources_fetcher.call("deployments")
    options  = deployments.map{|d| "deploy/#{d}" }
    options  << "ingresses" if include_ingresses
    options  << "pods" if include_pods
    option  = ui.prompt("Please select resource to #{action_name}", options)

    if option == "ingresses" && include_ingresses
      ingresses = resources_fetcher.call("ingresses")
      options   = ingresses.map{|d| "ingresses/#{d}" }
      return ui.prompt("Please select ingress to #{action_name}", options)
    end

    if option == "pods" && include_pods
      ingresses = resources_fetcher.call("pods")
      options   = ingresses.map{|d| "pods/#{d}" }
      return ui.prompt("Please select pod to #{action_name}", options)
    end
    
    option
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
kuber_kit-0.9.8 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.9.7 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.9.6 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.9.5 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.9.4 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.9.3 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.9.2 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.9.1 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.9.0 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.8.8 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.8.7 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.8.6 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.8.5 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.8.4 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.8.3 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.8.2 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.8.1 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.8.0 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.7.1 lib/kuber_kit/kubernetes/resource_selector.rb
kuber_kit-0.7.0 lib/kuber_kit/kubernetes/resource_selector.rb