mirror of https://github.com/spf13/afero.git
read GOOGLE_APPLICATION_CREDENTIALS_JSON if it is set
This commit is contained in:
parent
c1220175da
commit
090e652a76
3
gcs.go
3
gcs.go
|
@ -37,6 +37,9 @@ type GcsFs struct {
|
||||||
// You can provide additional options to be passed to the client creation, as per
|
// You can provide additional options to be passed to the client creation, as per
|
||||||
// cloud.google.com/go/storage documentation
|
// cloud.google.com/go/storage documentation
|
||||||
func NewGcsFS(ctx context.Context, opts ...option.ClientOption) (Fs, error) {
|
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...)
|
client, err := storage.NewClient(ctx, opts...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Reference in New Issue