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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(release) ⇒ Release

Returns a new instance of Release.



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

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

Instance Attribute Details

#releaseObject (readonly)

Returns the value of attribute release.



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

def release
  @release
end

#tagObject



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

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

#editionObject



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

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)


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

def ee?
  edition == :ee
end

#imageObject



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

def image
  @image ||=
    if canonical?
      "gitlab/gitlab-#{edition}"
    else
      release.sub(/:.+\z/, '')
    end
end

#previous_stableObject



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

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_nameObject



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

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

#qa_imageObject



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

def qa_image
  "#{image}-qa"
end

#qa_tagObject



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

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

#to_eeObject



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

def to_ee
  return self if ee?

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

#to_sObject



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

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