diff --git a/apis/storage/v1alpha1/types.go b/apis/storage/v1alpha1/types.go index 1861ee2f..c07fba5a 100644 --- a/apis/storage/v1alpha1/types.go +++ b/apis/storage/v1alpha1/types.go @@ -124,6 +124,9 @@ type GCSSpec struct { } type AzureSpec struct { + // StorageAccount specifies the name of the Azure Storage Account + StorageAccount string `json:"storageAccount,omitempty"` + // Container specifies the name of the Azure Blob container that will be used as storage backend. Container string `json:"container,omitempty"` diff --git a/crds/storage.kubestash.com_backupstorages.yaml b/crds/storage.kubestash.com_backupstorages.yaml index 24cd70d2..58540ad3 100644 --- a/crds/storage.kubestash.com_backupstorages.yaml +++ b/crds/storage.kubestash.com_backupstorages.yaml @@ -2429,6 +2429,10 @@ spec: description: Secret specifies the name of the Secret that contains the access credential for this storage. type: string + storageAccount: + description: StorageAccount specifies the name of the Azure + Storage Account + type: string type: object b2: description: B2 specifies the storage information for B2 bucket diff --git a/pkg/restic/config.go b/pkg/restic/config.go index 77212751..1d1669c7 100644 --- a/pkg/restic/config.go +++ b/pkg/restic/config.go @@ -80,11 +80,12 @@ type DumpOptions struct { } type backend struct { - provider v1alpha1.StorageProvider - bucket string - endpoint string - region string - path string + provider v1alpha1.StorageProvider + bucket string + endpoint string + region string + path string + storageAccount string } type SetupOptions struct { diff --git a/pkg/restic/setup.go b/pkg/restic/setup.go index 8193979a..c719a505 100644 --- a/pkg/restic/setup.go +++ b/pkg/restic/setup.go @@ -174,9 +174,10 @@ func (w *ResticWrapper) setupEnv() error { r := fmt.Sprintf("azure:%s:/%s", w.config.bucket, filepath.Join(w.config.path, w.config.Directory)) w.sh.SetEnv(RESTIC_REPOSITORY, r) - if err := w.exportSecretKey(AZURE_ACCOUNT_NAME, false); err != nil { - return err + if w.config.storageAccount == "" { + return fmt.Errorf("storageAccount name is empty") } + w.sh.SetEnv(AZURE_ACCOUNT_NAME, w.config.storageAccount) if err := w.exportSecretKey(AZURE_ACCOUNT_KEY, false); err != nil { return err @@ -389,6 +390,7 @@ func (w *ResticWrapper) setBackupStorageVariables() error { if azure := bs.Spec.Storage.Azure; azure != nil { w.config.provider = v1alpha1.ProviderAzure + w.config.storageAccount = azure.StorageAccount w.config.bucket = azure.Container w.config.path = azure.Prefix w.config.MaxConnections = azure.MaxConnections