prole/etc/render_manifest.py
chrisfu f2c9012cce Refactor installation and initialization logic, and expand test coverage
- install.py: Major update including configuration variable expansion, improved k3s/k3d handling, and enhanced installation logic.

- etc/ scripts: Significant refactoring of initialization scripts (Kerberos, Port Forwards, Garage Store, etc.).

- Port Forwards: Transitioned from XML to port-mappings.conf for managing kubectl port-forwards.

- Status Reporting: Improved status checking for common services.

- Infrastructure: Updated Ansible inventory and rsyslog role configurations.

- Tests: Added a comprehensive suite of tests for 'etc' initialization scripts in prole/tests/etc/.

- Documentation: Added prole-db-documentation-mcp-architecture.md.

- General: Updated Dockerfiles and various helper scripts.
2026-02-13 21:36:39 -08:00

114 lines
3.2 KiB
Python

#!/usr/bin/env python3
import os
import sys
from pathlib import Path
def _strip_blocks(text: str) -> str:
lines = text.splitlines()
out = []
skip_block = False
skip_indent = 0
i = 0
while i < len(lines):
line = lines[i]
stripped = line.lstrip()
if skip_block:
if not stripped:
i += 1
continue
indent = len(line) - len(stripped)
if indent > skip_indent:
i += 1
continue
skip_block = False
skip_indent = 0
continue
if stripped.startswith("affinity:"):
block_indent = len(line) - len(stripped)
block_lines = [line]
j = i + 1
while j < len(lines):
next_line = lines[j]
next_stripped = next_line.lstrip()
if not next_stripped:
block_lines.append(next_line)
j += 1
continue
next_indent = len(next_line) - len(next_stripped)
if next_indent <= block_indent:
break
block_lines.append(next_line)
j += 1
if any("kubernetes.io/hostname" in bl for bl in block_lines):
i = j
continue
out.extend(block_lines)
i = j
continue
if stripped.startswith("selector:"):
block_indent = len(line) - len(stripped)
block_lines = [line]
j = i + 1
while j < len(lines):
next_line = lines[j]
next_stripped = next_line.lstrip()
if not next_stripped:
block_lines.append(next_line)
j += 1
continue
next_indent = len(next_line) - len(next_stripped)
if next_indent <= block_indent:
break
block_lines.append(next_line)
j += 1
if any("prole.storage/" in bl for bl in block_lines):
i = j
continue
out.extend(block_lines)
i = j
continue
if stripped.startswith("nodeSelector:"):
skip_block = True
skip_indent = len(line) - len(stripped)
i += 1
continue
if stripped.startswith("storageClassName:") and "prole-iscsi" in stripped:
i += 1
continue
out.append(line)
i += 1
tail = "\n" if text.endswith("\n") else ""
return "\n".join(out) + tail
def main() -> int:
if len(sys.argv) < 2:
print("Usage: render_manifest.py <manifest.yaml>", file=sys.stderr)
return 2
path = Path(sys.argv[1]).expanduser()
if not path.exists():
print(f"ERROR: manifest not found: {path}", file=sys.stderr)
return 1
text = path.read_text()
mode = os.environ.get("PROLE_MODE", "").strip().lower()
if mode != "k3d":
sys.stdout.write(text)
return 0
sys.stdout.write(_strip_blocks(text))
return 0
if __name__ == "__main__":
raise SystemExit(main())