diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 09:16:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-01-20 09:16:11 +0000 |
commit | edaa33dee2ff2f7ea3fac488d41558eb5f86d68c (patch) | |
tree | 11f143effbfeba52329fb7afbd05e6e2a3790241 /lib/gitlab_edition.rb | |
parent | d8a5691316400a0f7ec4f83832698f1988eb27c1 (diff) | |
download | gitlab-ce-edaa33dee2ff2f7ea3fac488d41558eb5f86d68c.tar.gz |
Add latest changes from gitlab-org/gitlab@14-7-stable-eev14.7.0-rc42
Diffstat (limited to 'lib/gitlab_edition.rb')
-rw-r--r-- | lib/gitlab_edition.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/gitlab_edition.rb b/lib/gitlab_edition.rb new file mode 100644 index 00000000000..6eb6b52c357 --- /dev/null +++ b/lib/gitlab_edition.rb @@ -0,0 +1,50 @@ +# 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? + @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? + @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 |