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 override #787
Comments
Hi! My partner @apalmer16 and I are currently students enrolled in EECS 481. We recently saw a presentation regarding MyLA in class and wanted to contribute to fixing an open source issue. We just wanted to let you know that we will be attempting to implement this feature! |
Thanks @emilychee, we appreciate your help! |
In the code we should have defaults defined that match the json but inevitably that does get out of sync with an external configuration file. For instance the settings.py has I'd personally like to switch to defining most of the settings in Django admin using a live settings package. I'm not sure which one of those to pick. Probably one that's been updated recently/often and is going to be compatible with Django 2. Then we could load all of the defaults into the database via migrations. |
So if we decided to test using django-constance, would we install the redis backend or database backend? |
Just use the MySQL database backend that's already in the docker-compose and used for the application. |
Here were my comments from #820 on how we might support this I feel like for this to work as individual variables we'd have to either have a library that does type inference which is going to be a little more work than this (unless there's one out there). Probably the easier way to fulfill the initial request I'd think is just to use this special ENV called The thing with that is it's either or. You either have the entire env defined in ENV_JSON or you have it defined in the file. What I'd do instead of this.
This wouldn't allow someone to define individual values in the ENV and have them override but they could define a JSON in the env and it would override. I feel like this would be sufficient for the request and avoid modifying this entire file. Sorry as it looks like you did a a lot of work here. |
@ssciolla I think you code from https://github.com/tl-its-umich-edu/course-inventory/blame/master/environ.py#L27 would solve this issue. Could you look at this when you get a chance? Maybe it'd be useful to refactor this over to a file like environ.py just like this instead of loading it in settings. |
@jonespm, yeah, I can start looking at this. |
This relates to #1200 |
…1425) * Add basic fix for environment variable override * Remove GOOGLE_APPLICATION_CREDENTIALS from env_sample.hjson * TZ -> TIME_ZONE; use TZ env var in settings as backup * Add some info to configuration about overriding env.hjson values * Extract overriding as a function; improve docs language * Change log message to DEBUG level * Fix bug * Improve debug logging for clarity * Remove unnecessary pass
I have followed the Test plan on PR #1425:
|
Describe your problem or feature you'd like added
In order to deploy into a kubernetes infrastructure with more ease, I'd like the ability for any variables defined within the environment, to supersede any entries defined in the env.json file that is provided.
Describe the solution you'd like
I'd like for env_sample.json to be loaded as the default configuration. Any value defined in the environment during initialization, should override what has been loaded as default.
For example, if env_sample.json was loaded as our default configuration, it contains the following entries for log levels
If my environment were to have the following defined
I'd like the variables from my environment to override the default settings that were loaded from the json file. In the end we end up with these values being loaded.
Additional context
If it heps any, I was accomplishing this with this snippet in
settings.py
downside of my snippent is that everything from the environment was loaded as a string. I then needed to cast variables that I knew were a bool (str_2_bool) or int when assigning from
ENV
The text was updated successfully, but these errors were encountered: