Skip to content

Commit

Permalink
feat(gengapic): enable cloud.google.com/go/auth for most clients (#1535)
Browse files Browse the repository at this point in the history
* Convert allowlist to blocklist.
* Block ai, aiplatform, bigquery, bigtable, datastore, errorreporting,
  firestore, logging, profiler, pubsub, pubsublite, spanner, storage.
  • Loading branch information
quartzmo committed Jun 18, 2024
1 parent 91970bc commit cd06f12
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
26 changes: 22 additions & 4 deletions internal/gengapic/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,28 @@ import (
"google.golang.org/protobuf/types/pluginpb"
)

var enableNewAuthLibrary = map[string]bool{
"cloudkms.googleapis.com": true,
"secretmanager.googleapis.com": true,
"showcase.googleapis.com": true,
var enableNewAuthLibraryBlocklist = map[string]bool{
"generativelanguage.googleapis.com": true,
"aiplatform.googleapis.com": true,
"analyticshub.googleapis.com": true,
"biglake.googleapis.com": true,
"bigqueryconnection.googleapis.com": true,
"bigquerydatapolicy.googleapis.com": true,
"bigquerydatatransfer.googleapis.com": true,
"bigquerymigration.googleapis.com": true,
"bigqueryreservation.googleapis.com": true,
"bigquerystorage.googleapis.com": true,
"bigtableadmin.googleapis.com": true,
"bigtable.googleapis.com": true,
"datastore.googleapis.com": true,
"clouderrorreporting.googleapis.com": true,
"firestore.googleapis.com": true,
"logging.googleapis.com": true,
"cloudprofiler.googleapis.com": true,
"pubsub.googleapis.com": true,
"pubsublite.googleapis.com": true,
"spanner.googleapis.com": true,
"storage.googleapis.com": true,
}

type generator struct {
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/gengrpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ func (g *generator) grpcClientOptions(serv *descriptorpb.ServiceDescriptorProto,
p(" internaloption.WithDefaultAudience(%q),", generateDefaultAudience(host))
p(" internaloption.WithDefaultScopes(DefaultAuthScopes()...),")
p(" internaloption.EnableJwtWithScope(),")
if _, ok := enableNewAuthLibrary[g.serviceConfig.GetName()]; ok {
if _, ok := enableNewAuthLibraryBlocklist[g.serviceConfig.GetName()]; !ok {
p("internaloption.EnableNewAuthLibrary(),")
}
p(" option.WithGRPCDialOption(grpc.WithDefaultCallOptions(")
Expand Down
2 changes: 1 addition & 1 deletion internal/gengapic/genrest.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func (g *generator) restClientOptions(serv *descriptorpb.ServiceDescriptorProto,
p(" internaloption.WithDefaultUniverseDomain(%q),", googleDefaultUniverse)
p(" internaloption.WithDefaultAudience(%q),", generateDefaultAudience(host))
p(" internaloption.WithDefaultScopes(DefaultAuthScopes()...),")
if _, ok := enableNewAuthLibrary[g.serviceConfig.GetName()]; ok {
if _, ok := enableNewAuthLibraryBlocklist[g.serviceConfig.GetName()]; !ok {
p("internaloption.EnableNewAuthLibrary(),")
}
p(" }")
Expand Down

0 comments on commit cd06f12

Please sign in to comment.