mirror of
https://github.com/prometheus/prometheus.git
synced 2026-06-09 08:32:26 -04:00
Replace deprecated google.CredentialsFromJSON with option.WithAuthCredentialsFile
Signed-off-by: Ganesh Vernekar <ganesh.vernekar@reddit.com>
This commit is contained in:
parent
847e474bf4
commit
0ede19e2ee
1 changed files with 1 additions and 10 deletions
|
|
@ -19,7 +19,6 @@ import (
|
|||
"context"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"golang.org/x/oauth2/google"
|
||||
"google.golang.org/api/option"
|
||||
|
|
@ -42,15 +41,7 @@ func NewRoundTripper(cfg *Config, next http.RoundTripper) (http.RoundTripper, er
|
|||
option.WithScopes(scopes),
|
||||
}
|
||||
if cfg.CredentialsFile != "" {
|
||||
credBytes, err := os.ReadFile(cfg.CredentialsFile)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error reading Google credentials file: %w", err)
|
||||
}
|
||||
creds, err := google.CredentialsFromJSON(ctx, credBytes, scopes)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error parsing Google credentials file: %w", err)
|
||||
}
|
||||
opts = append(opts, option.WithCredentials(creds))
|
||||
opts = append(opts, option.WithAuthCredentialsFile(option.ServiceAccount, cfg.CredentialsFile))
|
||||
} else {
|
||||
creds, err := google.FindDefaultCredentials(ctx, scopes)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Reference in a new issue