-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Goal
I’m looking into creating a utility function that can dynamically create and assign the xDS bootstrap.
This could be hooked into the application startup so that xDS can be configured across different environments (IDE, GCE, GKE) without the need of startup shell scripts etc.
While almost every programming language supports dynamically setting environment variables, Java does not.
Would it be possible to have an alternative way in java to provide the location of the bootstrap file?
Possible solution
One possible solution that doesn’t break the existing API and gRPC spec would be to also try reading e.g. a java system property (System.getProperty(“grpc.xds.bootstrap”);) at
grpc-java/xds/src/main/java/io/grpc/xds/Bootstrapper.java
Lines 57 to 61 in beb3232
| String filePath = System.getenv(BOOTSTRAP_PATH_SYS_ENV_VAR); | |
| if (filePath == null) { | |
| throw new XdsInitializationException( | |
| "Environment variable " + BOOTSTRAP_PATH_SYS_ENV_VAR + " not defined."); | |
| } |
In the case that the GRPC_XDS_BOOSTRAP environment variable isn’t found.
Maybe something as simple as:
private static final String BOOTSTRAP_PATH_SYS_PROPERTY_VAR = "grpc.xds.bootstrap";
.
.
.
String filePath = Optional.ofNullable(System.getenv(BOOTSTRAP_PATH_SYS_ENV_VAR))
.orElse(System.getProperty(BOOTSTRAP_PATH_SYS_PROPERTY_VAR)); Alternatives
Alternative solutions would most likely require larger changes to the existing classes in order to pass the config down.