1
0
mirror of https://github.com/google/nomulus synced 2026-01-04 12:14:19 +00:00

Make Cloud Tasks Utils canary-aware (#2639)

This commit is contained in:
Lai Jiang
2025-01-14 12:39:51 -05:00
committed by GitHub
parent f8407c74bc
commit e4ee63b8f3
4 changed files with 21 additions and 7 deletions

View File

@@ -58,9 +58,15 @@ public enum RegistryEnvironment {
*/
private static final String JETTY_PROPERTY = "google.registry.jetty";
/** Name of the environmental variable of the container name. */
private static final String CONTAINER_ENV = "CONTAINER_NAME";
private static final boolean ON_JETTY =
Boolean.parseBoolean(System.getProperty(JETTY_PROPERTY, "false"));
private static final boolean IS_CANARY =
System.getenv().getOrDefault(CONTAINER_ENV, "").endsWith("-canary");
/**
* A thread local boolean that can be set in tests to indicate some code is running in a local
* test server.
@@ -98,6 +104,10 @@ public enum RegistryEnvironment {
return ON_JETTY;
}
public static boolean isCanary() {
return IS_CANARY;
}
public static void setIsInTestDriver(boolean value) {
checkState(RegistryEnvironment.get() == RegistryEnvironment.UNITTEST);
IN_TEST_SERVER.set(value);