GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: Add full support for Universe Domain (#1604) · googleapis/google-cloud-node@f4a3ed1

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • handwritten/bigtable
    • protos
      • protos.d.ts
      • protos.js
    • src
      • index.ts
    • system-test
      • tpc-tests.ts
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎handwritten/bigtable/protos/protos.d.ts‎

Copy file name to clipboardExpand all lines: handwritten/bigtable/protos/protos.d.ts
-21Lines changed: 0 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎handwritten/bigtable/protos/protos.js‎

Copy file name to clipboardExpand all lines: handwritten/bigtable/protos/protos.js
+7-42Lines changed: 7 additions & 42 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Collapse file

‎handwritten/bigtable/src/index.ts‎

Copy file name to clipboardExpand all lines: handwritten/bigtable/src/index.ts
+76-16Lines changed: 76 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,28 +104,81 @@ export interface BigtableOptions extends gax.GoogleAuthOptions {
104104
}
105105

106106
/**
107-
* Retrieves the domain to be used for the service path.
107+
* Retrieves the universe domain, if configured.
108108
*
109-
* This function retrieves the domain from gax.ClientOptions passed in or via an environment variable.
110-
* It defaults to 'googleapis.com' if none has been set.
111-
* @param {string} [prefix] The prefix for the domain.
112-
* @param {gax.ClientOptions} [opts] The gax client options
113-
* @returns {string} The universe domain.
109+
* This function checks for a universe domain in the following order:
110+
* 1. The `universeDomain` property within the provided options.
111+
* 2. The `universeDomain` or `universe_domain` property within the `opts` object.
112+
* 3. The `GOOGLE_CLOUD_UNIVERSE_DOMAIN` environment variable.
113+
*
114+
* If a universe domain is found in any of these locations, it is returned.
115+
* Otherwise, the function returns `undefined`.
116+
*
117+
* @param {BigtableOptions} options - The Bigtable client options.
118+
* @param {gax.ClientOptions} [gaxOpts] - Optional gax client options.
119+
* @returns {string | undefined} The universe domain, or `undefined` if not found.
114120
*/
115-
function getDomain(prefix: string, opts?: gax.ClientOptions) {
121+
function getUniverseDomainOnly(
122+
options: BigtableOptions,
123+
gaxOpts?: gax.ClientOptions,
124+
): string | undefined {
116125
// From https://github.com/googleapis/nodejs-bigtable/blob/589540475b0b2a055018a1cb6e475800fdd46a37/src/v2/bigtable_client.ts#L120-L128.
117126
// This code for universe domain was taken from the Gapic Layer.
118127
// It is reused here to build the service path.
119128
const universeDomainEnvVar =
120129
typeof process === 'object' && typeof process.env === 'object'
121130
? process.env['GOOGLE_CLOUD_UNIVERSE_DOMAIN']
122131
: undefined;
123-
return `${prefix}.${
124-
opts?.universeDomain ??
125-
opts?.universe_domain ??
126-
universeDomainEnvVar ??
127-
'googleapis.com'
128-
}`;
132+
return (
133+
gaxOpts?.universeDomain ??
134+
gaxOpts?.universe_domain ??
135+
options?.universeDomain ??
136+
universeDomainEnvVar
137+
);
138+
}
139+
140+
/**
141+
* Retrieves the universe domain options from the provided options.
142+
*
143+
* This function examines the provided BigtableOptions and an optional
144+
* gax.ClientOptions object to determine the universe domain to be used.
145+
* It prioritizes the `universeDomain` property in the options, then checks
146+
* for `universeDomain` or `universe_domain` in the gax options, and finally
147+
* falls back to the `GOOGLE_CLOUD_UNIVERSE_DOMAIN` environment variable.
148+
* If a universe domain is found, it returns an object containing the
149+
* `universeDomain` property; otherwise, it returns `null`.
150+
*
151+
* @param {BigtableOptions} options - The Bigtable client options.
152+
* @param {gax.ClientOptions} [gaxOpts] - Optional gax client options.
153+
* @returns {{universeDomain: string} | null} An object containing the `universeDomain` property if found,
154+
* otherwise `null`.
155+
*/
156+
function getUniverseDomainOptions(
157+
options: BigtableOptions,
158+
gaxOpts?: gax.ClientOptions,
159+
): {universeDomain: string} | null {
160+
const universeDomainOnly = getUniverseDomainOnly(options, gaxOpts);
161+
return universeDomainOnly ? {universeDomain: universeDomainOnly} : null;
162+
}
163+
164+
/**
165+
* Retrieves the domain to be used for the service path.
166+
*
167+
* This function retrieves the domain from gax.ClientOptions passed in or via an environment variable.
168+
* It defaults to 'googleapis.com' if none has been set.
169+
* @param {string} [prefix] The prefix for the domain.
170+
* @param {BigtableOptions} [options] The options passed into the Bigtable client.
171+
* @param {gax.ClientOptions} [gaxOpts] The gax client options.
172+
* @returns {string} The universe domain.
173+
*/
174+
function getDomain(
175+
prefix: string,
176+
options: BigtableOptions,
177+
gaxOpts?: gax.ClientOptions,
178+
): string {
179+
const universeDomainOnly = getUniverseDomainOnly(options, gaxOpts);
180+
const suffix = universeDomainOnly ? universeDomainOnly : 'googleapis.com';
181+
return `${prefix}.${suffix}`;
129182
}
130183

131184
/**
@@ -467,10 +520,11 @@ export class Bigtable {
467520
const dataOptions = Object.assign(
468521
{},
469522
baseOptions,
523+
getUniverseDomainOptions(options, options.BigtableClient),
470524
{
471525
servicePath:
472526
customEndpointBaseUrl ||
473-
getDomain('bigtable', options.BigtableClient),
527+
getDomain('bigtable', options, options.BigtableClient),
474528
'grpc.callInvocationTransformer': grpcGcp.gcpCallInvocationTransformer,
475529
'grpc.channelFactoryOverride': grpcGcp.gcpChannelFactoryOverride,
476530
'grpc.gcpApiConfig': grpcGcp.createGcpApiConfig({
@@ -488,20 +542,26 @@ export class Bigtable {
488542
const adminOptions = Object.assign(
489543
{},
490544
baseOptions,
545+
getUniverseDomainOptions(options, options.BigtableTableAdminClient),
491546
{
492547
servicePath:
493548
customEndpointBaseUrl ||
494-
getDomain('bigtableadmin', options.BigtableClient),
549+
getDomain('bigtableadmin', options, options.BigtableTableAdminClient),
495550
},
496551
options,
497552
);
498553
const instanceAdminOptions = Object.assign(
499554
{},
500555
baseOptions,
556+
getUniverseDomainOptions(options, options.BigtableInstanceAdminClient),
501557
{
502558
servicePath:
503559
customEndpointBaseUrl ||
504-
getDomain('bigtableadmin', options.BigtableClient),
560+
getDomain(
561+
'bigtableadmin',
562+
options,
563+
options.BigtableInstanceAdminClient,
564+
),
505565
},
506566
options,
507567
);

0 commit comments

Comments
0 (0)
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.