Commit d53471ce authored by Stan Hu's avatar Stan Hu

Specify Azure custom domain in Go Cloud query string

In https://gitlab.com/gitlab-org/gitlab/-/merge_requests/40694, we made
some changes to the Workhorse direct upload API to support custom
domains in Azure.

While this worked, it made it quite complicated for Workhorse to handle
since the Go Cloud library (https://gocloud.dev/howto/blob/) expects all
the object store information to be available in a single URL.

To simplify this, we added a custom storage domain as a `domain` query
parameter in
https://gitlab.com/gitlab-org/gitlab-workhorse/-/merge_requests/593.
parent 3aefe1d1
......@@ -98,16 +98,19 @@ module ObjectStorage
RemoteTempObjectID: object_name,
ObjectStorage: {
Provider: 'AzureRM',
AzureConfig: {
StorageDomain: config.azure_storage_domain
},
GoCloudConfig: {
URL: "azblob://#{bucket_name}"
URL: azure_gocloud_url
}
}
}
end
def azure_gocloud_url
url = "azblob://#{bucket_name}"
url += "?domain=#{config.azure_storage_domain}" if config.azure_storage_domain.present?
url
end
def use_workhorse_s3_client?
return false unless Feature.enabled?(:use_workhorse_s3_client, default_enabled: true)
return false unless config.use_iam_profile? || config.consolidated_settings?
......
......@@ -211,8 +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}" })
expect(subject[:ObjectStorage][:GoCloudConfig]).to eq({ URL: gocloud_url })
end
end
......@@ -399,6 +398,7 @@ RSpec.describe ObjectStorage::DirectUpload do
let(:has_length) { false }
let(:storage_domain) { nil }
let(:storage_url) { 'https://azuretest.blob.core.windows.net' }
let(:gocloud_url) { "azblob://#{bucket_name}" }
it_behaves_like 'a valid AzureRM upload'
it_behaves_like 'a valid upload without multipart data'
......@@ -406,6 +406,7 @@ RSpec.describe ObjectStorage::DirectUpload do
context 'when a custom storage domain is used' do
let(:storage_domain) { 'blob.core.chinacloudapi.cn' }
let(:storage_url) { "https://azuretest.#{storage_domain}" }
let(:gocloud_url) { "azblob://#{bucket_name}?domain=#{storage_domain}" }
before do
credentials[:azure_storage_domain] = storage_domain
......
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