Skip to content

Commit

Permalink
fix: reverted tracing ccode in client code for bigquery and gcloud (#346
Browse files Browse the repository at this point in the history
)

* fix: reverted tracing ccode in client code for bigquery and gcloud

* fix: test cases

* fix: revert code for gcs client
  • Loading branch information
utsav14nov authored Jan 13, 2023
1 parent 9bc45ee commit ba34b75
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 19 deletions.
7 changes: 1 addition & 6 deletions plugins/providers/bigquery/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (

bq "cloud.google.com/go/bigquery"
"github.com/odpf/guardian/domain"
"github.com/odpf/guardian/pkg/tracing"
bqApi "google.golang.org/api/bigquery/v2"
"google.golang.org/api/iam/v1"
"google.golang.org/api/iterator"
Expand All @@ -24,11 +23,7 @@ type bigQueryClient struct {

func newBigQueryClient(projectID string, credentialsJSON []byte) (*bigQueryClient, error) {
ctx := context.Background()
clientOpts := []option.ClientOption{
option.WithCredentialsJSON(credentialsJSON),
option.WithHTTPClient(tracing.NewHttpClient("BigQueryHttpClient")),
}
client, err := bq.NewClient(ctx, projectID, clientOpts...)
client, err := bq.NewClient(ctx, projectID, option.WithCredentialsJSON(credentialsJSON))
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/providers/bigquery/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1033,7 +1033,7 @@ func (s *BigQueryProviderTestSuite) TestListAccess() {
},
}, []*domain.Resource{})

s.EqualError(err, "initializing bigquery client: invalid character 'i' looking for beginning of value")
s.EqualError(err, "initializing bigquery client: bigquery: constructing client: invalid character 'i' looking for beginning of value")
})

s.Run("return nil error on success", func() {
Expand Down
7 changes: 1 addition & 6 deletions plugins/providers/gcloudiam/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"strings"

"github.com/odpf/guardian/domain"
"github.com/odpf/guardian/pkg/tracing"
"google.golang.org/api/cloudresourcemanager/v1"
"google.golang.org/api/iam/v1"
"google.golang.org/api/option"
Expand All @@ -25,11 +24,7 @@ type iamClient struct {

func newIamClient(credentialsJSON []byte, resourceName string) (*iamClient, error) {
ctx := context.Background()
opts := []option.ClientOption{
option.WithCredentialsJSON(credentialsJSON),
option.WithHTTPClient(tracing.NewHttpClient("GCloudIAMHttpClient")),
}
cloudResourceManagerService, err := cloudresourcemanager.NewService(ctx, opts...)
cloudResourceManagerService, err := cloudresourcemanager.NewService(ctx, option.WithCredentialsJSON(credentialsJSON))
if err != nil {
return nil, err
}
Expand Down
7 changes: 1 addition & 6 deletions plugins/providers/gcs/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"cloud.google.com/go/iam"
"cloud.google.com/go/storage"
"github.com/odpf/guardian/pkg/tracing"
"google.golang.org/api/iterator"
"google.golang.org/api/option"
)
Expand All @@ -24,11 +23,7 @@ type gcsClient struct {
}

func newGCSClient(projectID string, credentialsJSON []byte) (*gcsClient, error) {
opts := []option.ClientOption{
option.WithCredentialsJSON(credentialsJSON),
option.WithHTTPClient(tracing.NewHttpClient("GcsHttpClient")),
}
client, err := storage.NewClient(context.TODO(), opts...)
client, err := storage.NewClient(context.TODO(), option.WithCredentialsJSON(credentialsJSON))
if err != nil {
return nil, err
}
Expand Down

0 comments on commit ba34b75

Please sign in to comment.