Commit 931099d6 authored by Lin Jen-Shin's avatar Lin Jen-Shin

Generalize some operations and check jh/ directory

parent 7c79dba3
......@@ -56,38 +56,29 @@ module Gitlab
config.generators.templates.push("#{config.root}/generator_templates")
if Gitlab.ee?
ee_paths = config.eager_load_paths.each_with_object([]) do |path, memo|
ee_path = config.root.join('ee', Pathname.new(path).relative_path_from(config.root))
memo << ee_path.to_s
load_paths = lambda do |dir:|
ext_paths = config.eager_load_paths.each_with_object([]) do |path, memo|
ext_path = config.root.join(dir, Pathname.new(path).relative_path_from(config.root))
memo << ext_path.to_s
end
ee_paths << "#{config.root}/ee/app/replicators"
ext_paths << "#{config.root}/#{dir}/app/replicators"
# Eager load should load CE first
config.eager_load_paths.push(*ee_paths)
config.helpers_paths.push "#{config.root}/ee/app/helpers"
config.eager_load_paths.push(*ext_paths)
config.helpers_paths.push "#{config.root}/#{dir}/app/helpers"
# Other than Ruby modules we load EE first
config.paths['lib/tasks'].unshift "#{config.root}/ee/lib/tasks"
config.paths['app/views'].unshift "#{config.root}/ee/app/views"
# Other than Ruby modules we load extensions first
config.paths['lib/tasks'].unshift "#{config.root}/#{dir}/lib/tasks"
config.paths['app/views'].unshift "#{config.root}/#{dir}/app/views"
end
if Gitlab.jh?
jh_paths = config.eager_load_paths.each_with_object([]) do |path, memo|
jh_path = config.root.join('jh', Pathname.new(path).relative_path_from(config.root))
memo << jh_path.to_s
end
jh_paths << "#{config.root}/jh/app/replicators"
# Eager load should load CE/EE first
config.eager_load_paths.push(*jh_paths)
config.helpers_paths.push "#{config.root}/jh/app/helpers"
Gitlab.ee do
load_paths.call(dir: 'ee')
end
# Other than Ruby modules we load JH first
config.paths['lib/tasks'].unshift "#{config.root}/jh/lib/tasks"
config.paths['app/views'].unshift "#{config.root}/jh/app/views"
Gitlab.jh do
load_paths.call(dir: 'jh')
end
# Rake tasks ignore the eager loading settings, so we need to set the
......
# frozen_string_literal: true
Gitlab.ee do
load_license = lambda do |dir:, license_name:|
prefix = ENV['GITLAB_LICENSE_MODE'] == 'test' ? 'test_' : ''
public_key_file = File.read(Rails.root.join(".#{prefix}license_encryption_key.pub"))
public_key_file = File.read(Rails.root.join(dir, ".#{prefix}license_encryption_key.pub"))
public_key = OpenSSL::PKey::RSA.new(public_key_file)
Gitlab::License.encryption_key = public_key
rescue
warn "WARNING: No valid license encryption key provided."
warn "WARNING: No valid #{license_name} encryption key provided."
end
Gitlab.ee do
load_license.call(dir: '.', license_name: 'license')
end
Gitlab.jh do
prefix = ENV['GITLAB_LICENSE_MODE'] == 'test' ? 'test_' : ''
public_key_file = File.read(Rails.root.join("jh", ".#{prefix}license_encryption_key.pub"))
public_key = OpenSSL::PKey::RSA.new(public_key_file)
Gitlab::License.encryption_key = public_key
rescue
warn "WARNING: No valid JH license encryption key provided."
load_license.call(dir: 'jh', license_name: 'JH license')
end
......@@ -111,7 +111,7 @@ module Gitlab
def self.jh?
@is_jh ||=
ee? &&
root.join('jh/app/helpers/jh/appearances_helper.rb').exist? &&
root.join('jh').exist? &&
!%w[true 1].include?(ENV['EE_ONLY'].to_s)
end
......
......@@ -329,7 +329,7 @@ RSpec.describe Gitlab do
before do
stub_path(
'ee/app/models/license.rb',
'jh/app/helpers/jh/appearances_helper.rb',
'jh',
exist?: true)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment