classyconf icon indicating copy to clipboard operation
classyconf copied to clipboard

Feature request - load configuration from HashiCorp Vault

Open tomron opened this issue 2 years ago • 1 comments

This is slightly a different case for loaders since it is not local but we use Vault \ Secrets Manager to hold configuration data such as DB URL, password, etc (which are different per env).

tomron avatar Oct 21 '21 09:10 tomron

This would be really cool, does it need a new dependency? If so, I think it should be optional. Another possibility is to provide this loader as a separate package like classyconf-vault?

Something to consider is that we would need to have a "configuration of the configuration" since the loader would need to be configured:

VaultLoader(
        url='https://localhost:8200',
        token='asdf',
        namespace='/test/'
)

So the loader would need to get this params from somewhere

class VaultConf(ClassyConf):
    VAULT_URL = Value(default="https://localhost:8200")
    VAULT_TOKEN = Value()
    VAULT_NAMESPACE = Value()

    class Meta:
        loaders = [ EnvFile(".env") ]


vault_conf= VaultConf()

vault_loader = VaultLoader(
    url=vault_conf.VAULT_URL,  
    token=vault_conf.VAULT_TOKEN, 
    namespace=vault_conf.VAULT_NAMESPACE
)

ini_loader = IniFile("another_conf.ini")

class MyAppConf(ClassyConf):
    class Meta:
        loaders = [ vault_loader, ini_loader ]

Makes sense?

hernantz avatar Oct 29 '21 22:10 hernantz