Auto-update: Thu Aug 8 18:23:37 PDT 2024
This commit is contained in:
parent
ba7aa79229
commit
de0b869f03
1 changed files with 8 additions and 8 deletions
|
@ -160,22 +160,22 @@ class Configuration(BaseModel):
|
||||||
return data
|
return data
|
||||||
|
|
||||||
|
|
||||||
def resolve_string_placeholders(self, value: str, secrets_data: Dict[str, Any], home_dir: Path) -> Any:
|
def resolve_string_placeholders(self, value: str) -> Any:
|
||||||
pattern = r'\{\{\s*([^}]+)\s*\}\}'
|
pattern = r'\{\{\s*([^}]+)\s*\}\}'
|
||||||
matches = re.findall(pattern, value)
|
matches = re.findall(pattern, value)
|
||||||
|
|
||||||
for match in matches:
|
for match in matches:
|
||||||
parts = match.split('.')
|
parts = match.split('.')
|
||||||
if len(parts) == 1: # Internal reference
|
if len(parts) == 1: # Internal reference
|
||||||
replacement = str(home_dir / parts[0].lower())
|
replacement = getattr(self, parts[0], str(Path.home() / parts[0].lower()))
|
||||||
elif len(parts) == 2 and parts[0] == 'Dir':
|
elif len(parts) == 2 and parts[0] == 'Dir':
|
||||||
replacement = str(home_dir / parts[1].lower())
|
replacement = getattr(self, parts[1], str(Path.home() / parts[1].lower()))
|
||||||
elif len(parts) == 2 and parts[0] == 'ENV':
|
elif len(parts) == 2 and parts[0] == 'ENV':
|
||||||
replacement = os.getenv(parts[1], '')
|
replacement = os.getenv(parts[1], '')
|
||||||
elif len(parts) == 2 and parts[0] == 'SECRET':
|
elif len(parts) == 2 and parts[0] == 'SECRET':
|
||||||
replacement = secrets_data.get(parts[1], '')
|
replacement = getattr(self, parts[1].strip(), '')
|
||||||
if not replacement:
|
if not replacement:
|
||||||
warn(f"Secret '{parts[1]}' not found in secrets file")
|
warn(f"Secret '{parts[1].strip()}' not found in secrets file")
|
||||||
else:
|
else:
|
||||||
replacement = value
|
replacement = value
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue