feat: expand ~ and $HOME in mount target paths
- Add expand_container_path() helper that resolves ~/ and $HOME/ prefixes
- Add get_manifest_home_dir() to compute /home/{user.name} or /root from manifest
- Set ENV HOME=... and ENV USER=... in generated Dockerfile for runtime compatibility
- Pass home_dir through instance creation and startup pipeline
- Expand mount targets in apply_resolved_profile() for regular profile mounts
- Expand mapping targets in _resolve_git_mount_mappings() for git mounts
- Expand working_directory and volume targets in _modify_compose_file()
- Update _prepare_manifest_instance to return home_dir alongside image tag
- Fetch tool_type early in start_instance to determine home_dir before profile application
Quality gates: pytest 188 passed, frontend typecheck clean
Addresses: home-path-expansion
This commit is contained in:
@@ -8,6 +8,7 @@ from src.services.manifest_compiler import (
|
||||
compile_entrypoint,
|
||||
compute_image_tag,
|
||||
deep_merge,
|
||||
get_manifest_home_dir,
|
||||
merge_with_config,
|
||||
resolve_base,
|
||||
)
|
||||
@@ -161,6 +162,38 @@ class TestCompileDockerfile:
|
||||
df = compile_dockerfile(manifest)
|
||||
assert 'CMD ["/bin/bash"]' in df
|
||||
|
||||
def test_sets_home_env_for_user(self) -> None:
|
||||
manifest = {
|
||||
"base_image": "ubuntu:24.04",
|
||||
"name": "test",
|
||||
"user": {"name": "dev", "uid": 1001, "gid": 1001},
|
||||
}
|
||||
df = compile_dockerfile(manifest)
|
||||
assert "ENV HOME=/home/dev" in df
|
||||
assert "ENV USER=dev" in df
|
||||
|
||||
def test_no_home_env_without_user(self) -> None:
|
||||
manifest = {"base_image": "ubuntu:24.04", "name": "test"}
|
||||
df = compile_dockerfile(manifest)
|
||||
assert "ENV HOME=" not in df
|
||||
assert "ENV USER=" not in df
|
||||
|
||||
|
||||
class TestGetManifestHomeDir:
|
||||
"""Tests for get_manifest_home_dir."""
|
||||
|
||||
def test_with_user_name(self) -> None:
|
||||
manifest = {"user": {"name": "dev", "uid": 1001, "gid": 1001}}
|
||||
assert get_manifest_home_dir(manifest) == "/home/dev"
|
||||
|
||||
def test_without_user(self) -> None:
|
||||
manifest = {"base_image": "ubuntu:24.04"}
|
||||
assert get_manifest_home_dir(manifest) == "/root"
|
||||
|
||||
def test_with_empty_user_name(self) -> None:
|
||||
manifest = {"user": {"name": "", "uid": 1001, "gid": 1001}}
|
||||
assert get_manifest_home_dir(manifest) == "/root"
|
||||
|
||||
|
||||
class TestCompileEntrypoint:
|
||||
"""Tests for compile_entrypoint."""
|
||||
|
||||
Reference in New Issue
Block a user