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
- DEV_OFFICIAL_TAG_REGEX =
Official dev tag example:
12.5.4(-rc42)-ee
|————-|–|
| | | | | | | edition
version
/ \A (?<version>\d+\.\d+.\d+(?:-rc\d+)?)-(?<edition>ce|ee) \z /xi
- DEV_TAG_REGEX =
Dev tag example:
12.1.201906121026-325a6632895.b340d0bd35d
|—-|————|———–|———–|
| | | | | | | omnibus-ref | | gitlab-ee ref | timestamp
version
/ \A (?<version>\d+\.\d+(.\d+)?)\.(?<timestamp>\d+)\-(?<gitlab_ref>[A-Za-z0-9]+)\.(?<omnibus_ref>[A-Za-z0-9]+) \z /xi
- DEFAULT_TAG =
'latest'.freeze
- DEFAULT_CANONICAL_TAG =
'nightly'.freeze
- DEV_REGISTRY =
'dev.gitlab.org:5005'.freeze
- COM_REGISTRY =
'registry.gitlab.com'.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.
- #login_params ⇒ Object
- #omnibus_mirror? ⇒ Boolean
- #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.
62 63 64 65 66 |
# File 'lib/gitlab/qa/release.rb', line 62 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.
59 60 61 |
# File 'lib/gitlab/qa/release.rb', line 59 def release @release end |
#tag ⇒ Object
Tag scheme for gitlab-ce,ee images is like 11.1.0-rc12.ee.0
120 121 122 123 124 125 126 127 |
# File 'lib/gitlab/qa/release.rb', line 120 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
158 159 160 |
# File 'lib/gitlab/qa/release.rb', line 158 def dev_gitlab_org? image.start_with?(DEV_REGISTRY) end |
#edition ⇒ Object
78 79 80 81 82 83 84 85 |
# File 'lib/gitlab/qa/release.rb', line 78 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
87 88 89 |
# File 'lib/gitlab/qa/release.rb', line 87 def ee? edition == :ee end |
#image ⇒ Object
97 98 99 100 101 102 103 104 |
# File 'lib/gitlab/qa/release.rb', line 97 def image @image ||= if canonical? "gitlab/gitlab-#{edition}" else release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:image_without_tag] end end |
#login_params ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/gitlab/qa/release.rb', line 138 def login_params if dev_gitlab_org? Runtime::Env.require_qa_dev_access_token! { username: Runtime::Env.gitlab_dev_username, password: Runtime::Env.dev_access_token_variable, registry: DEV_REGISTRY } elsif omnibus_mirror? Runtime::Env.require_gitlab_bot_multi_project_pipeline_polling_token! { username: Runtime::Env.gitlab_username, password: Runtime::Env.gitlab_bot_multi_project_pipeline_polling_token, registry: COM_REGISTRY } end end |
#omnibus_mirror? ⇒ Boolean
162 163 164 |
# File 'lib/gitlab/qa/release.rb', line 162 def omnibus_mirror? image.start_with?("#{COM_REGISTRY}/gitlab-org/build/omnibus-gitlab-mirror/") end |
#previous_stable ⇒ Object
72 73 74 75 76 |
# File 'lib/gitlab/qa/release.rb', line 72 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
110 111 112 113 114 115 116 117 |
# File 'lib/gitlab/qa/release.rb', line 110 def project_name @project_name ||= if canonical? "gitlab-#{edition}" else "gitlab-#{release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:edition]}" end end |
#qa_image ⇒ Object
106 107 108 |
# File 'lib/gitlab/qa/release.rb', line 106 def qa_image "#{image}-qa" end |
#qa_tag ⇒ Object
Tag scheme for gitlab-ce,ee-qa images is like 11.1.0-rc12-ee
130 131 132 133 134 135 136 |
# File 'lib/gitlab/qa/release.rb', line 130 def qa_tag if dev_gitlab_org? && (match_data = tag.match(DEV_TAG_REGEX)) "#{match_data[:version]}-#{match_data[:gitlab_ref]}" else tag.sub(/[-\.]([ce]e)(\.(\d+))?\z/, '-\1') end end |
#to_ee ⇒ Object
91 92 93 94 95 |
# File 'lib/gitlab/qa/release.rb', line 91 def to_ee return self if ee? self.class.new(to_s.sub('ce:', 'ee:')) end |
#to_s ⇒ Object
68 69 70 |
# File 'lib/gitlab/qa/release.rb', line 68 def to_s "#{image}:#{tag}" end |
#valid? ⇒ Boolean
166 167 168 |
# File 'lib/gitlab/qa/release.rb', line 166 def valid? canonical? || release.match?(CUSTOM_GITLAB_IMAGE_REGEX) end |