feat(infra-net): read .infra*.yaml + tag rows by environment

Glob every .infra*.yaml (was .infra.yaml only) so .infra.dev.yaml variants are
reconciled too; add an ENV column + environment field to the inventory. A project
can now appear once per environment (prod DO + dev mac).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Natalie 2026-06-29 10:20:13 -04:00
parent 1bd8f0f8b9
commit 4c2312e173

View file

@ -25,10 +25,10 @@ OUT = os.path.join(NET_TOOLS, "data", "infra-net.json")
# Where deployable projects live (each may carry a root .infra.yaml).
ROOTS = [
os.path.join(CODE, "@applications", "*", ".infra.yaml"),
os.path.join(CODE, "@projects", "@cocottetech", "@platform", "codebase", "@features", "*", ".infra.yaml"),
os.path.join(CODE, "@projects", "@cocottetech", ".infra.yaml"),
os.path.join(CODE, "@projects", "@magic-civilization", ".infra.yaml"),
os.path.join(CODE, "@applications", "*", ".infra*.yaml"),
os.path.join(CODE, "@projects", "@cocottetech", "@platform", "codebase", "@features", "*", ".infra*.yaml"),
os.path.join(CODE, "@projects", "@cocottetech", ".infra*.yaml"),
os.path.join(CODE, "@projects", "@magic-civilization", ".infra*.yaml"),
]
@ -76,6 +76,7 @@ def main() -> int:
db = m.get("database", {}) or {}
rows.append({
"project": m["project"],
"environment": m.get("environment", "prod"),
"provider": m.get("provider"),
"host": host,
"port": port,
@ -87,11 +88,11 @@ def main() -> int:
rows.sort(key=lambda r: (r["host"] or "~", r["port"] or 0))
w = max([len(r["project"]) for r in rows] + [7])
print(f"\n infra-net — {len(rows)} services across {len(hosts)} hosts\n")
print(f" {'PROJECT'.ljust(w)} {'HOST'.ljust(8)} {'PORT'.ljust(5)} {'PROVIDER'.ljust(12)} DB / DEPS")
print(f" {'PROJECT'.ljust(w)} {'ENV'.ljust(4)} {'HOST'.ljust(8)} {'PORT'.ljust(5)} {'PROVIDER'.ljust(12)} DB / DEPS")
for r in rows:
deps = (" deps:" + ",".join(r["depends_on"])) if r["depends_on"] else ""
dbp = (r["db"] or "") + deps
print(f" {r['project'].ljust(w)} {str(r['host']).ljust(8)} {str(r['port'] or '').ljust(5)} {str(r['provider']).ljust(12)} {dbp}")
print(f" {r['project'].ljust(w)} {str(r['environment']).ljust(4)} {str(r['host']).ljust(8)} {str(r['port'] or '').ljust(5)} {str(r['provider']).ljust(12)} {dbp}")
if problems:
print("\n PROBLEMS:")