fix: Use the universe domain if it is provided by the user#1563
fix: Use the universe domain if it is provided by the user#1563gcf-merge-on-green[bot] merged 27 commits intomainfrom
Conversation
…ejs-bigtable into universe-domain-2
src/index.ts
Outdated
| servicePath: customEndpointBaseUrl || defaultAdminBaseUrl, | ||
| servicePath: | ||
| customEndpointBaseUrl || | ||
| `bigtableadmin.${getDomain(options.BigtableTableAdminClient)}`, |
There was a problem hiding this comment.
If no universe domain and custom endpoint is provided then this will still be bigtableadmin.googleapis.com.
src/index.ts
Outdated
| servicePath: customEndpointBaseUrl || defaultBaseUrl, | ||
| servicePath: | ||
| customEndpointBaseUrl || | ||
| `bigtable.${getDomain(options.BigtableClient)}`, |
There was a problem hiding this comment.
If no universe domain and custom endpoint is provided then this will still be bigtable.googleapis.com.
daniel-sanche
left a comment
There was a problem hiding this comment.
Mostly LGTM, with a few small comments.
I'm not too familiar with the universe domains yet though, so you might also want to assign a reviewer who understands potential complications there
| * @returns {string} The universe domain. | ||
| */ | ||
| function getDomain(opts?: gax.ClientOptions) { | ||
| // This code for universe domain was taken from the Gapic Layer. |
There was a problem hiding this comment.
can you add a permalink to where this came from?
src/index.ts
Outdated
| servicePath: customEndpointBaseUrl || defaultBaseUrl, | ||
| servicePath: | ||
| customEndpointBaseUrl || | ||
| `bigtable.${getDomain(options.BigtableClient)}`, |
There was a problem hiding this comment.
What would you think about adding pathPrefix as an argument to getDomain (and maybe renaming the method if needed), instead of manually building the string here? I think that would be a bit easier to read, and seems more natural to me since the returned string isn't useful on its own
There was a problem hiding this comment.
Yup. That would be fine.
bshaffer
left a comment
There was a problem hiding this comment.
This looks good - a few test suggestions and questions, but otherwise LGTM
| opts?.universeDomain ?? | ||
| opts?.universe_domain ?? |
There was a problem hiding this comment.
Is this a nodeJS convention to support both casings? AFAIK this is not the case in any other language implementation
There was a problem hiding this comment.
This is code is taken from here. I suggest we leave it as is because this is just Gapic code, but if you have an exact suggestion then maybe I could try that as well?
There was a problem hiding this comment.
In the JSON file, it's defined as universe_domain. I don't have a exact suggestion other than to say since the language agnostic spec doesn't require both casings, it must be specific to NodeJS.
According to #1386, that's how support was added for all GAPICs, so LGTM
There was a problem hiding this comment.
Ok. Thanks for looking into that.
testproxy/known_failures.txt
Outdated
| TestSampleRowKeys_Generic_CloseClient\| | ||
| TestSampleRowKeys_Generic_Headers\| | ||
| TestSampleRowKeys_NoRetry_NoEmptyKey\| | ||
| TestSampleRowKeys_Retry_WithRetryInfo |
There was a problem hiding this comment.
Why are these part of this PR? These tests shouldn't be affected as a result of these changes
There was a problem hiding this comment.
These needed to be added because suddenly conformance tests started failing for sampleRowKeys. This is most likely because new tests were recently added to the test runner.
There was a problem hiding this comment.
I'd pull these out of the PR.
There was a problem hiding this comment.
These have been pulled out.
| import {BigtableClient, BigtableInstanceAdminClient} from '../src/v2'; | ||
|
|
||
| describe('Service Path', () => { | ||
| it('Setting universe domain should set the service path', async () => { |
There was a problem hiding this comment.
I would suggest also
- adding a test for when the universe domain ENV VAR is set.
- setting the ENV VAR in the other two tests as well, which will ensure that it's not used when the
universeDomainandapiEndpointoptions are set.
There was a problem hiding this comment.
ok. I'll do that next.
# Conflicts: # testproxy/known_failures.txt Merge branch 'main' of https://github.com/googleapis/nodejs-bigtable into universe-domain-2
Summary:
The user should be able to set the universe domain so that outgoing calls work with a different Google Cloud Universe. Right now, if the user specifies a universe domain then it will not get used and the request will just be sent to the default Bigtable endpoint.
Changes:
src/index.ts:The change here is that when a custom url is not provided, but a universe domain is provided then the servicePath will use the universe domain provided. This is done for each Gapic client and ensures requests will be made to the universe domain instead of the default Bigtable service.system-test/service-path.ts: Two tests are added to ensure the service path is always set correctly. For instance, when a custom endpoint is provided then the service path will still always be that custom endpoint. When a custom endpoint is NOT provided, but a universe domain is provided then the service path is set to use the universe domain instead of the default endpoint.Alternatives:
universeDomainoption that would apply to all clients. While this would make things easier for users, it is an API change so it is not reversible. For now we should not change the API since users already have a way to specify the universe domains for the Gapic clients. We can always add this option later.