Add latest changes from gitlab-org/gitlab@master
This commit is contained in:
parent
4e375367b7
commit
dc87c65147
3 changed files with 43 additions and 7 deletions
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
title: Validate connection section in direct upload config
|
||||||
|
merge_request: 21270
|
||||||
|
author:
|
||||||
|
type: fixed
|
|
@ -3,17 +3,35 @@ class DirectUploadsValidator
|
||||||
|
|
||||||
ValidationError = Class.new(StandardError)
|
ValidationError = Class.new(StandardError)
|
||||||
|
|
||||||
def verify!(object_store)
|
def verify!(uploader_type, object_store)
|
||||||
return unless object_store.enabled
|
return unless object_store.enabled
|
||||||
return unless object_store.direct_upload
|
return unless object_store.direct_upload
|
||||||
return if SUPPORTED_DIRECT_UPLOAD_PROVIDERS.include?(object_store.connection&.provider.to_s)
|
|
||||||
|
|
||||||
raise ValidationError, "Only #{SUPPORTED_DIRECT_UPLOAD_PROVIDERS.join(',')} are supported as a object storage provider when 'direct_upload' is used"
|
raise ValidationError, "Object storage is configured for '#{uploader_type}', but the 'connection' section is missing" unless object_store.key?('connection')
|
||||||
|
|
||||||
|
provider = object_store.connection&.provider.to_s
|
||||||
|
|
||||||
|
raise ValidationError, "No provider configured for '#{uploader_type}'. #{supported_provider_text}" if provider.blank?
|
||||||
|
|
||||||
|
return if SUPPORTED_DIRECT_UPLOAD_PROVIDERS.include?(provider)
|
||||||
|
|
||||||
|
raise ValidationError, "Object storage provider '#{provider}' is not supported " \
|
||||||
|
"when 'direct_upload' is used for '#{uploader_type}'. #{supported_provider_text}"
|
||||||
|
end
|
||||||
|
|
||||||
|
def supported_provider_text
|
||||||
|
"Only #{SUPPORTED_DIRECT_UPLOAD_PROVIDERS.join(', ')} are supported."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
DirectUploadsValidator.new.tap do |validator|
|
DirectUploadsValidator.new.tap do |validator|
|
||||||
[Gitlab.config.artifacts, Gitlab.config.uploads, Gitlab.config.lfs].each do |uploader|
|
CONFIGS = {
|
||||||
validator.verify!(uploader.object_store)
|
artifacts: Gitlab.config.artifacts,
|
||||||
|
uploads: Gitlab.config.uploads,
|
||||||
|
lfs: Gitlab.config.lfs
|
||||||
|
}.freeze
|
||||||
|
|
||||||
|
CONFIGS.each do |uploader_type, uploader|
|
||||||
|
validator.verify!(uploader_type, uploader.object_store)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -56,7 +56,7 @@ describe 'Direct upload support' do
|
||||||
let(:connection) { nil }
|
let(:connection) { nil }
|
||||||
|
|
||||||
it 'raises an error' do
|
it 'raises an error' do
|
||||||
expect { subject }.to raise_error /are supported as a object storage provider when 'direct_upload' is used/
|
expect { subject }.to raise_error "No provider configured for '#{config_name}'. Only Google, AWS are supported."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -64,7 +64,20 @@ describe 'Direct upload support' do
|
||||||
let(:provider) { 'Rackspace' }
|
let(:provider) { 'Rackspace' }
|
||||||
|
|
||||||
it 'raises an error' do
|
it 'raises an error' do
|
||||||
expect { subject }.to raise_error /are supported as a object storage provider when 'direct_upload' is used/
|
expect { subject }.to raise_error /Object storage provider '#{provider}' is not supported when 'direct_upload' is used for '#{config_name}'/
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'when connection is omitted' do
|
||||||
|
let(:object_store) do
|
||||||
|
{
|
||||||
|
enabled: enabled,
|
||||||
|
direct_upload: direct_upload
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'raises an error' do
|
||||||
|
expect { subject }.to raise_error /the 'connection' section is missing/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue