Skip to content

Commit

Permalink
cherry pick #3654 to release-1.1 (#3655)
Browse files Browse the repository at this point in the history
Signed-off-by: ti-srebot <[email protected]>

Co-authored-by: Yilong Li <[email protected]>
  • Loading branch information
ti-srebot and dragonly authored Dec 27, 2020
1 parent 3c82347 commit db89860
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion cmd/backup-manager/app/util/remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ func NewStorageBackend(provider v1alpha1.StorageProvider) (*blob.Bucket, error)
}

// genStorageArgs returns the arg for --storage option and the remote/local path for br
// TODO: add unit test
func genStorageArgs(provider v1alpha1.StorageProvider) ([]string, error) {
st := util.GetStorageType(provider)
switch st {
Expand Down Expand Up @@ -212,7 +213,7 @@ func newGcsStorage(conf *gcsConfig) (*blob.Bucket, error) {
// newGcsStorageOption constructs the arg for --storage option and the remote path for br
func newGcsStorageOption(conf *gcsConfig) []string {
var gcsoptions []string
path := fmt.Sprintf("gcs://%s", path.Join(conf.bucket, conf.prefix))
path := fmt.Sprintf("gcs://%s/", path.Join(conf.bucket, conf.prefix))
gcsoptions = append(gcsoptions, fmt.Sprintf("--storage=%s", path))
if conf.storageClass != "" {
gcsoptions = append(gcsoptions, fmt.Sprintf("--gcs.storage-class=%s", conf.storageClass))
Expand Down
2 changes: 1 addition & 1 deletion cmd/backup-manager/app/util/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func GetStoragePath(backup *v1alpha1.Backup) (string, error) {
case v1alpha1.BackupStorageTypeGcs:
prefix = backup.Spec.StorageProvider.Gcs.Prefix
bucket = backup.Spec.StorageProvider.Gcs.Bucket
url = fmt.Sprintf("gcs://%s", path.Join(bucket, prefix))
url = fmt.Sprintf("gcs://%s/", path.Join(bucket, prefix))
return url, nil
case v1alpha1.BackupStorageTypeLocal:
prefix = backup.Spec.StorageProvider.Local.Prefix
Expand Down
2 changes: 1 addition & 1 deletion cmd/backup-manager/app/util/util_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ func TestGetRemotePath(t *testing.T) {
},
},
},
expect: "gcs://test1-demo1",
expect: "gcs://test1-demo1/",
},
{
name: "unknow storage type",
Expand Down

0 comments on commit db89860

Please sign in to comment.