Skip to content

Commit

Permalink
Honor DB username as set in env file (#486)
Browse files Browse the repository at this point in the history
  • Loading branch information
giohappy authored Sep 22, 2023
1 parent 95cdf4d commit 6db8112
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,22 +531,26 @@ def _container_exposed_port(component, instname):


def _update_db_connstring():
user = os.getenv("GEONODE_DATABASE", "geonode")
pwd = os.getenv("GEONODE_DATABASE_PASSWORD", "geonode")
dbname = os.getenv("GEONODE_DATABASE", "geonode")
dbhost = os.getenv("DATABASE_HOST", "db")
dbport = os.getenv("DATABASE_PORT", 5432)
connstr = f"postgis://{user}:{pwd}@{dbhost}:{dbport}/{dbname}"
connstr = os.getenv("DATABASE_URL", None)
if not connstr:
user = os.getenv("GEONODE_DATABASE_USER", "geonode")
pwd = os.getenv("GEONODE_DATABASE_PASSWORD", "geonode")
dbname = os.getenv("GEONODE_DATABASE", "geonode")
dbhost = os.getenv("DATABASE_HOST", "db")
dbport = os.getenv("DATABASE_PORT", 5432)
connstr = f"postgis://{user}:{pwd}@{dbhost}:{dbport}/{dbname}"
return connstr


def _update_geodb_connstring():
geouser = os.getenv("GEONODE_GEODATABASE", "geonode_data")
geopwd = os.getenv("GEONODE_GEODATABASE_PASSWORD", "geonode_data")
geodbname = os.getenv("GEONODE_GEODATABASE", "geonode_data")
dbhost = os.getenv("DATABASE_HOST", "db")
dbport = os.getenv("DATABASE_PORT", 5432)
geoconnstr = f"postgis://{geouser}:{geopwd}@{dbhost}:{dbport}/{geodbname}"
geoconnstr = os.getenv("GEODATABASE_URL", None)
if not geoconnstr:
geouser = os.getenv("GEONODE_GEODATABASE_USER", "geonode_data")
geopwd = os.getenv("GEONODE_GEODATABASE_PASSWORD", "geonode_data")
geodbname = os.getenv("GEONODE_GEODATABASE", "geonode_data")
dbhost = os.getenv("DATABASE_HOST", "db")
dbport = os.getenv("DATABASE_PORT", 5432)
geoconnstr = f"postgis://{geouser}:{geopwd}@{dbhost}:{dbport}/{geodbname}"
return geoconnstr


Expand Down

0 comments on commit 6db8112

Please sign in to comment.