Commit 9a206b6f authored by Stan Hu's avatar Stan Hu

Support custom Azure Blob Storage domains

Users of Azure Blob Storage, particularly those in China, may need to
customize the Azure endpoint. This change introduces a
`azure_storage_domain` parameter to be passed in the connection storage
settings. By default, `blob.core.windows.net` will be used. Example
other mappings:

1. China: blob.core.chinacloudapi.cn
2. US Government: blob.core.usgovcloudapi.net
3. Germany: blob.cloudapi.de

This change requires Workhorse changes as well:
https://gitlab.com/gitlab-org/gitlab-workhorse/-/merge_requests/575.
Otherwise, the default domain will be used.

Documentation is in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40693.
parent 91950c18
......@@ -119,7 +119,7 @@ gem 'fog-local', '~> 0.6'
gem 'fog-openstack', '~> 1.0'
gem 'fog-rackspace', '~> 0.1.1'
gem 'fog-aliyun', '~> 0.3'
gem 'gitlab-fog-azure-rm', '~> 0.7', require: false
gem 'gitlab-fog-azure-rm', '~> 0.8', require: false
# for Google storage
gem 'google-api-client', '~> 0.33'
......
......@@ -419,7 +419,7 @@ GEM
github-markup (1.7.0)
gitlab-chronic (0.10.5)
numerizer (~> 0.2)
gitlab-fog-azure-rm (0.7.0)
gitlab-fog-azure-rm (0.8.1)
azure-storage (~> 0.15.0.preview)
fog-core (= 2.1.0)
fog-json (~> 1.2.0)
......@@ -1303,7 +1303,7 @@ DEPENDENCIES
gitaly (~> 13.3.0.pre.rc1)
github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5)
gitlab-fog-azure-rm (~> 0.7)
gitlab-fog-azure-rm (~> 0.8)
gitlab-labkit (= 0.12.1)
gitlab-license (~> 1.0)
gitlab-mail_room (~> 0.0.6)
......
---
title: Support custom Azure Blob Storage domains
merge_request: 40694
author:
type: added
......@@ -54,6 +54,12 @@ module ObjectStorage
end
# End AWS-specific options
# Begin Azure-specific options
def azure_storage_domain
credentials[:azure_storage_domain]
end
# End Azure-specific options
def google?
provider == 'Google'
end
......
......@@ -98,6 +98,9 @@ module ObjectStorage
RemoteTempObjectID: object_name,
ObjectStorage: {
Provider: 'AzureRM',
AzureConfig: {
StorageDomain: config.azure_storage_domain
},
GoCloudConfig: {
URL: "azblob://#{bucket_name}"
}
......
......@@ -211,6 +211,7 @@ RSpec.describe ObjectStorage::DirectUpload do
expect(subject[:UseWorkhorseClient]).to be true
expect(subject[:RemoteTempObjectID]).to eq(object_name)
expect(subject[:ObjectStorage][:Provider]).to eq('AzureRM')
expect(subject[:ObjectStorage][:AzureConfig][:StorageDomain]).to eq(storage_domain)
expect(subject[:ObjectStorage][:GoCloudConfig]).to eq({ URL: "azblob://#{bucket_name}" })
end
end
......@@ -395,20 +396,22 @@ RSpec.describe ObjectStorage::DirectUpload do
}
end
let(:has_length) { false }
let(:storage_domain) { nil }
let(:storage_url) { 'https://azuretest.blob.core.windows.net' }
context 'when length is known' do
let(:has_length) { true }
it_behaves_like 'a valid AzureRM upload'
it_behaves_like 'a valid upload without multipart data'
it_behaves_like 'a valid AzureRM upload'
it_behaves_like 'a valid upload without multipart data'
end
context 'when a custom storage domain is used' do
let(:storage_domain) { 'blob.core.chinacloudapi.cn' }
let(:storage_url) { "https://azuretest.#{storage_domain}" }
context 'when length is unknown' do
let(:has_length) { false }
before do
credentials[:azure_storage_domain] = storage_domain
end
it_behaves_like 'a valid AzureRM upload'
it_behaves_like 'a valid upload without multipart data'
end
end
end
......
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