Skip to content

Commit

Permalink
Fix lint comments
Browse files Browse the repository at this point in the history
  • Loading branch information
deadlycoconuts committed Mar 27, 2023
1 parent 85e9db0 commit 1cc4b28
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions api/pkg/auth/google_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ func InitGoogleClient(ctx context.Context, audience string) (*http.Client, error
return nil, err
}

if len(cred.JSON) < 0 {
if len(cred.JSON) == 0 {
return nil, fmt.Errorf("no default credentials found")
}

Expand All @@ -66,16 +66,19 @@ func InitGoogleClient(ctx context.Context, audience string) (*http.Client, error

if f.Type == serviceAccountKey {
return idtoken.NewClient(ctx, audience)
} else {
defaultTokenSource, err := google.DefaultTokenSource(ctx)
tokenSource := oauth2.ReuseTokenSource(nil, &idTokenSource{TokenSource: defaultTokenSource})
}

var opts []idtoken.ClientOption
opts = append(opts, option.WithTokenSource(tokenSource), internaloption.SkipDialSettingsValidation())
t, err := htransport.NewTransport(ctx, http.DefaultTransport, opts...)
if err != nil {
return nil, err
}
return &http.Client{Transport: t}, nil
defaultTokenSource, err := google.DefaultTokenSource(ctx)
if err != nil {
return nil, err
}
tokenSource := oauth2.ReuseTokenSource(nil, &idTokenSource{TokenSource: defaultTokenSource})

var opts []idtoken.ClientOption
opts = append(opts, option.WithTokenSource(tokenSource), internaloption.SkipDialSettingsValidation())
t, err := htransport.NewTransport(ctx, http.DefaultTransport, opts...)
if err != nil {
return nil, err
}
return &http.Client{Transport: t}, nil
}

0 comments on commit 1cc4b28

Please sign in to comment.