joke2k / django-environ

Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.
https://django-environ.rtfd.org
MIT License
3.03k stars 315 forks source link

Direnv format support #232

Open IvanAnishchuk opened 5 years ago

IvanAnishchuk commented 5 years ago

One popular alternative for env file format is env directory (python implementation example). It's not necessarily "better" than env files but I think it's popular enough to be useful here. I have a simple implementation for one of my work projects (we use format similar to envdir for docker secrets and configs), should I send a PR here, is anyone interested at all?

vaygr commented 5 years ago

Hey @IvanAnishchuk. Yeah, at least I would be interested.

IvanAnishchuk commented 5 years ago

Meanwhile I found a simple way to do it, looks roughly like this:

if envdir.is_dir():  # envdir is a pathlib.Path
    for var in envdir.iterdir():
        if var.is_file():
            environ.Env.ENVIRON.setdefault(var.name, var.read_text().strip('\n'))

I should probably put it into a simple library so it's reusable easier, it could be used without any modifications on any dict-like or os.environ-like structure, not only with django-environ.

sergeyklay commented 3 years ago

@IvanAnishchuk Could you please send a PR?