Class: Gitlab::QA::Release
- Inherits:
-
Object
- Object
- Gitlab::QA::Release
- Defined in:
- lib/gitlab/qa/release.rb
Constant Summary collapse
- CANONICAL_REGEX =
/ \A (?<edition>ce|ee) (-qa)? (:(?<tag>.+))? \z /xi- CUSTOM_GITLAB_IMAGE_REGEX =
%r{ \A (?<image_without_tag> (?<registry>[^\/:]+(:(?<port>\d+))?) .+ gitlab- (?<edition>ce|ee) ) (-qa)? (:(?<tag>.+))? \z }xi- DEFAULT_TAG =
'latest'.freeze
- DEFAULT_CANONICAL_TAG =
'nightly'.freeze
- DEV_REGISTRY =
'dev.gitlab.org:5005'.freeze
- InvalidImageNameError =
Class.new(RuntimeError)
Instance Attribute Summary collapse
-
#release ⇒ Object
readonly
Returns the value of attribute release.
-
#tag ⇒ Object
Tag scheme for gitlab-ce,ee images is like 11.1.0-rc12.ee.0.
Instance Method Summary collapse
- #dev_gitlab_org? ⇒ Boolean
- #edition ⇒ Object
- #ee? ⇒ Boolean
- #image ⇒ Object
-
#initialize(release) ⇒ Release
constructor
A new instance of Release.
- #previous_stable ⇒ Object
- #project_name ⇒ Object
- #qa_image ⇒ Object
-
#qa_tag ⇒ Object
Tag scheme for gitlab-ce,ee-qa images is like 11.1.0-rc12-ee.
- #to_ee ⇒ Object
- #to_s ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(release) ⇒ Release
Returns a new instance of Release.
32 33 34 35 36 |
# File 'lib/gitlab/qa/release.rb', line 32 def initialize(release) @release = release.to_s.downcase raise InvalidImageNameError, "The release image name '#{@release}' does not have the expected format." unless valid? end |
Instance Attribute Details
#release ⇒ Object (readonly)
Returns the value of attribute release.
29 30 31 |
# File 'lib/gitlab/qa/release.rb', line 29 def release @release end |
#tag ⇒ Object
Tag scheme for gitlab-ce,ee images is like 11.1.0-rc12.ee.0
90 91 92 93 94 95 96 97 |
# File 'lib/gitlab/qa/release.rb', line 90 def tag @tag ||= if canonical? release.match(CANONICAL_REGEX)[:tag] || DEFAULT_CANONICAL_TAG else release.match(CUSTOM_GITLAB_IMAGE_REGEX)&.[](:tag) || DEFAULT_TAG end end |
Instance Method Details
#dev_gitlab_org? ⇒ Boolean
104 105 106 |
# File 'lib/gitlab/qa/release.rb', line 104 def dev_gitlab_org? image.start_with?(DEV_REGISTRY) end |
#edition ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'lib/gitlab/qa/release.rb', line 48 def edition @edition ||= if canonical? release.match(CANONICAL_REGEX)[:edition].to_sym else release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:edition].to_sym end end |
#ee? ⇒ Boolean
57 58 59 |
# File 'lib/gitlab/qa/release.rb', line 57 def ee? edition == :ee end |
#image ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/gitlab/qa/release.rb', line 67 def image @image ||= if canonical? "gitlab/gitlab-#{edition}" else release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:image_without_tag] end end |
#previous_stable ⇒ Object
42 43 44 45 46 |
# File 'lib/gitlab/qa/release.rb', line 42 def previous_stable # The previous stable is always gitlab/gitlab-ce:latest or # gitlab/gitlab-ee:latest self.class.new("#{canonical_image}:latest") end |
#project_name ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/gitlab/qa/release.rb', line 80 def project_name @project_name ||= if canonical? "gitlab-#{edition}" else "gitlab-#{release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:edition]}" end end |
#qa_image ⇒ Object
76 77 78 |
# File 'lib/gitlab/qa/release.rb', line 76 def qa_image "#{image}-qa" end |
#qa_tag ⇒ Object
Tag scheme for gitlab-ce,ee-qa images is like 11.1.0-rc12-ee
100 101 102 |
# File 'lib/gitlab/qa/release.rb', line 100 def qa_tag tag.sub(/[-\.]([ce]e)(\.(\d+))?\z/, '-\1') end |
#to_ee ⇒ Object
61 62 63 64 65 |
# File 'lib/gitlab/qa/release.rb', line 61 def to_ee return self if ee? self.class.new(to_s.sub('ce:', 'ee:')) end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/gitlab/qa/release.rb', line 38 def to_s "#{image}:#{tag}" end |
#valid? ⇒ Boolean
108 109 110 |
# File 'lib/gitlab/qa/release.rb', line 108 def valid? canonical? || release.match?(CUSTOM_GITLAB_IMAGE_REGEX) end |