Skip to content

Commit

Permalink
chore(auth): fix staticcheck errors (#10780)
Browse files Browse the repository at this point in the history
  • Loading branch information
julieqiu authored Aug 29, 2024
1 parent 897539d commit be2d56d
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions auth/credentials/detect.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ func DetectDefault(opts *DetectOptions) (*auth.Credentials, error) {
if OnGCE() {
return auth.NewCredentials(&auth.CredentialsOptions{
TokenProvider: computeTokenProvider(opts),
ProjectIDProvider: auth.CredentialsPropertyFunc(func(context.Context) (string, error) {
return metadata.ProjectID()
ProjectIDProvider: auth.CredentialsPropertyFunc(func(ctx context.Context) (string, error) {
return metadata.ProjectIDWithContext(ctx)
}),
UniverseDomainProvider: &internal.ComputeUniverseDomainProvider{},
}), nil
Expand Down
4 changes: 2 additions & 2 deletions auth/credentials/idtoken/compute.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ func computeCredentials(opts *Options) (*auth.Credentials, error) {
TokenProvider: auth.NewCachedTokenProvider(tp, &auth.CachedTokenProviderOptions{
ExpireEarly: 5 * time.Minute,
}),
ProjectIDProvider: auth.CredentialsPropertyFunc(func(context.Context) (string, error) {
return metadata.ProjectID()
ProjectIDProvider: auth.CredentialsPropertyFunc(func(ctx context.Context) (string, error) {
return metadata.ProjectIDWithContext(ctx)
}),
UniverseDomainProvider: &internal.ComputeUniverseDomainProvider{},
}), nil
Expand Down
2 changes: 1 addition & 1 deletion auth/grpctransport/grpctransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ func dial(ctx context.Context, secure bool, opts *Options) (*grpc.ClientConn, er
grpcOpts = addOCStatsHandler(grpcOpts, opts)
grpcOpts = append(grpcOpts, opts.GRPCDialOpts...)

return grpc.DialContext(ctx, endpoint, grpcOpts...)
return grpc.NewClient(endpoint, grpcOpts...)
}

// grpcKeyProvider satisfies https://pkg.go.dev/google.golang.org/grpc/credentials#PerRPCCredentials.
Expand Down
2 changes: 1 addition & 1 deletion auth/grpctransport/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func TestClose(t *testing.T) {

pool := &roundRobinConnPool{}
for i := 0; i < 4; i++ {
conn, err := grpc.Dial(l.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
conn, err := grpc.NewClient(l.Addr().String(), grpc.WithTransportCredentials(insecure.NewCredentials()))
if err != nil {
t.Fatal(err)
}
Expand Down
3 changes: 2 additions & 1 deletion auth/internal/transport/s2a.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package transport

import (
"context"
"encoding/json"
"fmt"
"log"
Expand Down Expand Up @@ -84,7 +85,7 @@ func getMetadataMTLSAutoConfig() {
}

var httpGetMetadataMTLSConfig = func() (string, error) {
return metadata.Get(configEndpointSuffix)
return metadata.GetWithContext(context.Background(), configEndpointSuffix)
}

func queryConfig() (*mtlsConfig, error) {
Expand Down

0 comments on commit be2d56d

Please sign in to comment.