File tree Expand file tree Collapse file tree 1 file changed +21
-6
lines changed
Expand file tree Collapse file tree 1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -22,12 +22,27 @@ def __init__(self) -> None:
2222
2323backend_config = BackendConfiguration ()
2424
25- # TODO: Make these throw an exception if they are None
26- GS_DATABASE_USER = environ .get ("GS_DATABASE_USER" )
27- GS_DATABASE_PASSWORD = environ .get ("GS_DATABASE_PASSWORD" )
28- GS_DATABASE_LOCATION = environ .get ("GS_DATABASE_LOCATION" )
29- GS_DATABASE_PORT = environ .get ("GS_DATABASE_PORT" )
30- GS_DATABASE_NAME = environ .get ("GS_DATABASE_NAME" )
25+
26+ def getenv (config : str ) -> str :
27+ """
28+ Validates whether or not database env values exist in .env. If not, throws a value error.
29+
30+ :param config: Variable in .env
31+ :type config: str
32+ :return: Value of variable in .env
33+ :rtype: str
34+ """
35+ value = environ .get (config )
36+ if not value :
37+ raise ValueError (f"{ config } is missing from .env." )
38+ return value
39+
40+
41+ GS_DATABASE_USER = getenv ("GS_DATABASE_USER" )
42+ GS_DATABASE_PASSWORD = getenv ("GS_DATABASE_PASSWORD" )
43+ GS_DATABASE_LOCATION = getenv ("GS_DATABASE_LOCATION" )
44+ GS_DATABASE_PORT = getenv ("GS_DATABASE_PORT" )
45+ GS_DATABASE_NAME = getenv ("GS_DATABASE_NAME" )
3146
3247DATABASE_CONNECTION_STRING : Final [
3348 str
You can’t perform that action at this time.
0 commit comments