Skip to content
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

Work in progress: Replicate Django-environ FileAwareEnv #295

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

avilaton
Copy link

@avilaton avilaton commented Aug 9, 2023

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 for MAIN_FILE to /run/secrets/main will make env.str("MAIN") read the value from that file. Usage is simply switched like this

env = environ.FileAwareEnv()
...

The 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?

@avilaton avilaton marked this pull request as draft August 9, 2023 01:41
@sloria
Copy link
Owner

sloria commented Jan 10, 2024

thanks! after reading joke2k/django-environ#328 , i can see the value in this. and i like how you were able to implement this with relatively little code.

just a few things to do before merging:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants