summaryrefslogtreecommitdiff
path: root/app/models/application_setting.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/application_setting.rb')
-rw-r--r--app/models/application_setting.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index b29d6731b08..425a0e05c7d 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -19,6 +19,12 @@ class ApplicationSetting < ApplicationRecord
belongs_to :instance_administrators_group, class_name: "Group"
+ def self.repository_storages_weighted_attributes
+ @repository_storages_weighted_atributes ||= Gitlab.config.repositories.storages.keys.map { |k| "repository_storages_weighted_#{k}".to_sym }.freeze
+ end
+
+ store_accessor :repository_storages_weighted, *Gitlab.config.repositories.storages.keys, prefix: true
+
# Include here so it can override methods from
# `add_authentication_token_field`
# We don't prepend for now because otherwise we'll need to
@@ -39,6 +45,7 @@ class ApplicationSetting < ApplicationRecord
cache_markdown_field :after_sign_up_text
default_value_for :id, 1
+ default_value_for :repository_storages_weighted, {}
chronic_duration_attr_writer :archive_builds_in_human_readable, :archive_builds_in_seconds
@@ -136,6 +143,10 @@ class ApplicationSetting < ApplicationRecord
presence: true,
numericality: { only_integer: true, greater_than: 0 }
+ validates :max_import_size,
+ presence: true,
+ numericality: { only_integer: true, greater_than_or_equal_to: 0 }
+
validates :max_pages_size,
presence: true,
numericality: { only_integer: true, greater_than_or_equal_to: 0,
@@ -152,6 +163,7 @@ class ApplicationSetting < ApplicationRecord
validates :repository_storages, presence: true
validate :check_repository_storages
+ validate :check_repository_storages_weighted
validates :auto_devops_domain,
allow_blank: true,
@@ -271,6 +283,10 @@ class ApplicationSetting < ApplicationRecord
validates :allowed_key_types, presence: true
+ repository_storages_weighted_attributes.each do |attribute|
+ validates attribute, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 0, less_than_or_equal_to: 100 }
+ end
+
validates_each :restricted_visibility_levels do |record, attr, value|
value&.each do |level|
unless Gitlab::VisibilityLevel.options.value?(level)
@@ -301,6 +317,13 @@ class ApplicationSetting < ApplicationRecord
numericality: { greater_than: 0, less_than_or_equal_to: 10 },
if: :external_authorization_service_enabled
+ validates :spam_check_endpoint_url,
+ addressable_url: true, allow_blank: true
+
+ validates :spam_check_endpoint_url,
+ presence: true,
+ if: :spam_check_endpoint_enabled
+
validates :external_auth_client_key,
presence: true,
if: -> (setting) { setting.external_auth_client_cert.present? }
@@ -427,6 +450,12 @@ class ApplicationSetting < ApplicationRecord
recaptcha_enabled || login_recaptcha_protection_enabled
end
+ repository_storages_weighted_attributes.each do |attribute|
+ define_method :"#{attribute}=" do |value|
+ super(value.to_i)
+ end
+ end
+
private
def parsed_grafana_url