Skip to content

Conversation

@danieljbruce
Copy link
Contributor

This change allows the user to set a custom endpoint when creating the client and it will work with the backend the way it is supposed to. It also ensures that we can still work with the emulator using the client.

With the code in its present state, this test should fail. A fix for regional endpoints intends to clean this up.
Only set the credentials to insecure if the custom endpoint is localhost and credentials are not provided. This way the user can set custom endpoints with the client and the request will work.
There is a test that uses a mock which is preventing the base url from being set. The test should be more realistic and when it is, the test passes with the new change.
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: datastore Issues related to the googleapis/nodejs-datastore API. labels Apr 6, 2023
@danieljbruce danieljbruce changed the title Allow user to set custom endpoints fix: Allow user to set custom endpoints Apr 6, 2023
src/index.ts Outdated
const isUsingEmulator =
this.baseUrl_ &&
(this.baseUrl_.includes('localhost') ||
this.baseUrl_.includes('127.0.0.1'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just in case, maybe add ::1 as an IPv6 version of localhost?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

There is a third way the user can specify localhost. We should include this way as an option.
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 11, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 11, 2023
@danieljbruce danieljbruce marked this pull request as ready for review April 11, 2023 14:45
@danieljbruce danieljbruce requested review from a team as code owners April 11, 2023 14:45
@danieljbruce danieljbruce added the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 11, 2023
@gcf-owl-bot gcf-owl-bot bot removed the owlbot:run Add this label to trigger the Owlbot post processor. label Apr 11, 2023
@danieljbruce danieljbruce merged commit e79fa49 into googleapis:main Apr 11, 2023
@edance
Copy link

edance commented May 3, 2023

hey all! This PR broke the docker setup for us. We're running the datastore emulator using a docker container so the datastore emulator host is something like datastore:8081. We want a connection that is both insecure and not to localhost.

How can we make changes to this code? If process.env.DATASTORE_EMULATOR_HOST is set, should we make isUsingEmulator == true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: datastore Issues related to the googleapis/nodejs-datastore API. size: s Pull request size is small.

3 participants