popd 2>/dev/null >/dev/null
}
+function capitalize() {
+ echo "$1" | sed -e 's!\(^\|-\)\(.\)!\U\2!g'
+}
+
APP=$(basename $(pwd))
FL_APPS_HOST="localhost"
FL_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local subkey=User') }}"
FL_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Local') }}"
-FL_CARRIER_DIRECTORY_DEV_PSQL_HOST="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=Host') }}"
-FL_CARRIER_DIRECTORY_DEV_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=Port') }}"
-FL_CARRIER_DIRECTORY_DEV_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=User') }}"
-FL_CARRIER_DIRECTORY_DEV_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory') }}"
-FL_CARRIER_DIRECTORY_DEV_PSQL_DB="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/CarrierDirectory subkey=Database') }}"
-
-FL_GEODATA_DEV_PSQL_HOST="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=Host') }}"
-FL_GEODATA_DEV_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=Port') }}"
-FL_GEODATA_DEV_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=User') }}"
-FL_GEODATA_DEV_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata') }}"
-FL_GEODATA_DEV_PSQL_DB="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Geodata subkey=Database') }}"
-
-FL_NOTIFIER_DEV_PSQL_HOST="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=Host') }}"
-FL_NOTIFIER_DEV_PSQL_PORT="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=Port') }}"
-FL_NOTIFIER_DEV_PSQL_USER="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=User') }}"
-FL_NOTIFIER_DEV_PSQL_PASSWORD="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier') }}"
-FL_NOTIFIER_DEV_PSQL_DB="{{ lookup('passwordstore', 'Travail/Fretlink/Psql/Dev/Notifier subkey=Database') }}"
-
FL_TOOLBOX_AGENT_MACAROON="{{ lookup('passwordstore', 'Travail/Fretlink/Macaroons/ToolboxAgent') }}"
+export FRETLINK_ENV="$APP ${FL_ENV:-local}"
+
if [ -f "local.env.example" ]; then
source local.env.example
fi
export POSTGRESQL_ADDON_PASSWORD="$FL_PSQL_PASSWORD"
export POSTGRESQL_ADDON_DB="$name"
else
- postgresql_host="FL_${name^^}_${FL_ENV^^}_PSQL_HOST"
- postgresql_port="FL_${name^^}_${FL_ENV^^}_PSQL_PORT"
- postgresql_user="FL_${name^^}_${FL_ENV^^}_PSQL_USER"
- postgresql_password="FL_${name^^}_${FL_ENV^^}_PSQL_PASSWORD"
- postgresql_db="FL_${name^^}_${FL_ENV^^}_PSQL_DB"
- export FRETLINK_ENV="$FL_ENV"
- export POSTGRESQL_ADDON_HOST="${!postgresql_host}"
- export POSTGRESQL_ADDON_PORT="${!postgresql_port}"
- export POSTGRESQL_ADDON_USER="${!postgresql_user}"
- export POSTGRESQL_ADDON_PASSWORD="${!postgresql_password}"
- export POSTGRESQL_ADDON_DB="${!postgresql_db}"
+ key=Psql/$(capitalize $FL_ENV)/$(capitalize $APP)
+ export POSTGRESQL_ADDON_HOST=$(p $key Host)
+ export POSTGRESQL_ADDON_PORT=$(p $key Port)
+ export POSTGRESQL_ADDON_USER=$(p $key User)
+ export POSTGRESQL_ADDON_PASSWORD=$(p $key)
+ export POSTGRESQL_ADDON_DB=$(p $key Database)
fi
fi