Skip to content

Commit 267b5ac

Browse files
nresareclaude
andcommitted
Make images.toml optional
Return an empty image mapping when images.toml is missing and update the regression test to cover that behavior. This lets manifest-builder run without image overrides while still rejecting empty or invalid images.toml files. Co-Authored-By: Codex Haiku 4.5 <noreply@anthropic.com>
1 parent 1183d44 commit 267b5ac

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎src/manifest_builder/config.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,20 @@ def load_images(config_dir: Path) -> dict[str, str]:
7373
Returns a dict mapping template variable names to image references, e.g.:
7474
{"git_image": "alpine/git:2.47.2", "hugo_image": "floryn90/hugo:0.155.3-alpine"}
7575
76+
If images.toml is absent, returns an empty dict so image overrides remain optional.
77+
7678
Args:
7779
config_dir: Directory containing images.toml
7880
7981
Returns:
8082
Dict mapping image variable names to full image references (repo:version)
8183
8284
Raises:
83-
FileNotFoundError: If images.toml is not found in config_dir
8485
ValueError: If images.toml is invalid or missing required fields
8586
"""
8687
images_file = config_dir / "images.toml"
8788
if not images_file.exists():
88-
raise FileNotFoundError(f"images.toml not found in {config_dir}")
89+
return {}
8990

9091
data = tomllib.loads(images_file.read_text())
9192

‎tests/test_config.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,13 +1102,12 @@ def test_load_images_returns_image_dict(tmp_path: Path) -> None:
11021102
}
11031103

11041104

1105-
def test_load_images_raises_when_missing(tmp_path: Path) -> None:
1106-
"""load_images should raise FileNotFoundError when images.toml is missing."""
1105+
def test_load_images_returns_empty_dict_when_missing(tmp_path: Path) -> None:
1106+
"""load_images should return an empty dict when images.toml is missing."""
11071107
conf_dir = tmp_path / "conf"
11081108
conf_dir.mkdir()
11091109

1110-
with pytest.raises(FileNotFoundError, match="images.toml not found"):
1111-
load_images(conf_dir)
1110+
assert load_images(conf_dir) == {}
11121111

11131112

11141113
def test_load_images_converts_hyphens_to_underscores(tmp_path: Path) -> None:

0 commit comments

Comments
 (0)