https://slingdata.io logo
Hi, we are using git to deploy code,
# sling-help
i
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 )
f
hi @itamar s if you use the
env.yaml
file, you can just use
${KEY}
inside the body and pass the env var, it will resolve
but i see you're using
SLING_ENV_YAML
, and passing that instead of the
env.yaml
file, so that's why
it doesn't work for
SLING_ENV_YAML
, will fix that for next release
i
When using env.yaml it adds files to the root of the git project (.db ...) thats why we moved to SLING_ENV_YAML .