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

light_settings.rb « config - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: aa0dd04b3fad3d5d5d648912cb162965f234fdb3 (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['gitlab']['host']
    end

    def gl_subdomain?
      GL_SUBDOMAIN_REGEX === host
    end
  end
end