Skip to content

Commit

Permalink
better env build + cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
AWerbrouck committed May 21, 2024
1 parent 2e9c2c5 commit 96cad66
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 56 deletions.
21 changes: 13 additions & 8 deletions .env-template
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
backend/app/src/main/resources/application-secrets.properties,spring.datasource.username=<username>
backend/app/src/main/resources/application-secrets.properties,spring.datasource.password=<password>
backend/app/src/main/resources/application-secrets.properties,azure.activedirectory.client-id=<client-id>
backend/app/src/main/resources/application-secrets.properties,azure.activedirectory.b2c.client-secret=<client-secret>
backend/app/src/main/resources/application-secrets.properties,azure.activedirectory.tenant-id=<tenant-id>
docker.env,PGU=<username>
docker.env,PGP=<password>
docker.env,POSTGRES_USER=${PGU}
client-secret=<your-client-secret>
client-id=<your-client-id>
tenant-id=<your-tenant-id>
PGU=<your-postgres-user>
PGP=<your-postgres-password>
POSTGRES_USER=${PGU}
URI=<your-uri>
EXPRESS_SESSION_SECRET=<your-express-session-secret>
PORT=<your-port>
ENVIRONMENT=<your-environment>
DB_HOST=<your-db-host>
DB_PORT=<your-db-port>
DB_NAME=<your-db-name>
Binary file removed dind-chart.png
Binary file not shown.
2 changes: 0 additions & 2 deletions docker.env.template

This file was deleted.

28 changes: 0 additions & 28 deletions envBuilder.bat

This file was deleted.

54 changes: 54 additions & 0 deletions envBuilder.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@


class envBuilder():
def __init__(self):
self.env = {}
self.javaEnv = {'client-secret': ['azure.activedirectory.b2c.client-secret'],'client-id':['azure.activedirectory.client-id'],'tenant-id':['azure.activedirectory.tenant-id'],'PGP':['spring.datasource.password'],'PGU':['spring.datasource.username']}
self.expressEnv = {'URI':['REDIRECT_URI','FRONTEND_URI','BACKEND_API_ENDPOINT'],
'client-id':['CLIENT_ID'],'client-secret':['CLIENT_SECRET'],
'tenant-id':['TENANT_ID'],'PGP':['DB_PASSWORD'],'PGU':['DB_USER'],'DB_HOST':['DB_HOST'],
'DB_PORT':['DB_PORT'],'DB_NAME':['DB_NAME'],'EXPRESS_SESSION_SECRET':['EXPRESS_SESSION_SECRET']}
self.javaEnvLocation = 'backend/app/src/main/resources/application-secrets.properties'
self.expressEnvLocation = 'backend/web-bff/App/.env'
def readEnv(self):
with open('.env', 'r') as file:
for line in file:
[key, value] = line.split('=')
self.env[key] = value

def javaBuilder(self):
with open(self.javaEnvLocation, 'a+') as file:
for key in self.javaEnv:
if key in self.env:
value = self.env[key]
if value == '':
print(f'{key} is empty')
else:
for envName in self.javaEnv[key]:
file.seek(0)
if sum(line.count(f'{envName}') for line in file) == 0:
file.write(f'{envName}={value}\n')
else :
print(f'{key} not found in .env file')

def expressBuilder(self):
with open(self.expressEnvLocation, 'a+') as file:
for key in self.expressEnv:
if key in self.env:
value = self.env[key]
if value == '':
print(f'{key} is empty')
else:
for envName in self.expressEnv[key]:
file.seek(0)
if sum(line.count(f'{envName}') for line in file) == 0:
file.write(f'{envName}={value}\n')
else :
print(f'{key} not found in .env file')


if __name__ == '__main__':
env = envBuilder()
env.readEnv()
env.javaBuilder()
env.expressBuilder()
18 changes: 0 additions & 18 deletions envBuilder.sh

This file was deleted.

Empty file removed gha
Empty file.

0 comments on commit 96cad66

Please sign in to comment.