class Gitlab::QA::Release

def canonical?

def canonical?
  release =~ CANONICAL_REGEX
end

def canonical_image

def canonical_image
  @canonical_image ||= "gitlab/gitlab-#{edition}"
end

def dev_gitlab_org?

def dev_gitlab_org?
  image.start_with?(DEV_REGISTRY)
end

def edition

def edition
  @edition ||=
    if canonical?
      release.match(CANONICAL_REGEX)[:edition].to_sym
    else
      release.match(CUSTOM_GITLAB_IMAGE_REGEX)[:edition].to_sym
    end
end

def ee?

def ee?
  edition == :ee
end

def image

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

def initialize(release)

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

def previous_stable

def previous_stable
  # The previous stable is always gitlab/gitlab-ce:latest or
  # gitlab/gitlab-ee:latest
  self.class.new("#{canonical_image}:latest")
end

def project_name

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

def qa_image

def qa_image
  "#{image}-qa"
end

def qa_tag

Tag scheme for gitlab-{ce,ee}-qa images is like 11.1.0-rc12-ee
def qa_tag
  tag.sub(/\.([ce]e)/, '-\1').sub(/\.(\d+)\z/, '')
end

def tag

Tag scheme for gitlab-{ce,ee} images is like 11.1.0-rc12.ee.0
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

def to_ee

def to_ee
  return self if ee?
  self.class.new(to_s.sub('ce:', 'ee:'))
end

def to_s

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