Skip to content

check_template_bundles

rhiza_hooks.check_template_bundles

Validate template-bundles.yml structure and consistency.

This script validates the template bundles configuration file to ensure: 1. Valid YAML syntax 2. Required fields are present 3. Bundle dependencies reference existing bundles 4. File paths follow expected patterns 5. Examples reference valid bundles

The script reads .rhiza/template.yml to find the template repository, then fetches template-bundles.yml from that remote repository.

The implementation is split across focused modules — :mod:rhiza_hooks._bundles_fetch (obtaining a document), :mod:rhiza_hooks._bundles_validate (structural checks), and :mod:rhiza_hooks._bundles_config (reading .rhiza/template.yml). This module is the CLI/orchestration layer and re-exports those helpers so rhiza_hooks.check_template_bundles remains the single public import surface.

Those three modules are themselves private, so the package's public surface is unchanged by the split. Within them a leading underscore marks a helper with no caller outside its own file — which is why this module imports only unprefixed names from them.

Exit codes

0 - Validation passed 1 - Validation failed

main(argv=None, fetcher=fetch_remote_bundles)

Main entry point.

fetcher is the one place the real network call is named. The console script takes the default; a test passes a fake document source as an argument rather than rebinding this module's fetch_remote_bundles global.

Source code in rhiza_hooks/check_template_bundles.py
def main(argv: list[str] | None = None, fetcher: Fetcher = fetch_remote_bundles) -> int:
    """Main entry point.

    ``fetcher`` is the one place the real network call is named. The console script
    takes the default; a test passes a fake document source as an argument rather than
    rebinding this module's ``fetch_remote_bundles`` global.
    """
    _ensure_utf8_stdout()

    args = _parse_args(argv)

    if args.offline:
        print("Offline mode: skipping remote template bundles validation")
        return 0

    config_path = _get_config_path(args)

    # Load and validate configuration. A None result means validation was
    # skipped (missing config or no templates field); both cases pass.
    result = _load_and_validate_config(config_path)
    if result is None:
        return 0
    config, templates_set = result

    return _run_remote_validation(config, templates_set, config_path, args.retries, args.timeout, fetcher)