diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 03:07:43 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-12-07 03:07:43 +0000 |
commit | dc87c6514746996c8d720527c10102d42809804b (patch) | |
tree | 7a2b99f7237c674da2176d5d297daf1af6d9b89f /config | |
parent | 4e375367b78bb44bd00957522cd9fc3e6d403fef (diff) | |
download | gitlab-ce-dc87c6514746996c8d720527c10102d42809804b.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/direct_upload_support.rb | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/config/initializers/direct_upload_support.rb b/config/initializers/direct_upload_support.rb index 32fc8c8bc69..0fc6e82207e 100644 --- a/config/initializers/direct_upload_support.rb +++ b/config/initializers/direct_upload_support.rb @@ -3,17 +3,35 @@ class DirectUploadsValidator ValidationError = Class.new(StandardError) - def verify!(object_store) + def verify!(uploader_type, object_store) return unless object_store.enabled 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 DirectUploadsValidator.new.tap do |validator| - [Gitlab.config.artifacts, Gitlab.config.uploads, Gitlab.config.lfs].each do |uploader| - validator.verify!(uploader.object_store) + CONFIGS = { + 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 |