Class: Gitlab::QA::Release

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/release.rb

Constant Summary collapse

CANONICAL_REGEX =
/\A(?<edition>ce|ee):?(?<tag>.+)?/i
CUSTOM_GITLAB_IMAGE_REGEX =
%r{/gitlab-(?<edition>[ce]e):(?<tag>.+)\z}
DEFAULT_TAG =
'latest'.freeze
DEFAULT_CANONICAL_TAG =
'nightly'.freeze
DEV_REGISTRY =
'dev.gitlab.org:5005'.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(release) ⇒ Release

Returns a new instance of Release.



13
14
15
# File 'lib/gitlab/qa/release.rb', line 13

def initialize(release)
  @release = release.to_s.downcase
end

Instance Attribute Details

#release ⇒ Object (readonly)

Returns the value of attribute release.



10
11
12
# File 'lib/gitlab/qa/release.rb', line 10

def release
  @release
end

#tag ⇒ Object



63
64
65
66
67
68
69
70
# File 'lib/gitlab/qa/release.rb', line 63

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

Returns:

  • (Boolean)


76
77
78
# File 'lib/gitlab/qa/release.rb', line 76

def dev_gitlab_org?
  image.start_with?(DEV_REGISTRY)
end

#edition ⇒ Object



27
28
29
30
31
32
33
34
# File 'lib/gitlab/qa/release.rb', line 27

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

Returns:

  • (Boolean)


36
37
38
# File 'lib/gitlab/qa/release.rb', line 36

def ee?
  edition == :ee
end

#image ⇒ Object



46
47
48
49
50
51
52
53
# File 'lib/gitlab/qa/release.rb', line 46

def image
  @image ||=
    if canonical?
      "gitlab/gitlab-#{edition}"
    else
      release.sub(%r{(?<image_without_tag>.+(?<port>:\d+)?/.+)(?<tag>:.+)\z}, '\k<image_without_tag>')
    end
end

#previous_stable ⇒ Object



21
22
23
24
25
# File 'lib/gitlab/qa/release.rb', line 21

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



59
60
61
# File 'lib/gitlab/qa/release.rb', line 59

def project_name
  @project_name ||= image.sub(%r{^gitlab\/}, '')
end

#qa_image ⇒ Object



55
56
57
# File 'lib/gitlab/qa/release.rb', line 55

def qa_image
  "#{image}-qa"
end

#qa_tag ⇒ Object



72
73
74
# File 'lib/gitlab/qa/release.rb', line 72

def qa_tag
  tag.sub(/\.([ce]e)/, '-\1').sub(/\.(\d+)\z/, '')
end

#to_ee ⇒ Object



40
41
42
43
44
# File 'lib/gitlab/qa/release.rb', line 40

def to_ee
  return self if ee?

  self.class.new(to_s.sub('ce:', 'ee:'))
end

#to_s ⇒ Object



17
18
19
# File 'lib/gitlab/qa/release.rb', line 17

def to_s
  "#{image}:#{tag}"
end