Skip to content

Commit 8e0f748

Browse files
committed
feat(datastore): support --use-firestore-in-datastore-mode in the datastore emulator
Fixes #1406 This followed the changes in the java-datastore library. See googleapis/java-datastore#1698
1 parent 11f862e commit 8e0f748

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/datastore/EmulatorSettings.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,20 @@ public class EmulatorSettings {
5454
*/
5555
private Path dataDir;
5656

57+
/**
58+
* Configures whether the emulator runs in "Cloud Firestore in Datastore Mode". Correspondent CLI
59+
* property: --use-firestore-in-datastore-mode.
60+
*/
61+
private boolean firestoreInDatastoreMode = false;
62+
63+
public boolean getFirestoreInDatastoreMode() {
64+
return firestoreInDatastoreMode;
65+
}
66+
67+
public void setFirestoreInDatastoreMode(boolean useFirestoreInDatastoreMode) {
68+
this.firestoreInDatastoreMode = useFirestoreInDatastoreMode;
69+
}
70+
5771
public Path getDataDir() {
5872
return dataDir;
5973
}

spring-cloud-gcp-autoconfigure/src/main/java/com/google/cloud/spring/autoconfigure/datastore/GcpDatastoreEmulatorAutoConfiguration.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public LocalDatastoreHelper createDatastoreHelper(GcpDatastoreProperties datasto
5858
.setPort(settings.getPort())
5959
.setStoreOnDisk(settings.isStoreOnDisk())
6060
.setDataDir(settings.getDataDir())
61+
.setFirestoreInDatastoreMode(settings.getFirestoreInDatastoreMode())
6162
.build();
6263

6364
return this.helper;

spring-cloud-gcp-autoconfigure/src/test/java/com/google/cloud/spring/autoconfigure/datastore/GcpDatastoreEmulatorAutoConfigurationTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ void testDatastoreOptionsCorrectlySet() {
4242
"spring.cloud.gcp.datastore.emulator.enabled=true",
4343
"spring.cloud.gcp.datastore.emulator.consistency=0.8",
4444
"spring.cloud.gcp.datastore.emulator.dataDir=/usr/local/datastore",
45-
"spring.cloud.gcp.datastore.emulator.storeOnDisk=false")
45+
"spring.cloud.gcp.datastore.emulator.storeOnDisk=false",
46+
"spring.cloud.gcp.datastore.emulator.firestoreInDatastoreMode=true")
4647
.run(
4748
context -> {
4849
LocalDatastoreHelper helper = context.getBean(LocalDatastoreHelper.class);
@@ -51,6 +52,7 @@ void testDatastoreOptionsCorrectlySet() {
5152
assertThat(helper.getConsistency()).isEqualTo(0.8D);
5253
assertThat(helper.getGcdPath()).isEqualTo(Paths.get("/usr/local/datastore"));
5354
assertThat(helper.isStoreOnDisk()).isFalse();
55+
assertThat(helper.isFirestoreInDatastoreMode()).isTrue();
5456
});
5557
}
5658

0 commit comments

Comments
 (0)