Skip to content

Commit

Permalink
Merge pull request #49 from nicon89/gcloud_service_account
Browse files Browse the repository at this point in the history
Adding logic which disables google cloud registration if there's no K…
  • Loading branch information
maxisam authored Mar 24, 2023
2 parents 3ba048b + 3c6470f commit 366207a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions pkg/backup/gcloud.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ import (

func gCloudUpload(file string, plan config.Plan) (string, error) {

register := fmt.Sprintf("gcloud auth activate-service-account --key-file=%v",
plan.GCloud.KeyFilePath)

_, err := sh.Command("/bin/sh", "-c", register).CombinedOutput()
if err != nil {
return "", errors.Wrapf(err, "gcloud auth for plan %v failed", plan.Name)
if len(plan.GCloud.KeyFilePath) > 0 {
register := fmt.Sprintf("gcloud auth activate-service-account --key-file=%v",
plan.GCloud.KeyFilePath)
_, err := sh.Command("/bin/sh", "-c", register).CombinedOutput()
if err != nil {
return "", errors.Wrapf(err, "gcloud auth for plan %v failed", plan.Name)
}
}

upload := fmt.Sprintf("gsutil cp %v gs://%v",
Expand Down

0 comments on commit 366207a

Please sign in to comment.