Skip to content

Commit

Permalink
Handle Azure URLs for chinacloud
Browse files Browse the repository at this point in the history
  • Loading branch information
itaiad200 committed Feb 27, 2024
1 parent e14c7f3 commit 48ecdfa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/block/azure/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,8 +562,8 @@ func (a *Adapter) CompleteMultiPartUpload(ctx context.Context, obj block.ObjectP

func (a *Adapter) GetStorageNamespaceInfo() block.StorageNamespaceInfo {
info := block.DefaultStorageNamespaceInfo(block.BlockstoreTypeAzure)
info.ImportValidityRegex = `^https?://[a-z0-9_-]+\.(blob|adls)\.core\.windows\.net` // added adls for import hint validation in UI
info.ValidityRegex = `^https?://[a-z0-9_-]+\.blob\.core\.windows\.net`
info.ImportValidityRegex = `^https?://[a-z0-9_-]+\.(blob|adls)\.core\.(windows\.net|chinacloudapi\.cn)` // added adls for import hint validation in UI
info.ValidityRegex = `^https?://[a-z0-9_-]+\.blob\.core\.(windows\.net|chinacloudapi\.cn)`
info.Example = "https://mystorageaccount.blob.core.windows.net/mycontainer/"
if a.disablePreSigned {
info.PreSignSupport = false
Expand Down
15 changes: 15 additions & 0 deletions pkg/block/azure/adapter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ func TestAdapterNamespace(t *testing.T) {
Namespace: "https://test.blob.core.windows.net/container1/repo1",
Success: true,
},
{
Name: "valid_https_china",
Namespace: "https://test.blob.core.chinacloudapi.cn/container1/repo1",
Success: true,
},
{
Name: "valid_http",
Namespace: "http://test.blob.core.windows.net/container1/repo1",
Expand All @@ -75,6 +80,16 @@ func TestAdapterNamespace(t *testing.T) {
Namespace: "this is a bad string",
Success: false,
},
{
Name: "invalid_https_china_mix_1",
Namespace: "https://test.blob.core.chinacloudapi.net/container1/repo1",
Success: false,
},
{
Name: "invalid_https_china_mix_2",
Namespace: "https://test.blob.core.windows.cn/container1/repo1",
Success: false,
},
}
for _, tt := range tests {
t.Run(tt.Name, func(t *testing.T) {
Expand Down

0 comments on commit 48ecdfa

Please sign in to comment.