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
Environment variable resolution in configs #1198
Environment variable resolution in configs #1198
Conversation
This commit enables parsing config values from environment variables. This is particularly useful if passwords can't be hardcoded in the config files but instead passed to Cruise Control via an environment variable. For instance if there is a MY_PASSWORD=test123 then defining the following config in cruisecontrol.properties will be resolved on startup to the actual password. Config file on the disk: Resolved runtime config: config.name=${env:MY_ENV_VAR} ==> config.name=test123
@efeg would you please review this? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the patch! Left a couple minor comments.
cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/KafkaCruiseControlUtils.java
Outdated
Show resolved
Hide resolved
@@ -541,4 +547,20 @@ public static void sanityCheckNonExistingGoal(List<String> goals, Map<String, Go | |||
|
|||
return balancednessCostByGoal; | |||
} | |||
|
|||
/** | |||
* Reads the configuration file, parses and validates the configs. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we also mention the properties that enable configs to be provided out of the configuration file?
Is it intentional to override these hardcoded properties if they were also defined in the configuration file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1st: acked, will do
2nd: well, I treat them as defaults here so if people want to do something else than what CC does by default, then they should be free to. What can I improve here?
cruise-control/src/main/java/com/linkedin/kafka/cruisecontrol/config/EnvConfigProvider.java
Outdated
Show resolved
Hide resolved
cruise-control/src/test/java/com/linkedin/kafka/cruisecontrol/config/EnvConfigProviderTest.java
Outdated
Show resolved
Hide resolved
Change-Id: I1759b4c0f0a2dba59f59d1aa7838aef2d8205e6d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the updates -- LGTM.
This commit enables parsing config values from environment variables. This is particularly useful if passwords can't be hardcoded in the config files but instead passed to Cruise Control via an environment variable. For instance if there is a MY_PASSWORD=test123 then defining the following config in cruisecontrol.properties will be resolved on startup to the actual password. Config file on the disk: Resolved runtime config: config.name=${env:MY_ENV_VAR} ==> config.name=test123
This commit enables parsing config values from environment variables.
This is particularly useful if passwords can't be hardcoded in the config
files but instead passed to Cruise Control via an environment variable.
For instance if there is a MY_PASSWORD=test123 then defining the following
config in cruisecontrol.properties will be resolved on startup to the
actual password.
Config file on the disk: config.name=${env:MY_ENV_VAR}
Resolved runtime config: config.name=test123
This fixes #1197