Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
2fe5ec7a
Commit
2fe5ec7a
authored
Jul 01, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
af2a92b0
0e8b76e1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
40 deletions
+6
-40
app/models/application_setting.rb
app/models/application_setting.rb
+0
-5
config/initializers/6_validations.rb
config/initializers/6_validations.rb
+6
-15
spec/initializers/6_validations_spec.rb
spec/initializers/6_validations_spec.rb
+0
-20
No files found.
app/models/application_setting.rb
View file @
2fe5ec7a
...
@@ -23,11 +23,6 @@ class ApplicationSetting < ApplicationRecord
...
@@ -23,11 +23,6 @@ class ApplicationSetting < ApplicationRecord
serialize
:domain_blacklist
,
Array
# rubocop:disable Cop/ActiveRecordSerialize
serialize
:domain_blacklist
,
Array
# rubocop:disable Cop/ActiveRecordSerialize
serialize
:repository_storages
# rubocop:disable Cop/ActiveRecordSerialize
serialize
:repository_storages
# rubocop:disable Cop/ActiveRecordSerialize
ignore_column
:circuitbreaker_failure_count_threshold
ignore_column
:circuitbreaker_failure_reset_time
ignore_column
:circuitbreaker_storage_timeout
ignore_column
:circuitbreaker_access_retries
ignore_column
:circuitbreaker_check_interval
ignore_column
:koding_url
ignore_column
:koding_url
ignore_column
:koding_enabled
ignore_column
:koding_enabled
ignore_column
:sentry_enabled
ignore_column
:sentry_enabled
...
...
config/initializers/6_validations.rb
View file @
2fe5ec7a
def
storage_name_valid?
(
name
)
!!
(
name
=~
/\A[a-zA-Z0-9\-_]+\z/
)
end
def
storage_validation_error
(
message
)
def
storage_validation_error
(
message
)
raise
"
#{
message
}
. Please fix this in your gitlab.yml before starting GitLab."
raise
"
#{
message
}
. Please fix this in your gitlab.yml before starting GitLab."
end
end
def
validate_storages_config
def
validate_storages_config
storage_validation_error
(
'No repository storage path defined'
)
if
Gitlab
.
config
.
repositories
.
storages
.
empty?
if
Gitlab
.
config
.
repositories
.
storages
.
empty?
storage_validation_error
(
'No repository storage path defined'
)
Gitlab
.
config
.
repositories
.
storages
.
each
do
|
name
,
repository_storage
|
end
storage_validation_error
(
"
\"
#{
name
}
\"
is not a valid storage name"
)
unless
storage_name_valid?
(
name
)
%w(failure_count_threshold failure_reset_time storage_timeout)
.
each
do
|
setting
|
# Falling back to the defaults is fine!
next
if
repository_storage
[
setting
].
nil?
unless
repository_storage
[
setting
].
to_f
>
0
Gitlab
.
config
.
repositories
.
storages
.
keys
.
each
do
|
name
|
storage_validation_error
(
"`
#{
setting
}
` for storage `
#{
name
}
` needs to be greater than 0"
)
unless
/\A[a-zA-Z0-9\-_]+\z/
.
match?
(
name
)
end
storage_validation_error
(
"
\"
#{
name
}
\"
is not a valid storage name"
)
end
end
end
end
end
end
...
...
spec/initializers/6_validations_spec.rb
View file @
2fe5ec7a
...
@@ -2,16 +2,6 @@ require 'spec_helper'
...
@@ -2,16 +2,6 @@ require 'spec_helper'
require_relative
'../../config/initializers/6_validations.rb'
require_relative
'../../config/initializers/6_validations.rb'
describe
'6_validations'
do
describe
'6_validations'
do
before
:all
do
FileUtils
.
mkdir_p
(
'tmp/tests/paths/a/b/c/d'
)
FileUtils
.
mkdir_p
(
'tmp/tests/paths/a/b/c2'
)
FileUtils
.
mkdir_p
(
'tmp/tests/paths/a/b/d'
)
end
after
:all
do
FileUtils
.
rm_rf
(
'tmp/tests/paths'
)
end
describe
'validate_storages_config'
do
describe
'validate_storages_config'
do
context
'with correct settings'
do
context
'with correct settings'
do
before
do
before
do
...
@@ -23,16 +13,6 @@ describe '6_validations' do
...
@@ -23,16 +13,6 @@ describe '6_validations' do
end
end
end
end
context
'when one of the settings is incorrect'
do
before
do
mock_storages
(
'foo'
=>
Gitlab
::
GitalyClient
::
StorageSettings
.
new
(
'path'
=>
'tmp/tests/paths/a/b/c'
,
'failure_count_threshold'
=>
'not a number'
))
end
it
'throws an error'
do
expect
{
validate_storages_config
}.
to
raise_error
(
/failure_count_threshold/
)
end
end
context
'with invalid storage names'
do
context
'with invalid storage names'
do
before
do
before
do
mock_storages
(
'name with spaces'
=>
Gitlab
::
GitalyClient
::
StorageSettings
.
new
(
'path'
=>
'tmp/tests/paths/a/b/c'
))
mock_storages
(
'name with spaces'
=>
Gitlab
::
GitalyClient
::
StorageSettings
.
new
(
'path'
=>
'tmp/tests/paths/a/b/c'
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment