Add support for loading configurations values from systemd credentials
This commit is contained in:
parent
ee2d63f784
commit
785a445b43
@ -1,3 +1,4 @@
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from django.core import validators
|
||||
@ -8,6 +9,17 @@ BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
class Base(Configuration):
|
||||
@classmethod
|
||||
def pre_setup(cls):
|
||||
super().pre_setup()
|
||||
|
||||
# load systemd credentials, as per https://systemd.io/CREDENTIALS/
|
||||
credentials_directory = os.getenv("CREDENTIALS_DIRECTORY")
|
||||
if credentials_directory is not None:
|
||||
for credential in Path(credentials_directory).iterdir():
|
||||
if credential.name.isupper():
|
||||
os.environ.setdefault(credential.name, credential.read_text())
|
||||
|
||||
@classmethod
|
||||
def setup(cls):
|
||||
super().setup()
|
||||
|
Loading…
Reference in New Issue
Block a user