Skip to content

Commit

Permalink
Merge 1632ff3 into 254dac3
Browse files Browse the repository at this point in the history
  • Loading branch information
jawadqur committed Dec 6, 2022
2 parents 254dac3 + 1632ff3 commit e70f908
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .secrets.baseline
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
"filename": "fence/config-default.yaml",
"hashed_secret": "a94a8fe5ccb19ba61c4c0873d391e987982fbbd3",
"is_verified": false,
"line_number": 31
"line_number": 32
}
],
"fence/local_settings.example.py": [
Expand Down
1 change: 1 addition & 0 deletions fence/config-default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ BASE_URL: 'http://localhost/user'
# postgres db to connect to
# connection url format:
# postgresql://[user[:password]@][netloc][:port][/dbname]
# can also be set via env var DB
DB: 'postgresql://test:test@localhost:5432/fence'

# A URL-safe base64-encoded 32-byte key for encrypting keys in db
Expand Down
7 changes: 7 additions & 0 deletions fence/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ def post_process(self):
for default in defaults:
self.force_default_if_none(default, default_cfg=default_config)

# allow setting DB connection string via env var
if os.environ.get("DB"):
logger.info("Found environment variable 'DB': overriding 'DB' field from config file")
self["DB"] = os.environ["DB"]
else:
logger.info("Environment variable 'DB' empty or not set: using 'DB' field from config file")

if "ROOT_URL" not in self._configs and "BASE_URL" in self._configs:
url = urllib.parse.urlparse(self._configs["BASE_URL"])
self._configs["ROOT_URL"] = "{}://{}".format(url.scheme, url.netloc)
Expand Down

0 comments on commit e70f908

Please sign in to comment.