Skip to content

Commit

Permalink
read GOOGLE_APPLICATION_CREDENTIALS_JSON if it is set
Browse files Browse the repository at this point in the history
  • Loading branch information
dynamix committed Oct 5, 2021
1 parent c122017 commit 090e652
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions gcs.go
Expand Up @@ -37,6 +37,9 @@ type GcsFs struct {
// You can provide additional options to be passed to the client creation, as per
// cloud.google.com/go/storage documentation
func NewGcsFS(ctx context.Context, opts ...option.ClientOption) (Fs, error) {
if json := os.Getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON"); json != "" {
opts = append(opts, option.WithCredentialsJSON([]byte(json)))
}
client, err := storage.NewClient(ctx, opts...)
if err != nil {
return nil, err
Expand Down

0 comments on commit 090e652

Please sign in to comment.