Class: Kubes::CLI::Base

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/kubes/cli/base.rb

Direct Known Subclasses

Apply, Build, Clean, Compile, Delete, Deploy, Describe, Exec, Get, Logs, Prune

Instance Method Summary collapse

Methods included from Logging

#logger

Constructor Details

#initialize(options = {}) ⇒ Base

Returns a new instance of Base.



5
6
7
# File 'lib/kubes/cli/base.rb', line 5

def initialize(options={})
  @options = options
end

Instance Method Details

#compileObject



9
10
11
# File 'lib/kubes/cli/base.rb', line 9

def compile
  Compile.new(@options).run unless @options[:compile] == false
end

#pod_nameObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/kubes/cli/base.rb', line 13

def pod_name
  return unless @options[:pod]

  pods = Kubes::Kubectl::Fetch::Pods.new(@options)
  items = pods.fetch(:pod)
  metas = items.map { |i| i['metadata'] }
  metas.select! { |i| i['name'].include?(@options[:pod]) }
  meta = metas.sort { i['creationTimestamp'] }.last
  meta['name'] if meta
end