-
Notifications
You must be signed in to change notification settings - Fork 84
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(jans-cedarling): Load bootstrap properties from environment variables #10692
Conversation
…alize` that allows to deserialize struct from string Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
…prove tests Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
c046d85
to
b2df993
Compare
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.
Can we add tests that load environment variables
// OR from environment variables | ||
let config = | ||
BootstrapConfig::from_raw_config_and_env(None).unwrap(); | ||
|
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.
So if None
is passed, it will just used defaults... should we also provide a function where the behavior is like passing in None
?
// OR from environment variables | |
let config = | |
BootstrapConfig::from_raw_config_and_env(None).unwrap(); | |
// Load the bootstrap config from the environment variables. Properties that are not defined will be assigned a default value. | |
let config = BootstrapConfig::from_env().unwrap(); | |
// Load the bootstrap config from the environment variables and a given config. | |
let config = BootstrapConfig::from_raw_config_and_env(None).unwrap(); |
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.
If passed None, will be used values from env. And if some values are not present in env it does not get values from config structure.
Ok I will add additional method from_env
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.
Resolved in 870d869
/// Construct `BootstrapConfig` from environment variables and `BootstrapConfigRaw` config | ||
// | ||
// Simple implementation that map input structure to JSON map | ||
// and map environment variables with prefix `CEDARLING_` to JSON map. And merge it. |
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.
Also document which config source has a higher priority here.
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.
I don't really get. But environment variables
have bigger priority. The comment was updated.
/// Helper function to convert Python-style list strings to JSON format | ||
fn to_json(s: &str) -> Option<Value> { |
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.
a better name might be parse_python_list_to_json
/// Helper function to convert Python-style list strings to JSON format | |
fn to_json(s: &str) -> Option<Value> { | |
/// Helper function to convert Python-style list strings to JSON format | |
fn parse_python_list_to_json(s: &str) -> Option<Value> { |
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.
This function parse string to json. And fix some kind of string to parse correctly.
I will think about better comment.
parse_python_list_to_json
doesn't look appropriate..
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.
Improved comments in the 99859c7
…aling-issue-10648 Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
…or_parse_string_as_json` Signed-off-by: Oleh Bohzok <[email protected]>
…env_vars` Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
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.
The python changes look good to me, though I am concerned about the use of environment variables for a docker image. For docker, environment variables are used like so:
docker run -e <variable1> -e <variable2> ...
This is not feasible for a massive number of environment variables that would be needed for cedarling.
In addition docker-compose.yml
needs to be updated.
exit() | ||
with open(CEDARLING_BOOTSTRAP_CONFIG_FILE, "r") as f: | ||
CEDARLING_BOOTSTRAP_CONFIG = f.read() | ||
logger.warning( |
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.
CEDARLING_BOOTSTRAP_CONFIG
may be an unbound variable here. The correct way is to initialize it to a null value before the conditional.
CEDARLING_BOOTSTRAP_CONFIG = None
#...
if CEDARLING_BOOTSTRAP_CONFIG_FILE is None:
…ass property with None Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
Signed-off-by: Oleh Bohzok <[email protected]>
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.
Looks good to me
Prepare
Description
Implemented load
BootstrapConfig
from environment variablesTarget issue
link
closes #10648
Implementation Details
BootstrapConfig
from environment variablesTest and Document the changes
Please check the below before submitting your PR. The PR will not be merged if there are no commits that start with
docs:
to indicate documentation changes or if the below checklist is not selected.