Skip to content

Commit fc59e39

Browse files
authored
feat(bigtable): Support universe domain (#12567)
1 parent 3de795e commit fc59e39

File tree

5 files changed

+14
-5
lines changed

5 files changed

+14
-5
lines changed

bigtable/admin.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ import (
4646
"google.golang.org/protobuf/types/known/timestamppb"
4747
)
4848

49-
const adminAddr = "bigtableadmin.googleapis.com:443"
49+
// UNIVERSE_DOMAIN placeholder is replaced by the UniverseDomain from DialSettings while creating GRPC connection/dial pool.
50+
const adminAddr = "bigtableadmin.UNIVERSE_DOMAIN:443"
5051
const mtlsAdminAddr = "bigtableadmin.mtls.googleapis.com:443"
5152

5253
var (
@@ -1166,7 +1167,8 @@ func (ac *AdminClient) AuthorizedViewIAM(table, authorizedView string) *iam.Hand
11661167
return iam.InternalNewHandleGRPCClient(ac.tClient, ac.authorizedViewPath(table, authorizedView))
11671168
}
11681169

1169-
const instanceAdminAddr = "bigtableadmin.googleapis.com:443"
1170+
// UNIVERSE_DOMAIN placeholder is replaced by the UniverseDomain from DialSettings while creating GRPC connection/dial pool.
1171+
const instanceAdminAddr = "bigtableadmin.UNIVERSE_DOMAIN:443"
11701172
const mtlsInstanceAdminAddr = "bigtableadmin.mtls.googleapis.com:443"
11711173

11721174
// InstanceAdminClient is a client type for performing admin operations on instances.

bigtable/bigtable.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ import (
4949
"google.golang.org/protobuf/types/known/timestamppb"
5050
)
5151

52-
const prodAddr = "bigtable.googleapis.com:443"
52+
// UNIVERSE_DOMAIN placeholder is replaced by the UniverseDomain from DialSettings while creating GRPC connection/dial pool.
53+
const prodAddr = "bigtable.UNIVERSE_DOMAIN:443"
5354
const mtlsProdAddr = "bigtable.mtls.googleapis.com:443"
5455
const featureFlagsHeaderKey = "bigtable-features"
5556
const queryExpiredViolationType = "PREPARED_QUERY_EXPIRED"

bigtable/export_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ type IntegrationTestConfig struct {
9090
Cluster string
9191
Cluster2 string
9292
Table string
93+
ClientOpts []option.ClientOption
9394
AttemptDirectPath bool
9495
DirectPathIPV4Only bool
9596
EmulatedServerOptions []grpc.ServerOption
@@ -129,6 +130,8 @@ func NewIntegrationEnv() (IntegrationEnv, error) {
129130
if c.Cluster2 == "" {
130131
c.Cluster2 = os.Getenv("GCLOUD_TESTS_BIGTABLE_PRI_PROJ_SEC_CLUSTER")
131132
}
133+
universeDomain := os.Getenv("GCLOUD_TESTS_BIGTABLE_UNIVERSE_DOMAIN")
134+
c.ClientOpts = append(c.ClientOpts, option.WithUniverseDomain(universeDomain))
132135

133136
if legacyUseProd != "" {
134137
fmt.Println("WARNING: using legacy commandline arg -use_prod, please switch to -it.*")
@@ -324,6 +327,7 @@ func (e *ProdEnv) AdminClientOptions() (context.Context, []option.ClientOption,
324327
if endpoint := e.config.AdminEndpoint; endpoint != "" {
325328
clientOpts = append(clientOpts, option.WithEndpoint(endpoint))
326329
}
330+
clientOpts = append(clientOpts, e.config.ClientOpts...)
327331
return context.Background(), clientOpts, nil
328332
}
329333

@@ -365,5 +369,6 @@ func (e *ProdEnv) newProdClient(config ClientConfig) (*Client, error) {
365369
// For DirectPath tests, we need to add an interceptor to check the peer IP.
366370
clientOpts = append(clientOpts, option.WithGRPCDialOption(grpc.WithDefaultCallOptions(grpc.Peer(e.peerInfo))))
367371
}
372+
clientOpts = append(clientOpts, e.config.ClientOpts...)
368373
return NewClientWithConfig(context.Background(), e.config.Project, e.config.Instance, config, clientOpts...)
369374
}

bigtable/integration_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func cleanup(c IntegrationTestConfig) error {
153153
return nil
154154
}
155155
ctx := context.Background()
156-
iac, err := NewInstanceAdminClient(ctx, c.Project)
156+
iac, err := NewInstanceAdminClient(ctx, c.Project, c.ClientOpts...)
157157
if err != nil {
158158
return err
159159
}
@@ -952,7 +952,7 @@ func TestIntegration_ExportBuiltInMetrics(t *testing.T) {
952952
// Sleep some more
953953
time.Sleep(30 * time.Second)
954954

955-
monitoringClient, err := monitoring.NewMetricClient(ctx)
955+
monitoringClient, err := monitoring.NewMetricClient(ctx, testEnv.Config().ClientOpts...)
956956
if err != nil {
957957
t.Errorf("Failed to create metric client: %v", err)
958958
}

bigtable/internal/option/option.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ func DefaultClientOptions(endpoint, mtlsEndpoint, scope, userAgent string) ([]op
9595
o = []option.ClientOption{
9696
internaloption.WithDefaultEndpointTemplate(endpoint),
9797
internaloption.WithDefaultMTLSEndpoint(mtlsEndpoint),
98+
internaloption.WithDefaultUniverseDomain("googleapis.com"),
9899
option.WithScopes(scope),
99100
option.WithUserAgent(userAgent),
100101
}

0 commit comments

Comments
 (0)