mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 10:13:58 +00:00
- Add build-context helper to copy Docker context safely (ignore runtime data, keep symlinks) - Update UI and core actions to use ~/.prole/build and shared copy helper - Add/adjust tests and scripts; introduce knoe ops helpers and update manifests Co-authored-by: Junie <junie@jetbrains.com>
42 lines
1.4 KiB
Python
42 lines
1.4 KiB
Python
import os
|
|
from pathlib import Path
|
|
|
|
from knoe.core.build_context import copy_build_context_dir
|
|
|
|
|
|
def test_copy_build_context_dir_ignores_data_and_keeps_dangling_symlinks(tmp_path: Path):
|
|
source_dir = tmp_path / "source"
|
|
build_dir = tmp_path / "build"
|
|
source_dir.mkdir()
|
|
|
|
(source_dir / "Dockerfile").write_text("FROM scratch\n")
|
|
(source_dir / "keep.txt").write_text("ok")
|
|
|
|
# Create a runtime-like `data/` tree that may contain problematic entries.
|
|
pgdata = source_dir / "data" / "pvc-123" / "pgdata"
|
|
pgdata.mkdir(parents=True)
|
|
if hasattr(os, "symlink"):
|
|
os.symlink("does_not_exist", pgdata / "pg_wal")
|
|
|
|
# Also ensure we can copy dangling symlinks outside ignored directories.
|
|
if hasattr(os, "symlink"):
|
|
os.symlink("missing_target", source_dir / "dangling_link")
|
|
|
|
# Pre-create build_dir with stale content to ensure it gets replaced.
|
|
build_dir.mkdir()
|
|
(build_dir / "stale.txt").write_text("stale")
|
|
|
|
copy_build_context_dir(source_dir, build_dir)
|
|
|
|
assert (build_dir / "Dockerfile").exists()
|
|
assert (build_dir / "keep.txt").read_text() == "ok"
|
|
assert not (build_dir / "stale.txt").exists()
|
|
|
|
# `data/` should never be part of the Docker build context.
|
|
assert not (build_dir / "data").exists()
|
|
|
|
if hasattr(os, "symlink"):
|
|
link = build_dir / "dangling_link"
|
|
assert link.is_symlink()
|
|
assert os.readlink(link) == "missing_target"
|