From 2fe21565d989ddcf17d8de5a93ab6f0d5ec5e8dc Mon Sep 17 00:00:00 2001 From: Cody Oss Date: Tue, 13 Aug 2024 13:40:15 -0500 Subject: [PATCH 1/2] feat: move storage, bigquery, and compute to new auth lib --- 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 + go.mod | 2 +- go.sum | 2 ++ google-api-go-generator/gen.go | 14 ++------------ storage/v1/storage-gen.go | 1 + 8 files changed, 10 insertions(+), 13 deletions(-) diff --git a/bigquery/v2/bigquery-gen.go b/bigquery/v2/bigquery-gen.go index 81b1146aadc..a62207a9c8f 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 fc8ef86929c..c880afa9b26 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 3daa19777cb..58e51fc12bc 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 d7916672836..d05761b66b9 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/go.mod b/go.mod index a22e9944974..b3a6a969771 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( cloud.google.com/go v0.115.0 - cloud.google.com/go/auth v0.7.3 + cloud.google.com/go/auth v0.8.1 cloud.google.com/go/auth/oauth2adapt v0.2.3 cloud.google.com/go/compute/metadata v0.5.0 github.com/google/go-cmp v0.6.0 diff --git a/go.sum b/go.sum index b25b0ae38d2..c0bb3655726 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,8 @@ cloud.google.com/go v0.115.0 h1:CnFSK6Xo3lDYRoBKEcAtia6VSC837/ZkJuRduSFnr14= cloud.google.com/go v0.115.0/go.mod h1:8jIM5vVgoAEoiVxQ/O4BFTfHqulPZgs/ufEzMcFMdWU= cloud.google.com/go/auth v0.7.3 h1:98Vr+5jMaCZ5NZk6e/uBgf60phTk/XN84r8QEWB9yjY= cloud.google.com/go/auth v0.7.3/go.mod h1:HJtWUx1P5eqjy/f6Iq5KeytNpbAcGolPhOgyop2LlzA= +cloud.google.com/go/auth v0.8.1 h1:QZW9FjC5lZzN864p13YxvAtGUlQ+KgRL+8Sg45Z6vxo= +cloud.google.com/go/auth v0.8.1/go.mod h1:qGVp/Y3kDRSDZ5gFD/XPUfYQ9xW1iI7q8RIRoCyBbJc= cloud.google.com/go/auth/oauth2adapt v0.2.3 h1:MlxF+Pd3OmSudg/b1yZ5lJwoXCEaeedAguodky1PcKI= cloud.google.com/go/auth/oauth2adapt v0.2.3/go.mod h1:tMQXOfZzFuNuUxOypHlQEXgdfX5cuhwU+ffUuXRJE8I= cloud.google.com/go/compute/metadata v0.5.0 h1:Zr0eK8JbFv6+Wi4ilXAR8FJ3wyNdpxHKJNPos6LTZOY= diff --git a/google-api-go-generator/gen.go b/google-api-go-generator/gen.go index 87be88b10df..b22c2268d52 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, } @@ -900,9 +891,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 99b72cdb4a9..8a16d773485 100644 --- a/storage/v1/storage-gen.go +++ b/storage/v1/storage-gen.go @@ -134,6 +134,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 From fb0783c0df69489d8ded74a971b7e7843a796c7d Mon Sep 17 00:00:00 2001 From: Cody Oss Date: Tue, 13 Aug 2024 13:48:06 -0500 Subject: [PATCH 2/2] go mod tidy --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index c0bb3655726..4f5f4c039da 100644 --- a/go.sum +++ b/go.sum @@ -1,8 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.115.0 h1:CnFSK6Xo3lDYRoBKEcAtia6VSC837/ZkJuRduSFnr14= cloud.google.com/go v0.115.0/go.mod h1:8jIM5vVgoAEoiVxQ/O4BFTfHqulPZgs/ufEzMcFMdWU= -cloud.google.com/go/auth v0.7.3 h1:98Vr+5jMaCZ5NZk6e/uBgf60phTk/XN84r8QEWB9yjY= -cloud.google.com/go/auth v0.7.3/go.mod h1:HJtWUx1P5eqjy/f6Iq5KeytNpbAcGolPhOgyop2LlzA= cloud.google.com/go/auth v0.8.1 h1:QZW9FjC5lZzN864p13YxvAtGUlQ+KgRL+8Sg45Z6vxo= cloud.google.com/go/auth v0.8.1/go.mod h1:qGVp/Y3kDRSDZ5gFD/XPUfYQ9xW1iI7q8RIRoCyBbJc= cloud.google.com/go/auth/oauth2adapt v0.2.3 h1:MlxF+Pd3OmSudg/b1yZ5lJwoXCEaeedAguodky1PcKI=