Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab_edition.rb « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 02006148a3494f7dce9c0749754645967678ded0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# frozen_string_literal: true

require 'pathname'

module GitlabEdition
  def self.root
    Pathname.new(File.expand_path('..', __dir__))
  end

  def self.extensions
    if jh?
      %w[ee jh]
    elsif ee?
      %w[ee]
    else
      %w[]
    end
  end

  def self.ee?
    # To reduce dependencies in QA image we are not using
    # `Gitlab::Utils::StrongMemoize` but reimplementing its functionality.
    return @is_ee if defined?(@is_ee)

    @is_ee =
      # We use this method when the Rails environment is not loaded. This
      # means that checking the presence of the License class could result in
      # this method returning `false`, even for an EE installation.
      #
      # The `FOSS_ONLY` is always `string` or `nil`
      # Thus the nil or empty string will result
      # in using default value: false
      #
      # The behavior needs to be synchronised with
      # config/helpers/is_ee_env.js
      root.join('ee/app/models/license.rb').exist? &&
        !%w[true 1].include?(ENV['FOSS_ONLY'].to_s)
  end

  def self.jh?
    return @is_jh if defined?(@is_jh)

    @is_jh =
      ee? &&
        root.join('jh').exist? &&
        !%w[true 1].include?(ENV['EE_ONLY'].to_s)
  end

  def self.ee
    yield if ee?
  end

  def self.jh
    yield if jh?
  end
end