Skip to content

Commit

Permalink
Azure cloud domain (#8)
Browse files Browse the repository at this point in the history
* allow configuration of azure-cloud-domain (based on Lucretius#26)

---------

Co-authored-by: Karsten Kraus <[email protected]>
  • Loading branch information
Argelbargel and Karsten Kraus authored Sep 14, 2023
1 parent 7131124 commit 50ee232
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ uploaders:
accountName: <name>
accountKey: <key>
container: <container>
cloudDomain: <domain>
google:
bucket: <bucket>
local:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion internal/app/vault_raft_snapshot_agent/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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: ".",
Expand Down
3 changes: 2 additions & 1 deletion internal/app/vault_raft_snapshot_agent/upload/azure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions testdata/complete.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ uploaders:
accountName: test-account
accountKey: test-key
container: test-container
cloudDomain: blob.core.chinacloudapi.cn
google:
bucket: test-bucket
local:
Expand Down

0 comments on commit 50ee232

Please sign in to comment.