[T20] domains registry + nginx diff checker
This commit is contained in:
1 parent
0e5e308647
commit
446a60b329
2 files changed
+181
No files matched your search
Executable
+29
@@ -0,0 +1,29 @@
|
||||
#!/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())
|
||||
Reference in new issue
Block a user