Work in progress: Replicate Django-environ FileAwareEnv #295
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is a work in progres PR to try to bring FileAwareEnv functionality found in django-environ to this package. Requesting for comments, I still need to polish it a lot, but wanted to get it out there.
The feature allows one to set a variable to indicate that the value should be read from a file instead of from os.environ.
For example, if a variable one passes in is called
MAIN
, then setting a value forMAIN_FILE
to/run/secrets/main
will make env.str("MAIN") read the value from that file. Usage is simply switched like thisThe mentioned functionality uses some caching to avoid reading files every time we use this value, see here
https://github.com/joke2k/django-environ/blob/main/environ/fileaware_mapping.py#L15
Thoughts?