- add startup/shutdown scripts that render a Caddyfile from JSON config and run health checks - add Python utilities and a sample sites.json for declarative multi-site configuration - document the workflow and ignore generated Caddy state artifacts - normalize double-quote style across challenge workflow controllers, nodes, and tests
29 lines
883 B
Python
29 lines
883 B
Python
"""Load site metadata without rewriting the Caddyfile."""
|
|
from __future__ import annotations
|
|
|
|
import json
|
|
import os
|
|
from pathlib import Path
|
|
from typing import List
|
|
|
|
from .render_caddy import SiteMetadata, _expand, _to_bool
|
|
|
|
|
|
def load_metadata(config_path: Path) -> List[SiteMetadata]:
|
|
with config_path.open("r", encoding="utf-8") as fh:
|
|
data = json.load(fh)
|
|
|
|
sites = data.get("sites", [])
|
|
metadata: List[SiteMetadata] = []
|
|
for raw_site in sites:
|
|
site = _expand(raw_site)
|
|
health_cfg = site.get("health_check") or {}
|
|
metadata.append(
|
|
SiteMetadata(
|
|
name=site.get("name", "site"),
|
|
health_url=health_cfg.get("url", ""),
|
|
skip_healthcheck=_to_bool(health_cfg.get("skip"), default=False),
|
|
app_url=site.get("app_url", ""),
|
|
)
|
|
)
|
|
return metadata
|