diff --git a/README.md b/README.md index 0b31e7c..38119cc 100644 --- a/README.md +++ b/README.md @@ -232,6 +232,7 @@ uploaders: accountName: accountKey: container: + cloudDomain: google: bucket: local: @@ -266,6 +267,7 @@ uploaders: - `accountName` **(required)** - the account name of the storage account - `accountKey` **(required)** - the account key of the storage account - `containerName` **(required)** - the name of the blob container to write to +- `cloudDomain` *(default: blob.core.windows.net) - domain of the cloud-service to use #### Google Storage diff --git a/internal/app/vault_raft_snapshot_agent/config_test.go b/internal/app/vault_raft_snapshot_agent/config_test.go index c4e82f8..8424e29 100644 --- a/internal/app/vault_raft_snapshot_agent/config_test.go +++ b/internal/app/vault_raft_snapshot_agent/config_test.go @@ -115,6 +115,7 @@ func TestReadCompleteConfig(t *testing.T) { AccountName: "test-account", AccountKey: "test-key", ContainerName: "test-container", + CloudDomain: "blob.core.chinacloudapi.cn", }, GCP: upload.GCPConfig{ Bucket: "test-bucket", @@ -163,7 +164,10 @@ func TestReadConfigSetsDefaultValues(t *testing.T) { Credentials: upload.AWSCredentialsConfig{Empty: true}, Empty: true, }, - Azure: upload.AzureConfig{Empty: true}, + Azure: upload.AzureConfig{ + CloudDomain: "blob.core.windows.net", + Empty: true, + }, GCP: upload.GCPConfig{Empty: true}, Local: upload.LocalConfig{ Path: ".", diff --git a/internal/app/vault_raft_snapshot_agent/upload/azure.go b/internal/app/vault_raft_snapshot_agent/upload/azure.go index c293efc..29647df 100644 --- a/internal/app/vault_raft_snapshot_agent/upload/azure.go +++ b/internal/app/vault_raft_snapshot_agent/upload/azure.go @@ -13,6 +13,7 @@ type AzureConfig struct { AccountName string `validate:"required_if=Empty false"` AccountKey string `validate:"required_if=Empty false"` ContainerName string `mapstructure:"container" validate:"required_if=Empty false"` + CloudDomain string `default:"blob.core.windows.net" validate:"required_if=Empty false"` Empty bool } @@ -27,7 +28,7 @@ func createAzureUploader(config AzureConfig) (*uploader[*container.BlobItem], er return nil, fmt.Errorf("invalid credentials for azure: %w", err) } - serviceURL := fmt.Sprintf("https://%s.blob.core.windows.net/", config.AccountName) + serviceURL := fmt.Sprintf("https://%s.%s/", config.AccountName, config.CloudDomain) client, err := azblob.NewClientWithSharedKeyCredential(serviceURL, credential, nil) if err != nil { return nil, fmt.Errorf("failed to create azure client: %w", err) diff --git a/testdata/complete.yaml b/testdata/complete.yaml index c6e777a..711730b 100644 --- a/testdata/complete.yaml +++ b/testdata/complete.yaml @@ -29,6 +29,7 @@ uploaders: accountName: test-account accountKey: test-key container: test-container + cloudDomain: blob.core.chinacloudapi.cn google: bucket: test-bucket local: