-
Notifications
You must be signed in to change notification settings - Fork 693
Datastore emulator support #1430
Comments
Hi, just created #1445 to solve this problem. Regarding the CredentialsProvider fix, this may not be possible. I made a few attempts:
Given this, it looks like part of using the emulator is to also verify that your credentials are correct; this behavior may actually be useful. So I think the most prudent choice here is to just keep it |
@dzou as of now, I use the following custom configuration along with Datastore emulator:
Works like a charm. I think you might use it as well |
Nice one, that works for me. OK, I would be open to including this in our configuration. I will check in with our team to confirm the approach. @meltsufin, @artembilan: What are your thoughts about including a NoCredentials provider bean if an emulator is installed? The main question here is that if we override the CredentialsProvider bean, this will affect usage of entire Spring Cloud GCP library. Is there risk of user wanting to use emulator with real GCP services in test situation? (such as if user wanted to use datastore emulator + real stackdriver logging, etc.) |
Well, we are here in the opinionated auto-configuration and having |
In if (gcpPubSubProperties.getEmulatorHost() == null
|| "false".equals(gcpPubSubProperties.getEmulatorHost())) {
this.finalCredentialsProvider = gcpPubSubProperties.getCredentials().hasKey()
? new DefaultCredentialsProvider(gcpPubSubProperties)
: credentialsProvider;
}
else {
// Since we cannot create a general NoCredentialsProvider if the emulator host is enabled
// (because it would also be used for the other components), we have to create one here
// for this particular case.
this.finalCredentialsProvider = NoCredentialsProvider.create();
} We should do the same for Datastore. It will not override the global credentials provider. |
OK, sounds good. I have revised my PR to adopt this style. |
Add support for connecting to emulator with Datastore. Fixes #1430.
Hello. I have a question and I don't know if I should open another ticket. Google libraries have a good class to start the emulator through java. For datastore this class is LocalDatastoreHelper.java. With this new support for datastore-emulator the host must have to be defined statically in application.properties. The problem is the emulator helper starts search for a random free port to start the emulator and the datastore connection for spring data cannot connect to the datastore instance. Do you guys have any kind of helper similar to LocalDatastoreHelper.java that uses the spring.cloud.gcp.datastore.emulator-host properties? |
Hey thanks for posting the question. Is it possible to startup your emulator with a predetermined port via. --port flag? I.e. in an ideal scenario you could set your emulator and application.properties to the same port. However, if this solution doesn't work for you, please feel free to file a new issue on our github just so we don't forget to look deeper into it; often times comments on older issues will get missed. Thanks. |
@lucasoares Using the port flag that @dzou suggested should solve your issue. |
@meltsufin yes, exactly that.. @dzou unfortunately the I will open a new issue and also create a PR to Thank you guys. |
|
@lucasoares I created the issue #1642. Contributions are always welcomed! 😉 |
Google's clients now accepts a custom port. We just need to wait for their release haha After that I can create a PR here to auto configure the datastore emulator after using a custom properties. |
Please add a possibility to set emulator host for datastore (as it's implemented for PubSub). Also, if emulator host is set, instantiate NoCredentialsProvider instead of DefaultCredentialsProvider
The text was updated successfully, but these errors were encountered: