30 lines
997 B
Python
Executable File
30 lines
997 B
Python
Executable File
#!/usr/bin/env python3
|
|
"""CI diff: domains.yaml must cover all nginx server_name entries."""
|
|
import re, subprocess, sys, yaml
|
|
from pathlib import Path
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
REG = ROOT / "docs/architecture/REGISTRY/domains.yaml"
|
|
|
|
def nginx_names():
|
|
out = subprocess.run(["nginx", "-T"], capture_output=True, text=True, timeout=20).stdout
|
|
return set(re.findall(r"[a-z0-9][a-z0-9-]*\.buryans\.ru", out))
|
|
|
|
def main():
|
|
data = yaml.safe_load(REG.read_text())
|
|
declared = {x["name"] for x in data.get("domains", [])}
|
|
try:
|
|
live = nginx_names()
|
|
except Exception as e:
|
|
print("WARN nginx unavailable:", e, file=sys.stderr)
|
|
return 0
|
|
missing = live - declared
|
|
extra = declared - live
|
|
if missing:
|
|
print("MISSING in domains.yaml:", *sorted(missing), sep="\n ")
|
|
if extra:
|
|
print("EXTRA in domains.yaml:", *sorted(extra), sep="\n ")
|
|
return 1 if missing else 0
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|