Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion blueprint/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,9 @@ def show_vars(path: str, profile: str | None, unused: bool, root: str | None):
config_path = Path(path)

try:
config, _ = render_yaml_template(config_path, use_airflow_context=False)
config, _ = render_yaml_template(
config_path, context={"profile": profile}, use_airflow_context=False
)
vars_root = Path(root) if root else Path.cwd()
declared = bp_vars.declared_profiles(config_path, search_root=vars_root)
resolved = bp_vars.collect(config, config_path, profile=profile, search_root=vars_root)
Expand Down
18 changes: 18 additions & 0 deletions tests/test_vars.py
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,24 @@ def test_profile_available_in_jinja(self, tmp_path):

assert config["description"] == "prod run"

def test_vars_command_renders_the_active_profile(self, tmp_path):
from click.testing import CliRunner

from blueprint.cli import cli

p = dag_file(
tmp_path,
'dag_id: d_{{ profile }}\ndescription: "{{ profile }} run"\n'
"steps:\n s:\n blueprint: b\n",
)

result = CliRunner().invoke(
cli, ["vars", str(p), "--profile", "local", "--root", str(tmp_path)]
)

assert result.exit_code == 0, result.output
assert "undefined" not in result.output


class TestNoVars:
def test_config_without_vars_is_untouched(self, tmp_path):
Expand Down
Loading