2019-02-15 15:39:39 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
module Gitlab
|
|
|
|
module Kubernetes
|
2021-01-03 14:25:43 +05:30
|
|
|
class Pod
|
2019-12-04 20:38:33 +05:30
|
|
|
PENDING = 'Pending'
|
|
|
|
RUNNING = 'Running'
|
|
|
|
SUCCEEDED = 'Succeeded'
|
|
|
|
FAILED = 'Failed'
|
|
|
|
UNKNOWN = 'Unknown'
|
2018-03-17 18:26:18 +05:30
|
|
|
PHASES = [PENDING, RUNNING, SUCCEEDED, FAILED, UNKNOWN].freeze
|
2021-01-03 14:25:43 +05:30
|
|
|
|
|
|
|
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
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|