Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,9 @@ def _write_option_header(
file.write(f"#\n# Source: {value_with_source[1]}\n")
needs_separation = True
if include_env_vars:
file.write(f"#\n# Variable: AIRFLOW__{section_to_write.upper()}__{option.upper()}\n")
team_name, _, base_section = section_to_write.rpartition(TEAM_SECTION_SEPARATOR)
env_var = self._env_var_name(base_section, option, team_name=team_name or None)
file.write(f"#\n# Variable: {env_var}\n")
if extra_spacing:
file.write("#\n")
needs_separation = True
Expand Down
22 changes: 22 additions & 0 deletions shared/configuration/tests/configuration/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,28 @@ def test_write_materializes_provider_sources_in_requested_context(self):
test_conf.write(StringIO(), include_sources=True, include_providers=False)
assert "_provider_metadata_config_fallback_default_values" in test_conf.__dict__

@pytest.mark.parametrize(
("section", "expected_env_var"),
[
pytest.param("providers.test", "AIRFLOW__PROVIDERS_TEST__KEY1", id="dotted_section"),
pytest.param("team_a=test", "AIRFLOW__TEAM_A___TEST__KEY1", id="team_scoped_section"),
],
)
def test_write_shows_env_var_name_the_parser_reads(self, section, expected_env_var):
test_conf = AirflowConfigParser()
test_conf.read_string(f"[{section}]\nkey1 = value\n")

file = StringIO()
test_conf.write(
file,
section=section,
include_descriptions=False,
include_examples=False,
include_sources=False,
)

assert f"# Variable: {expected_env_var}\n" in file.getvalue()

def test_get_resolves_provider_metadata_fallback(self):
"""conf.get returns values from provider metadata for provider-only sections."""
provider_configs = [
Expand Down