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)
    (-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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(release) ⇒ Release

Returns a new instance of Release.



30
31
32
# File 'lib/gitlab/qa/release.rb', line 30

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

Instance Attribute Details

#releaseObject (readonly)

Returns the value of attribute release.



27
28
29
# File 'lib/gitlab/qa/release.rb', line 27

def release
  @release
end

#tagObject

Tag scheme for gitlab-ce,ee images is like 11.1.0-rc12.ee.0



86
87
88
89
90
91
92
93
# File 'lib/gitlab/qa/release.rb', line 86

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)


100
101
102
# File 'lib/gitlab/qa/release.rb', line 100

def dev_gitlab_org?
  image.start_with?(DEV_REGISTRY)
end

#editionObject



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

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)


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

def ee?
  edition == :ee
end

#imageObject



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

def image
  @image ||=
    if canonical?
      "gitlab/gitlab-#{edition}"
    else
      release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:image_without_tag]
    end
end

#previous_stableObject



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

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



76
77
78
79
80
81
82
83
# File 'lib/gitlab/qa/release.rb', line 76

def project_name
  @project_name ||=
    if canonical?
      "gitlab-#{edition}"
    else
      "gitlab-#{release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:edition]}"
    end
end

#qa_imageObject



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

def qa_image
  "#{image}-qa"
end

#qa_tagObject

Tag scheme for gitlab-ce,ee-qa images is like 11.1.0-rc12-ee



96
97
98
# File 'lib/gitlab/qa/release.rb', line 96

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

#to_eeObject



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

def to_ee
  return self if ee?

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

#to_sObject



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

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