Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support overriding the emulator download URL in LocalDatastoreHelper #492

Merged
merged 2 commits into from Aug 26, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -63,6 +63,8 @@ public class LocalDatastoreHelper extends BaseEmulatorHelper<DatastoreOptions> {
private static final String MD5_CHECKSUM = "ec2237a0f0ac54964c6bd95e12c73720";
private static final String BIN_CMD_PORT_FLAG = "--port=";
private static final URL EMULATOR_URL;
private static final String EMULATOR_URL_ENV_VAR = "DATASTORE_EMULATOR_URL";
private static final String ACCESS_TOKEN = System.getenv("DATASTORE_EMULATOR_ACCESS_TOKEN");

// Common settings
private static final String CONSISTENCY_FLAG = "--consistency=";
Expand All @@ -72,7 +74,11 @@ public class LocalDatastoreHelper extends BaseEmulatorHelper<DatastoreOptions> {

static {
try {
EMULATOR_URL = new URL("http://storage.googleapis.com/gcd/tools/" + FILENAME);
if (System.getenv(EMULATOR_URL_ENV_VAR) == null) {
EMULATOR_URL = new URL("http://storage.googleapis.com/gcd/tools/" + FILENAME);
} else {
EMULATOR_URL = new URL(System.getenv(EMULATOR_URL_ENV_VAR));
}
} catch (MalformedURLException ex) {
throw new IllegalStateException(ex);
}
Expand Down Expand Up @@ -147,7 +153,7 @@ private LocalDatastoreHelper(Builder builder) {
gcloudCommand.add("--data-dir=" + getGcdPath());
}
DownloadableEmulatorRunner downloadRunner =
new DownloadableEmulatorRunner(binCommand, EMULATOR_URL, MD5_CHECKSUM);
new DownloadableEmulatorRunner(binCommand, EMULATOR_URL, MD5_CHECKSUM, ACCESS_TOKEN);
Copy link
Contributor Author

@aristide-n aristide-n Aug 9, 2021

Choose a reason for hiding this comment

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

requires a google-java-core dependency version that contains googleapis/java-core#513

this.emulatorRunners = ImmutableList.of(gcloudRunner, downloadRunner);
}

Expand Down