Class: Gitlab::Kubernetes::Pod

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/kubernetes/pod.rb

Constant Summary collapse

PENDING =
'Pending'
RUNNING =
'Running'
SUCCEEDED =
'Succeeded'
FAILED =
'Failed'
UNKNOWN =
'Unknown'
PHASES =
[PENDING, RUNNING, SUCCEEDED, FAILED, UNKNOWN].freeze
STABLE_TRACK_VALUE =
'stable'

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Pod

Returns a new instance of Pod.



15
16
17
# File 'lib/gitlab/kubernetes/pod.rb', line 15

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

Instance Method Details

#nameObject



23
24
25
# File 'lib/gitlab/kubernetes/pod.rb', line 23

def name
  ['name'] || ['generateName']
end

#orderObject



35
36
37
# File 'lib/gitlab/kubernetes/pod.rb', line 35

def order
  stable? ? 1 : 0
end

#stable?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/gitlab/kubernetes/pod.rb', line 27

def stable?
  track == STABLE_TRACK_VALUE
end

#statusObject



31
32
33
# File 'lib/gitlab/kubernetes/pod.rb', line 31

def status
  attributes.dig('status', 'phase')
end

#trackObject



19
20
21
# File 'lib/gitlab/kubernetes/pod.rb', line 19

def track
  attributes.dig('metadata', 'labels', 'track') || STABLE_TRACK_VALUE
end