Process environment variables defined in compose files #736

Merged
dboreham merged 3 commits from dboreham/compose-env-vars into main 2024-02-08 19:41:58 +00:00
Showing only changes of commit bb73ceb0f7 - Show all commits

View File

@ -17,6 +17,7 @@ from kubernetes import client
import os
from pathlib import Path
import subprocess
import re
from typing import Set, Mapping, List
from stack_orchestrator.opts import opts
@ -220,9 +221,16 @@ def merge_envs(a: Mapping[str, str], b: Mapping[str, str]) -> Mapping[str, str]:
return result
# DANGER: implement me
def _expand_shell_vars(raw_val: str) -> str:
return raw_val
# could be: <string> or ${<env-var-name>} or ${<env-var-name>:-<default-value>}
# TODO: implement support for variable substitution and default values
# if raw_val is like ${<something>} print a warning and substitute an empty string
# otherwise return raw_val
match = re.search(r"^\$\{(.*)\}$", raw_val)
if match:
print(f"WARNING: found unimplemented environment variable substitution: {raw_val}")
else:
return raw_val
# TODO: handle the case where the same env var is defined in multiple places