Skip to content

Commit 8a922ae

Browse files
snapshot upload: use option.WithAuthCredentialsFile
google.golang.org/api v0.264.0 deprecates option.WithCredentialsFile (staticcheck SA1019), which failed the go-lint job. The credentials file is a service account key, so load it as that type explicitly. Amp-Thread-ID: https://ampcode.com/threads/T-01a18b16-df86-7399-a300-979289761a30 Co-authored-by: Amp <amp@ampcode.com>
1 parent e9add8e commit 8a922ae

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎cmd/src/snapshot_upload.go‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,10 @@ func createGcsClient(flagSet *flag.FlagSet, credentialsPath string) (*gcsClient,
205205
out := output.NewOutput(flagSet.Output(), output.OutputOpts{Verbose: *verbose})
206206

207207
// https://pkg.go.dev/cloud.google.com/go/storage#section-readme
208-
client, err := storage.NewClient(ctx, option.WithCredentialsFile(credentialsPath))
208+
// The credentials file Sourcegraph provides is a service account key, so
209+
// only accept that type; option.WithCredentialsFile is deprecated because
210+
// it loads any credential type without validation.
211+
client, err := storage.NewClient(ctx, option.WithAuthCredentialsFile(option.ServiceAccount, credentialsPath))
209212

210213
if err != nil {
211214
return nil, errors.Wrap(err, "create Google Cloud Storage client")

0 commit comments

Comments
 (0)