Class: Dapp::Kube::Kubernetes::Client::Resource::Pod

Inherits:
Base
  • Object
show all
Defined in:
lib/dapp/kube/kubernetes/client/resource/pod.rb

Instance Attribute Summary

Attributes inherited from Base

#spec

Instance Method Summary collapse

Methods inherited from Base

#annotations, #initialize, #metadata, #name, #status, #uid

Constructor Details

This class inherits a constructor from Dapp::Kube::Kubernetes::Client::Resource::Base

Instance Method Details

#container_id(container_name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/dapp/kube/kubernetes/client/resource/pod.rb', line 5

def container_id(container_name)
  container_status = spec.fetch('status', {})
    .fetch('containerStatuses')
    .find {|cs| cs['name'] == container_name}

  if container_status
    container_status['containerID']
  else
    nil
  end
end

#container_state(container_name) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/dapp/kube/kubernetes/client/resource/pod.rb', line 17

def container_state(container_name)
  container_status = status
    .fetch('containerStatuses', [])
    .find {|cs| cs['name'] == container_name}

  if container_status
    container_state, container_state_data = container_status.fetch('state', {}).first
    [container_state, container_state_data]
  else
    [nil, {}]
  end
end

#containers_namesObject



34
35
36
37
38
# File 'lib/dapp/kube/kubernetes/client/resource/pod.rb', line 34

def containers_names
  spec.fetch('spec', {})
    .fetch('containers', [])
    .map {|container_spec| container_spec['name']}
end

#phaseObject



30
31
32
# File 'lib/dapp/kube/kubernetes/client/resource/pod.rb', line 30

def phase
  status.fetch('phase', nil)
end

#restart_policyObject



40
41
42
43
44
# File 'lib/dapp/kube/kubernetes/client/resource/pod.rb', line 40

def restart_policy
  spec
    .fetch('spec', {})
    .fetch('restartPolicy', nil)
end