gitlab-org--gitlab-foss/config/initializers/direct_upload_support.rb

20 lines
700 B
Ruby
Raw Normal View History

2018-06-04 08:06:07 -04:00
class DirectUploadsValidator
SUPPORTED_DIRECT_UPLOAD_PROVIDERS = %w(Google AWS).freeze
2018-05-09 11:27:38 -04:00
2018-06-04 08:06:07 -04:00
ValidationError = Class.new(StandardError)
2018-05-09 11:27:38 -04:00
2018-06-04 08:06:07 -04:00
def verify!(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"
end
2018-05-09 11:27:38 -04:00
end
2018-06-04 08:06:07 -04:00
DirectUploadsValidator.new.tap do |validator|
[Gitlab.config.artifacts, Gitlab.config.uploads, Gitlab.config.lfs].each do |uploader|
validator.verify!(uploader.object_store)
end
end