Skip to content

Commit

Permalink
🧹 Log if gcp clients fail to init. (#4630)
Browse files Browse the repository at this point in the history
Signed-off-by: Preslav <preslav@mondoo.com>
  • Loading branch information
preslavgerchev authored Sep 4, 2024
1 parent a5e151b commit 528df76
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions providers/gcp/connection/clients.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"net/http"

"github.com/hashicorp/go-cleanhttp"
"github.com/pkg/errors"
"github.com/rs/zerolog/log"
"go.mondoo.com/cnquery/v11/providers-sdk/v1/vault"
"golang.org/x/oauth2"
Expand Down Expand Up @@ -68,13 +69,13 @@ func serviceAccountAuth(ctx context.Context, subject string, serviceAccount []by

credentials, err := googleoauth.CredentialsFromJSONWithParams(ctx, serviceAccount, credParams)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to create google credentials")
}

cleanCtx := context.WithValue(ctx, oauth2.HTTPClient, cleanhttp.DefaultClient())
client, _, err := transport.NewHTTPClient(cleanCtx, option.WithTokenSource(credentials.TokenSource))
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to create google http client")
}

return client, nil
Expand Down

0 comments on commit 528df76

Please sign in to comment.