Add get_env_or_secret(env, secret) so that it returns docker swarm secret when specified.

Related-FIELD: FIELD-5385
Change-Id: If6a97f26204ca3c758ece38651a08653e51df471
diff --git a/sf_notifier/helpers.py b/sf_notifier/helpers.py
index 4dc4048..7e2b1c8 100644
--- a/sf_notifier/helpers.py
+++ b/sf_notifier/helpers.py
@@ -76,3 +76,17 @@
     if isinstance(name, str):
         return name.lower() == 'true'
     return name is True
+
+def get_env_or_secret(env, secret):
+    # returns the value of the env var if present,
+    # otherwise docker swarm secret if present,
+    # null when neither of the two present.
+    value = os.getenv(env, 'null')
+    if value != 'null':
+        return value
+    fpath = f'/run/secrets/{secret}'
+    exist = os.path.exists(fpath)
+    if exist:
+        with open(fpath) as file:
+            value = file.read().rstrip('\n')
+    return value