diff --git a/pkg/function/backup_data.go b/pkg/function/backup_data.go index b27e6341ce..eec879f7a5 100644 --- a/pkg/function/backup_data.go +++ b/pkg/function/backup_data.go @@ -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 diff --git a/pkg/location/location.go b/pkg/location/location.go index f03252ae01..3f595d1366 100644 --- a/pkg/location/location.go +++ b/pkg/location/location.go @@ -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`. diff --git a/pkg/restic/restic.go b/pkg/restic/restic.go index a8ae1cd4a0..8395c274f7 100644 --- a/pkg/restic/restic.go +++ b/pkg/restic/restic.go @@ -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 }