diff --git a/weed/remote_storage/gcs/gcs_storage_client.go b/weed/remote_storage/gcs/gcs_storage_client.go index b92f81b0f..2d090ae6e 100644 --- a/weed/remote_storage/gcs/gcs_storage_client.go +++ b/weed/remote_storage/gcs/gcs_storage_client.go @@ -38,26 +38,26 @@ func (s gcsRemoteStorageMaker) Make(conf *remote_pb.RemoteConf) (remote_storage. googleApplicationCredentials := conf.GcsGoogleApplicationCredentials if googleApplicationCredentials == "" { - found := false - googleApplicationCredentials, found = os.LookupEnv("GOOGLE_APPLICATION_CREDENTIALS") - if !found { - return nil, fmt.Errorf("need to specific GOOGLE_APPLICATION_CREDENTIALS env variable") + if creds, found := os.LookupEnv("GOOGLE_APPLICATION_CREDENTIALS"); found { + googleApplicationCredentials = creds + } else { + glog.Warningf("no GOOGLE_APPLICATION_CREDENTIALS env variable found, falling back to Application Default Credentials") } } projectID := conf.GcsProjectId if projectID == "" { - found := false - projectID, found = os.LookupEnv("GOOGLE_CLOUD_PROJECT") - if !found { - glog.Warningf("need to specific GOOGLE_CLOUD_PROJECT env variable") + if pid, found := os.LookupEnv("GOOGLE_CLOUD_PROJECT"); found { + projectID = pid + } else { + glog.Warningf("need to specify GOOGLE_CLOUD_PROJECT env variable") } } - googleApplicationCredentials = util.ResolvePath(googleApplicationCredentials) - var clientOpts []option.ClientOption + if googleApplicationCredentials != "" { + googleApplicationCredentials = util.ResolvePath(googleApplicationCredentials) var data []byte var err error if strings.HasPrefix(googleApplicationCredentials, "{") {