From 62e385a2aa7448cc4ca4bc96774bcd34fe55e867 Mon Sep 17 00:00:00 2001 From: Jawad Qureshi Date: Wed, 26 Apr 2023 15:07:32 -0500 Subject: [PATCH 1/2] allow setting INDEXD_PASSWORD via env var --- fence/config-default.yaml | 1 + fence/config.py | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/fence/config-default.yaml b/fence/config-default.yaml index 03213253e..503cb6d61 100755 --- a/fence/config-default.yaml +++ b/fence/config-default.yaml @@ -675,6 +675,7 @@ INDEXD: null # this is the username which fence uses to make authenticated requests to indexd INDEXD_USERNAME: 'fence' # this is the password which fence uses to make authenticated requests to indexd +# can also be set via env var INDEXD_PASSWORD INDEXD_PASSWORD: '' # ////////////////////////////////////////////////////////////////////////////////////// diff --git a/fence/config.py b/fence/config.py index 1c7ff15b9..27344b58a 100644 --- a/fence/config.py +++ b/fence/config.py @@ -60,6 +60,17 @@ def post_process(self): "Environment variable 'DB' empty or not set: using 'DB' field from config file" ) + # allow setting INDEXD_PASSWORD via env var + if os.environ.get("INDEXD_PASSWORD"): + logger.info( + "Found environment variable 'INDEXD_PASSWORD': overriding 'INDEXD_PASSWORD' field from config file" + ) + self["INDEXD_PASSWORD"] = os.environ["INDEXD_PASSWORD"] + else: + logger.info( + "Environment variable 'INDEXD_PASSWORD' empty or not set: using 'INDEXD_PASSWORD' 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) From 60536b4d2ec5c3535e316aff9502709d2870466b Mon Sep 17 00:00:00 2001 From: Jawad Qureshi Date: Wed, 26 Apr 2023 15:53:16 -0500 Subject: [PATCH 2/2] allow setting INDEXD_PASSWORD via env var --- fence/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fence/config.py b/fence/config.py index 27344b58a..e643a758c 100644 --- a/fence/config.py +++ b/fence/config.py @@ -67,7 +67,7 @@ def post_process(self): ) self["INDEXD_PASSWORD"] = os.environ["INDEXD_PASSWORD"] else: - logger.info( + logger.debug( "Environment variable 'INDEXD_PASSWORD' empty or not set: using 'INDEXD_PASSWORD' field from config file" )