Skip to content

Commit

Permalink
Add storage account name
Browse files Browse the repository at this point in the history
Signed-off-by: Md. Ishtiaq Islam <[email protected]>
  • Loading branch information
ishtiaqhimel committed Oct 2, 2023
1 parent b9eb063 commit f634457
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
3 changes: 3 additions & 0 deletions apis/storage/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`

Expand Down
4 changes: 4 additions & 0 deletions crds/storage.kubestash.com_backupstorages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions pkg/restic/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 4 additions & 2 deletions pkg/restic/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit f634457

Please sign in to comment.