2018-11-16 19:37:17 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-11-03 05:02:30 -04:00
|
|
|
module Gitlab
|
|
|
|
module Kubernetes
|
2020-10-06 20:08:24 -04:00
|
|
|
class Pod
|
2019-08-31 15:25:25 -04:00
|
|
|
PENDING = 'Pending'
|
|
|
|
RUNNING = 'Running'
|
|
|
|
SUCCEEDED = 'Succeeded'
|
|
|
|
FAILED = 'Failed'
|
|
|
|
UNKNOWN = 'Unknown'
|
2017-11-03 07:23:08 -04:00
|
|
|
PHASES = [PENDING, RUNNING, SUCCEEDED, FAILED, UNKNOWN].freeze
|
2020-10-06 20:08:24 -04:00
|
|
|
|
|
|
|
STABLE_TRACK_VALUE = 'stable'
|
|
|
|
|
|
|
|
def initialize(attributes = {})
|
|
|
|
@attributes = attributes
|
|
|
|
end
|
|
|
|
|
|
|
|
def track
|
|
|
|
attributes.dig('metadata', 'labels', 'track') || STABLE_TRACK_VALUE
|
|
|
|
end
|
|
|
|
|
|
|
|
def name
|
|
|
|
metadata['name'] || metadata['generateName']
|
|
|
|
end
|
|
|
|
|
|
|
|
def stable?
|
|
|
|
track == STABLE_TRACK_VALUE
|
|
|
|
end
|
|
|
|
|
|
|
|
def status
|
|
|
|
attributes.dig('status', 'phase')
|
|
|
|
end
|
|
|
|
|
|
|
|
def order
|
|
|
|
stable? ? 1 : 0
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
attr_reader :attributes
|
|
|
|
|
|
|
|
def metadata
|
|
|
|
attributes.fetch('metadata', {})
|
|
|
|
end
|
2017-11-03 05:02:30 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|