Skip to content

Commit

Permalink
blob/gcsblob: Don't hard-fail if no DefaultCredentials are found (#3306)
Browse files Browse the repository at this point in the history
  • Loading branch information
vangent authored Aug 21, 2023
1 parent 1b4bd15 commit 62841e7
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions blob/gcsblob/gcsblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,16 @@ func (o *lazyCredsOpener) OpenBucketURL(ctx context.Context, u *url.URL) (*blob.
var err error
creds, err = gcp.DefaultCredentials(ctx)
if err != nil {
o.err = err
return
fmt.Printf("Warning: unable to load GCP Default Credentials: %v", err)
// Use empty credentials, in case the user isn't going to actually use
// them; e.g., getting signed URLs with GoogleAccessID=-.
creds = &google.Credentials{}
}

// Populate default values from credentials files, where available.
opts.GoogleAccessID, opts.PrivateKey = readDefaultCredentials(creds.JSON)

// else, on GCE, at least get the instance's main service account.
// ... else, on GCE, at least get the instance's main service account.
if opts.GoogleAccessID == "" && metadata.OnGCE() {
mc := metadata.NewClient(nil)
opts.GoogleAccessID, _ = mc.Email("")
Expand Down

0 comments on commit 62841e7

Please sign in to comment.