Giter Club home page Giter Club logo

Comments (1)

rochacbruno avatar rochacbruno commented on June 9, 2024

Right now, the easiest path is to create a hook function and attach it as shown here: https://www.dynaconf.com/advanced/?h=hooks#instance-approach

import os

def load_mounted_secrets(settings):
    data = {"dynaconf_merge": True}
    folder_path = "the/path/to/the/secrets" # or take from settings
    for filename in os.listdir(folder_path):
        file_path = os.path.join(folder_path, filename)
        if os.path.isfile(file_path):
            with open(file_path, 'r') as file:
                data[filename] = file.read().strip()
    return data

settings = Dynaconf(post_hooks=[load_mounted_secrets])

It would be great to have this feature built-in in a better standardized way, so A PR also welcome.

How I would do it:

  1. Include a new variable on https://github.com/dynaconf/dynaconf/blob/master/dynaconf/default_settings.py something like SECRET_MOUNT_PATH_FOR_DYNACONF which will become the secret_mount_path= argument to the Dynaconf class.
  2. Add a mounted_secrets_loader.py to https://github.com/dynaconf/dynaconf/tree/master/dynaconf/loaders, that loader will do what the function above does (following the loader Base class style)
  3. On execute_loaders function invoke the loader (need to decide which order is best to load it)
  4. Add an app example as a functional test on tests_functional folder
  5. Add unit tests to the tests/ folder
  6. Add docs

from dynaconf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.