blob: 19343ba7de06a61987f437ff78af33ad151bfdba (
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
|
# frozen_string_literal: true
class LightSettings
GL_HOST ||= 'gitlab.com'
GL_SUBDOMAIN_REGEX ||= %r{\A[a-z0-9]+\.gitlab\.com\z}.freeze
class << self
def com?
return Thread.current[:is_com] unless Thread.current[:is_com].nil?
Thread.current[:is_com] = host == GL_HOST || gl_subdomain?
end
private
def config
YAML.safe_load(File.read(settings_path), aliases: true)[Rails.env]
end
def settings_path
Rails.root.join('config', 'gitlab.yml')
end
def host
config.dig('gitlab', 'host') || ENV['GITLAB_HOST'] || 'localhost'
end
def gl_subdomain?
GL_SUBDOMAIN_REGEX === host
end
end
end
|