← Back to team overview

sts-sponsors team mailing list archive

[Merge] ~ack/maas-site-manager:env-file-cleanup into maas-site-manager:main

 

Alberto Donato has proposed merging ~ack/maas-site-manager:env-file-cleanup into maas-site-manager:main.

Commit message:
rename .env.dev since it's used for docker-compose

This also doesn't load the file anymore in the import script, allows overriding
params from the env

Requested reviews:
  MAAS Committers (maas-committers)

For more details, see:
https://code.launchpad.net/~ack/maas-site-manager/+git/site-manager/+merge/441076
-- 
Your team MAAS Committers is requested to review the proposed merge of ~ack/maas-site-manager:env-file-cleanup into maas-site-manager:main.
diff --git a/.env.dev b/docker-compose.env
similarity index 100%
rename from .env.dev
rename to docker-compose.env
diff --git a/docker-compose.yaml b/docker-compose.yaml
index 3a6ab76..b1dbec9 100644
--- a/docker-compose.yaml
+++ b/docker-compose.yaml
@@ -2,7 +2,7 @@ version: "3.9"
 services:
   postgres:
     image: postgres:14
-    env_file: .env.dev
+    env_file: docker-compose.env
     ports:
       - 5432:5432
     volumes:
@@ -14,7 +14,7 @@ services:
       retries: 5
 
   backend:
-    env_file: .env.dev
+    env_file: docker-compose.env
     depends_on:
       postgres:
         condition: service_healthy
diff --git a/test-data/import.sh b/test-data/import.sh
index 4309cdb..3264d0c 100755
--- a/test-data/import.sh
+++ b/test-data/import.sh
@@ -2,7 +2,12 @@
 #
 # This script imports the testdata from this directory into the postgres database
 #
-envfile="../.env.dev"
+
+POSTGRES_HOST="${POSTGRERS_HOST:-localhost}"
+POSTGRES_PORT="${POSTGRES_PORT:-5432}"
+POSTGRES_DB="${POSTGRES_DB:-postgres}"  # default for postgres docker image
+POSTGRES_USER="${POSTGRES_USER:-postgres}"  # default for postgres docker image
+POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-msm}"  # default for postgres docker image
 
 basedir="$(dirname "$0")"
 
@@ -29,14 +34,6 @@ EOF
     exit 1
 fi
 
-if [ -e "$envfile" ]; then
-    # shellcheck disable=SC1090
-    . "$envfile"
-else 
-    echo "Cannot source dev environment. Make sure ${envfile} exists." >&2
-    exit 1
-fi
-
 (
     copy_cmd sites.csv 'site(id, city, country, latitude, longitude, name, note, region, street, timezone, url)'
     copy_cmd tokens.csv 'token(site_id, value, expired, created)'

Follow ups