Commit b334f0d3 authored by Igor Drozdov's avatar Igor Drozdov

Merge branch 'sh-require-azurerm' into 'master'

Ensure Azure-related gems are loaded

See merge request gitlab-org/gitlab!72433
parents 0c9dbf79 2112aeb4
...@@ -129,7 +129,7 @@ gem 'fog-local', '~> 0.6' ...@@ -129,7 +129,7 @@ gem 'fog-local', '~> 0.6'
gem 'fog-openstack', '~> 1.0' gem 'fog-openstack', '~> 1.0'
gem 'fog-rackspace', '~> 0.1.1' gem 'fog-rackspace', '~> 0.1.1'
gem 'fog-aliyun', '~> 0.3' gem 'fog-aliyun', '~> 0.3'
gem 'gitlab-fog-azure-rm', '~> 1.2.0', require: false gem 'gitlab-fog-azure-rm', '~> 1.2.0', require: 'fog/azurerm'
# for Google storage # for Google storage
gem 'google-api-client', '~> 0.33' gem 'google-api-client', '~> 0.33'
......
...@@ -17,7 +17,7 @@ class DirectUploadsValidator ...@@ -17,7 +17,7 @@ class DirectUploadsValidator
raise ValidationError, "No provider configured for '#{uploader_type}'. #{supported_provider_text}" if provider.blank? raise ValidationError, "No provider configured for '#{uploader_type}'. #{supported_provider_text}" if provider.blank?
return if provider_loaded?(provider) return if provider_supported?(provider)
raise ValidationError, "Object storage provider '#{provider}' is not supported " \ raise ValidationError, "Object storage provider '#{provider}' is not supported " \
"when 'direct_upload' is used for '#{uploader_type}'. #{supported_provider_text}" "when 'direct_upload' is used for '#{uploader_type}'. #{supported_provider_text}"
...@@ -25,12 +25,8 @@ class DirectUploadsValidator ...@@ -25,12 +25,8 @@ class DirectUploadsValidator
private private
def provider_loaded?(provider) def provider_supported?(provider)
return false unless SUPPORTED_DIRECT_UPLOAD_PROVIDERS.include?(provider) SUPPORTED_DIRECT_UPLOAD_PROVIDERS.include?(provider)
require 'fog/azurerm' if provider == ObjectStorage::Config::AZURE_PROVIDER
true
end end
def supported_provider_text def supported_provider_text
......
...@@ -210,9 +210,7 @@ module Backup ...@@ -210,9 +210,7 @@ module Backup
def object_storage_config def object_storage_config
@object_storage_config ||= begin @object_storage_config ||= begin
config = ObjectStorage::Config.new(Gitlab.config.backup.upload) ObjectStorage::Config.new(Gitlab.config.backup.upload)
config.load_provider
config
end end
end end
......
...@@ -12,16 +12,6 @@ module ObjectStorage ...@@ -12,16 +12,6 @@ module ObjectStorage
@options = options.to_hash.deep_symbolize_keys @options = options.to_hash.deep_symbolize_keys
end end
def load_provider
if aws?
require 'fog/aws'
elsif google?
require 'fog/google'
elsif azure?
require 'fog/azurerm'
end
end
def credentials def credentials
@credentials ||= options[:connection] || {} @credentials ||= options[:connection] || {}
end end
......
...@@ -15,9 +15,6 @@ RSpec.describe 'CarrierWave::Storage::Fog::File' do ...@@ -15,9 +15,6 @@ RSpec.describe 'CarrierWave::Storage::Fog::File' do
subject { CarrierWave::Storage::Fog::File.new(uploader, storage, test_filename) } subject { CarrierWave::Storage::Fog::File.new(uploader, storage, test_filename) }
before do before do
require 'fog/azurerm'
require 'fog/aws'
stub_object_storage(connection_params: connection_options, remote_directory: bucket_name) stub_object_storage(connection_params: connection_options, remote_directory: bucket_name)
allow(uploader).to receive(:fog_directory).and_return(bucket_name) allow(uploader).to receive(:fog_directory).and_return(bucket_name)
......
...@@ -36,46 +36,6 @@ RSpec.describe ObjectStorage::Config do ...@@ -36,46 +36,6 @@ RSpec.describe ObjectStorage::Config do
subject { described_class.new(raw_config.as_json) } subject { described_class.new(raw_config.as_json) }
describe '#load_provider' do
before do
subject.load_provider
end
context 'with AWS' do
it 'registers AWS as a provider' do
expect(Fog.providers.keys).to include(:aws)
end
end
context 'with Google' do
let(:credentials) do
{
provider: 'Google',
google_storage_access_key_id: 'GOOGLE_ACCESS_KEY_ID',
google_storage_secret_access_key: 'GOOGLE_SECRET_ACCESS_KEY'
}
end
it 'registers Google as a provider' do
expect(Fog.providers.keys).to include(:google)
end
end
context 'with Azure' do
let(:credentials) do
{
provider: 'AzureRM',
azure_storage_account_name: 'azuretest',
azure_storage_access_key: 'ABCD1234'
}
end
it 'registers AzureRM as a provider' do
expect(Fog.providers.keys).to include(:azurerm)
end
end
end
describe '#credentials' do describe '#credentials' do
it { expect(subject.credentials).to eq(credentials) } it { expect(subject.credentials).to eq(credentials) }
end end
......
...@@ -201,10 +201,6 @@ RSpec.describe ObjectStorage::DirectUpload do ...@@ -201,10 +201,6 @@ RSpec.describe ObjectStorage::DirectUpload do
end end
shared_examples 'a valid AzureRM upload' do shared_examples 'a valid AzureRM upload' do
before do
require 'fog/azurerm'
end
it_behaves_like 'a valid upload' it_behaves_like 'a valid upload'
it 'enables the Workhorse client' do it 'enables the Workhorse client' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment