Skip to content

Commit 0ea4883

Browse files
committed
Normalize the vlaue of the stored runtime
1 parent 0446c77 commit 0ea4883

4 files changed

Lines changed: 30 additions & 2 deletions

File tree

src/vibepod/core/config.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,14 @@ def deep_merge(base: dict[str, Any], override: dict[str, Any]) -> dict[str, Any]
147147
return merged
148148

149149

150+
def _parse_container_runtime(value: str) -> str:
151+
return value.strip().lower()
152+
153+
150154
def _apply_env(config: dict[str, Any]) -> dict[str, Any]:
151155
mappings: dict[str, tuple[str, Any]] = {
152156
"VP_DEFAULT_AGENT": ("default_agent", str),
153-
"VP_CONTAINER_RUNTIME": ("container_runtime", str),
157+
"VP_CONTAINER_RUNTIME": ("container_runtime", _parse_container_runtime),
154158
"VP_CONTAINER_USERNS_MODE": ("container_userns_mode", lambda x: x.strip() or None),
155159
"VP_AUTO_PULL": ("auto_pull", lambda x: x.lower() == "true"),
156160
"VP_LOG_LEVEL": ("log_level", str),

src/vibepod/core/runtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ def resolve_runtime(
185185
available = detect_available_runtimes()
186186

187187
if explicit is not None:
188-
explicit = explicit.lower()
188+
explicit = explicit.strip().lower()
189189
if explicit not in SUPPORTED_RUNTIMES:
190190
raise RuntimeError(
191191
f"Unknown container runtime '{explicit}'. "

tests/test_config.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,15 @@ def test_container_userns_mode_env_override(monkeypatch, tmp_path: Path) -> None
139139
assert config["container_userns_mode"] == "keep-id"
140140

141141

142+
def test_container_runtime_env_override_is_normalized(
143+
monkeypatch, tmp_path: Path
144+
) -> None:
145+
monkeypatch.setenv("VP_CONFIG_DIR", str(tmp_path))
146+
monkeypatch.setenv("VP_CONTAINER_RUNTIME", " PodMan ")
147+
config = get_config()
148+
assert config["container_runtime"] == "podman"
149+
150+
142151
def test_per_agent_auto_pull_override(monkeypatch, tmp_path: Path) -> None:
143152
monkeypatch.setenv("VP_CONFIG_DIR", str(tmp_path))
144153
global_config = tmp_path / "config.yaml"

tests/test_runtime.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,21 @@ def test_resolve_runtime_rejects_unavailable_prompt_choice(monkeypatch) -> None:
107107
runtime.resolve_runtime()
108108

109109

110+
def test_resolve_runtime_normalizes_env_value(monkeypatch) -> None:
111+
monkeypatch.setattr(
112+
runtime,
113+
"detect_available_runtimes",
114+
lambda: {
115+
"podman": "unix:///run/user/1000/podman/podman.sock",
116+
},
117+
)
118+
monkeypatch.setenv("VP_CONTAINER_RUNTIME", " PodMan ")
119+
120+
selected = runtime.resolve_runtime()
121+
122+
assert selected == ("podman", "unix:///run/user/1000/podman/podman.sock")
123+
124+
110125
def test_get_manager_wraps_runtime_preference_errors(monkeypatch) -> None:
111126
def _raise_runtime_preference_error(**kwargs) -> tuple[str, str]:
112127
del kwargs

0 commit comments

Comments
 (0)