Hi, we are using git to deploy code, when using DBT if you put the profile.yaml in the root git it find it automatically and replace environment variables like that password: "{{ env_var('DB_PASS') }}" in sling we are doing :
env_yaml_path = ROOT_DIR / "env.yaml"
if env_yaml_path.exists():
with open(env_yaml_path, "r", encoding="utf-8") as f:
env_yaml_content = f.read()
# Resolve ${VAR} patterns from environment variables (use [^}]+ to match any chars except })
def resolve_var(match):
var_name = match.group(1)
return os.environ.get(var_name, os.environ.get(var_name.upper(), match.group(0)))
env_yaml_content = re.sub(r'\$\{([^}]+)\}', resolve_var, env_yaml_content)
os.environ["SLING_ENV_YAML"] = env_yaml_content
print("> Resolved env.yaml:")
else:
print("Warning: env.yaml not found at root")
is there a simpler way not to replace the environment variables manually ? (we get the environment vars from secrets )