Skip to content

Commit 34ea198

Browse files
author
leoguillaume
committed
remove assertion to secrets of other services
1 parent 05c9003 commit 34ea198

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

app/schemas/core/settings.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,15 +168,16 @@ def config_file_exists(cls, config_file):
168168

169169
@model_validator(mode="after")
170170
def setup_config(cls, values) -> Any:
171-
with open(file=values.config_file, mode="r") as f:
172-
file_content = f.read()
173-
f.close()
171+
with open(file=values.config_file, mode="r") as file:
172+
file_content = file.read()
173+
file.close()
174174

175175
# replace environment variables (pattern: ${VARIABLE_NAME})
176176
for match in set(re.findall(pattern=r"\${[A-Z_]+}", string=file_content)):
177177
variable = match.replace("${", "").replace("}", "")
178-
assert os.getenv(variable), f"Environment variable {variable} not found or empty to replace {match}."
179-
file_content = file_content.replace(match, os.environ[variable])
178+
if not os.getenv(variable):
179+
logging.warning(f"Environment variable {variable} not found or empty to replace {match}.")
180+
file_content = file_content.replace(match, os.getenv(variable, match))
180181

181182
config = Config(**yaml.safe_load(file_content))
182183

compose.dev.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ services:
4444
postgres:
4545
condition: service_healthy
4646

47-
4847
postgres:
4948
extends:
5049
file: compose.yml

ui/settings.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from functools import lru_cache
2+
import logging
23
import os
34
import re
45
from typing import Any, Optional
@@ -43,15 +44,16 @@ def config_file_exists(cls, config_file):
4344

4445
@model_validator(mode="after")
4546
def setup_config(cls, values) -> Any:
46-
with open(file=values.config_file, mode="r") as f:
47-
file_content = f.read()
48-
f.close()
47+
with open(file=values.config_file, mode="r") as file:
48+
file_content = file.read()
49+
file.close()
4950

5051
# replace environment variables (pattern: ${VARIABLE_NAME})
5152
for match in set(re.findall(pattern=r"\${[A-Z_]+}", string=file_content)):
5253
variable = match.replace("${", "").replace("}", "")
53-
assert os.getenv(variable), f"Environment variable {variable} not found or empty to replace {match}."
54-
file_content = file_content.replace(match, os.environ[variable])
54+
if not os.getenv(variable):
55+
logging.info(f"Environment variable {variable} not found or empty to replace {match}.")
56+
file_content = file_content.replace(match, os.getenv(variable, match))
5557

5658
config = Config(**yaml.safe_load(file_content))
5759

0 commit comments

Comments
 (0)