Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/gitlab/kubernetes/pod.rb')
-rw-r--r--lib/gitlab/kubernetes/pod.rb36
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/gitlab/kubernetes/pod.rb b/lib/gitlab/kubernetes/pod.rb
index d247662dc3b..a5651f2f184 100644
--- a/lib/gitlab/kubernetes/pod.rb
+++ b/lib/gitlab/kubernetes/pod.rb
@@ -2,13 +2,47 @@
module Gitlab
module Kubernetes
- module Pod
+ class Pod
PENDING = 'Pending'
RUNNING = 'Running'
SUCCEEDED = 'Succeeded'
FAILED = 'Failed'
UNKNOWN = 'Unknown'
PHASES = [PENDING, RUNNING, SUCCEEDED, FAILED, UNKNOWN].freeze
+
+ 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
end
end
end