summaryrefslogtreecommitdiff
path: root/config/initializers/6_validations.rb
blob: 060b04be8243da6c876321f5caa671a2236a3a3c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

def storage_validation_error(message)
  raise "#{message}. Please fix this in your gitlab.yml before starting GitLab."
end

def validate_storages_config
  if Gitlab.config.repositories.storages.empty?
    storage_validation_error('No repository storage path defined')
  end

  Gitlab.config.repositories.storages.keys.each do |name|
    unless /\A[a-zA-Z0-9\-_]+\z/.match?(name)
      storage_validation_error("\"#{name}\" is not a valid storage name")
    end
  end
end

validate_storages_config