Partially handle shell variable expansion

This commit is contained in:
David Boreham 2024-02-08 07:15:52 -07:00
parent 4956fab325
commit bb73ceb0f7

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