diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-29 19:57:17 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-07-29 19:57:17 +0000 |
commit | 37e3c3bb33c3d331fceb2840cf3c1d3c466dcfa9 (patch) | |
tree | 9d3739f627b491b42ede6424acd11b589beed25f /lib/api | |
parent | b55baf593e63db9be3f446ea0cca0281a69dd2e2 (diff) | |
download | gitlab-ce-37e3c3bb33c3d331fceb2840cf3c1d3c466dcfa9.tar.gz |
Add latest changes from gitlab-org/gitlab@13-2-stable-ee
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/settings.rb | 3 | ||||
-rw-r--r-- | lib/api/validations/types/hash_of_integer_values.rb | 20 |
2 files changed, 21 insertions, 2 deletions
diff --git a/lib/api/settings.rb b/lib/api/settings.rb index 3463e29041b..f2e0aaecfb9 100644 --- a/lib/api/settings.rb +++ b/lib/api/settings.rb @@ -114,8 +114,7 @@ module API requires :recaptcha_private_key, type: String, desc: 'Generate private key at http://www.google.com/recaptcha' end optional :repository_checks_enabled, type: Boolean, desc: "GitLab will periodically run 'git fsck' in all project and wiki repositories to look for silent disk corruption issues." - optional :repository_storages, type: Array[String], coerce_with: Validations::Types::CommaSeparatedToArray.coerce, desc: 'Storage paths for new projects' - optional :repository_storages_weighted, type: Hash, desc: 'Storage paths for new projects with a weighted value between 0 and 100' + optional :repository_storages_weighted, type: Hash, coerce_with: Validations::Types::HashOfIntegerValues.coerce, desc: 'Storage paths for new projects with a weighted value ranging from 0 to 100' optional :require_two_factor_authentication, type: Boolean, desc: 'Require all users to set up Two-factor authentication' given require_two_factor_authentication: ->(val) { val } do requires :two_factor_grace_period, type: Integer, desc: 'Amount of time (in hours) that users are allowed to skip forced configuration of two-factor authentication' diff --git a/lib/api/validations/types/hash_of_integer_values.rb b/lib/api/validations/types/hash_of_integer_values.rb new file mode 100644 index 00000000000..05821acfad5 --- /dev/null +++ b/lib/api/validations/types/hash_of_integer_values.rb @@ -0,0 +1,20 @@ +# frozen_string_literal: true + +module API + module Validations + module Types + class HashOfIntegerValues + def self.coerce + lambda do |value| + case value + when Hash + value.transform_values(&:to_i) + else + value + end + end + end + end + end + end +end |