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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'config/light_settings.rb')
-rw-r--r--config/light_settings.rb32
1 files changed, 32 insertions, 0 deletions
diff --git a/config/light_settings.rb b/config/light_settings.rb
new file mode 100644
index 00000000000..aa0dd04b3fa
--- /dev/null
+++ b/config/light_settings.rb
@@ -0,0 +1,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['gitlab']['host']
+ end
+
+ def gl_subdomain?
+ GL_SUBDOMAIN_REGEX === host
+ end
+ end
+end