-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
fix: Use the universe domain if it is provided by the user #1563
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If no universe domain and custom endpoint is provided then this will still be bigtable.googleapis.com.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add a permalink to where this came from?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/index.ts
Outdated
servicePath: customEndpointBaseUrl || defaultBaseUrl, | ||
servicePath: | ||
customEndpointBaseUrl || | ||
`bigtable.${getDomain(options.BigtableClient)}`, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup. That would be fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good - a few test suggestions and questions, but otherwise LGTM
opts?.universeDomain ?? | ||
opts?.universe_domain ?? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd pull these out of the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
universeDomain
andapiEndpoint
options are set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. I'll do that next.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
# 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:
universeDomain
option 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.