Skip to content

Commit

Permalink
Merge pull request #2 from aristide-n/custom-emulator-urls
Browse files Browse the repository at this point in the history
feat: support overriding the emulator download URL in LocalDatastoreHelper
  • Loading branch information
aristide-n authored Aug 9, 2021
2 parents d3e1af5 + 440ab13 commit 2de14c2
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
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);
this.emulatorRunners = ImmutableList.of(gcloudRunner, downloadRunner);
}

Expand Down

0 comments on commit 2de14c2

Please sign in to comment.