Skip to content
Permalink
Browse files
feat: use dummy emulator-project when no project is set (#1363)
Use a dummy emulator-project when no default project is set for the environment
and the SPANNER_EMULATOR_HOST environment variable has been set.

Replaces #1345
  • Loading branch information
olavloite committed Aug 19, 2021
1 parent 8951c8c commit 673855eea8c244457ad4c8ac5abe3ad3a0a0cdde
Showing with 10 additions and 0 deletions.
  1. +10 −0 google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java
@@ -1164,6 +1164,16 @@ public static void useDefaultEnvironment() {
SpannerOptions.environment = SpannerEnvironmentImpl.INSTANCE;
}

@Override
protected String getDefaultProject() {
String projectId = getDefaultProjectId();
// The project id does not matter if we are using the emulator.
if (projectId == null && System.getenv("SPANNER_EMULATOR_HOST") != null) {
return "emulator-project";
}
return projectId;
}

public TransportChannelProvider getChannelProvider() {
return channelProvider;
}

0 comments on commit 673855e

Please sign in to comment.