Skip to content

Commit

Permalink
Add Azure Support for restic (#5797)
Browse files Browse the repository at this point in the history
* Add Azure Support for restic

* Address review suggestion
  • Loading branch information
SupriyaKasten authored and Ilya Kislenko committed Jun 14, 2019
1 parent 013b425 commit ec60e05
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
6 changes: 5 additions & 1 deletion pkg/function/backup_data.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,11 @@ func validateProfile(profile *param.Profile) error {
if len(profile.Credential.KeyPair.Secret) == 0 {
return errors.New("Secret access key is not set")
}
if profile.Location.Type != crv1alpha1.LocationTypeS3Compliant && profile.Location.Type != crv1alpha1.LocationTypeGCS {
switch profile.Location.Type {
case crv1alpha1.LocationTypeS3Compliant:
case crv1alpha1.LocationTypeGCS:
case crv1alpha1.LocationTypeAzure:
default:
return errors.New("Location type not supported")
}
return nil
Expand Down
10 changes: 6 additions & 4 deletions pkg/location/location.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,12 @@ import (
)

const (
AWSAccessKeyID = "AWS_ACCESS_KEY_ID"
AWSSecretAccessKey = "AWS_SECRET_ACCESS_KEY"
GoogleCloudCreds = "GOOGLE_APPLICATION_CREDENTIALS"
GoogleProjectId = "GOOGLE_PROJECT_ID"
AWSAccessKeyID = "AWS_ACCESS_KEY_ID"
AWSSecretAccessKey = "AWS_SECRET_ACCESS_KEY"
GoogleCloudCreds = "GOOGLE_APPLICATION_CREDENTIALS"
GoogleProjectId = "GOOGLE_PROJECT_ID"
AzureStorageAccount = "AZURE_ACCOUNT_NAME"
AzureStorageKey = "AZURE_ACCOUNT_KEY"
)

// Write pipes data from `in` into the location specified by `profile` and `suffix`.
Expand Down
8 changes: 8 additions & 0 deletions pkg/restic/restic.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,14 @@ func resticArgs(profile *param.Profile, repository, encryptionKey string) []stri
fmt.Sprintf("export %s=gs:%s/\n", ResticRepository, strings.Replace(repository, "/", ":/", 1)),
ResticCommand,
}
case crv1alpha1.LocationTypeAzure:
return []string{
fmt.Sprintf("export %s=%s\n", location.AzureStorageAccount, profile.Credential.KeyPair.ID),
fmt.Sprintf("export %s=%s\n", location.AzureStorageKey, profile.Credential.KeyPair.Secret),
fmt.Sprintf("export %s=%s\n", ResticPassword, encryptionKey),
fmt.Sprintf("export %s=azure:%s/\n", ResticRepository, strings.Replace(repository, "/", ":/", 1)),
ResticCommand,
}
}
return nil
}
Expand Down

0 comments on commit ec60e05

Please sign in to comment.