From 66ace6c95689fd06cb467069d8ec0f5ddb8ac695 Mon Sep 17 00:00:00 2001 From: Cody Oss <6331106+codyoss@users.noreply.github.com> Date: Wed, 24 Jul 2024 15:18:21 -0500 Subject: [PATCH] feat: move storage, bigquery, and compute to new auth lib (#2695) All other clients in this repo have been exercising the new library for almost 3 months now. I believe things to be stable so we should move the remaining libraries. --- bigquery/v2/bigquery-gen.go | 1 + compute/v0.alpha/compute-gen.go | 1 + compute/v0.beta/compute-gen.go | 1 + compute/v1/compute-gen.go | 1 + google-api-go-generator/gen.go | 14 ++------------ storage/v1/storage-gen.go | 1 + 6 files changed, 7 insertions(+), 12 deletions(-) diff --git a/bigquery/v2/bigquery-gen.go b/bigquery/v2/bigquery-gen.go index ec0458f3ac2..f7f76e03eb4 100644 --- a/bigquery/v2/bigquery-gen.go +++ b/bigquery/v2/bigquery-gen.go @@ -145,6 +145,7 @@ func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, err opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) + opts = append(opts, internaloption.EnableNewAuthLibrary()) client, endpoint, err := htransport.NewClient(ctx, opts...) if err != nil { return nil, err diff --git a/compute/v0.alpha/compute-gen.go b/compute/v0.alpha/compute-gen.go index 3c4ac294300..4aed399d246 100644 --- a/compute/v0.alpha/compute-gen.go +++ b/compute/v0.alpha/compute-gen.go @@ -137,6 +137,7 @@ func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, err opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) + opts = append(opts, internaloption.EnableNewAuthLibrary()) client, endpoint, err := htransport.NewClient(ctx, opts...) if err != nil { return nil, err diff --git a/compute/v0.beta/compute-gen.go b/compute/v0.beta/compute-gen.go index 23a0abfaf95..89e91dc78c1 100644 --- a/compute/v0.beta/compute-gen.go +++ b/compute/v0.beta/compute-gen.go @@ -137,6 +137,7 @@ func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, err opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) + opts = append(opts, internaloption.EnableNewAuthLibrary()) client, endpoint, err := htransport.NewClient(ctx, opts...) if err != nil { return nil, err diff --git a/compute/v1/compute-gen.go b/compute/v1/compute-gen.go index 29abc286d58..e07038fe97f 100644 --- a/compute/v1/compute-gen.go +++ b/compute/v1/compute-gen.go @@ -137,6 +137,7 @@ func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, err opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) + opts = append(opts, internaloption.EnableNewAuthLibrary()) client, endpoint, err := htransport.NewClient(ctx, opts...) if err != nil { return nil, err diff --git a/google-api-go-generator/gen.go b/google-api-go-generator/gen.go index 06068115d9b..7fa66d717f3 100644 --- a/google-api-go-generator/gen.go +++ b/google-api-go-generator/gen.go @@ -81,15 +81,6 @@ var skipAPIGeneration = map[string]bool{ "datalineage:v1": true, } -// skipNewAuthLibrary is a set of APIs to not migrate to cloud.google.com/go/auth. -var skipNewAuthLibrary = map[string]bool{ - "bigquery:v2": true, - "compute:alpha": true, - "compute:beta": true, - "compute:v1": true, - "storage:v1": true, -} - var apisToSplit = map[string]bool{ "compute": true, } @@ -897,9 +888,8 @@ func (a *API) GenerateCode() ([]byte, error) { if a.mtlsAPIBaseURL() != "" { pn("opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath))") } - if !skipNewAuthLibrary[a.ID] { - pn("opts = append(opts, internaloption.EnableNewAuthLibrary())") - } + pn("opts = append(opts, internaloption.EnableNewAuthLibrary())") + pn("client, endpoint, err := htransport.NewClient(ctx, opts...)") pn("if err != nil { return nil, err }") pn("s, err := New(client)") diff --git a/storage/v1/storage-gen.go b/storage/v1/storage-gen.go index 07de6ebf63c..a6af8bd9ed3 100644 --- a/storage/v1/storage-gen.go +++ b/storage/v1/storage-gen.go @@ -133,6 +133,7 @@ func NewService(ctx context.Context, opts ...option.ClientOption) (*Service, err opts = append(opts, internaloption.WithDefaultEndpoint(basePath)) opts = append(opts, internaloption.WithDefaultEndpointTemplate(basePathTemplate)) opts = append(opts, internaloption.WithDefaultMTLSEndpoint(mtlsBasePath)) + opts = append(opts, internaloption.EnableNewAuthLibrary()) client, endpoint, err := htransport.NewClient(ctx, opts...) if err != nil { return nil, err