Skip to content

Commit e0f9d8a

Browse files
committed
feat: add GOOGLE_APPLICATION_CREDENTIALS_JSON
1 parent fb3d3a7 commit e0f9d8a

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

Gopkg.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cmd/bctx/main.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"github.com/docker/docker/pkg/archive"
2020
"github.com/docker/docker/pkg/idtools"
2121
"golang.org/x/xerrors"
22+
"google.golang.org/api/option"
2223
)
2324

2425
func main() {
@@ -152,7 +153,11 @@ func writer(dest string) (io.WriteCloser, string, error) {
152153
}
153154
switch u.Scheme {
154155
case "gs":
155-
storageClient, err := storage.NewClient(ctx)
156+
var opts []option.ClientOption
157+
if cred := os.Getenv("GOOGLE_APPLICATION_CREDENTIALS_JSON"); cred != "" {
158+
opts = append(opts, option.WithCredentialsJSON([]byte(cred)))
159+
}
160+
storageClient, err := storage.NewClient(ctx, opts...)
156161
if err != nil {
157162
return nil, "", xerrors.Errorf("failed to create gcs client: %w", err)
158163
}

0 commit comments

Comments
 (0)