From c8e7753756cd7363ff6dc143b2c55cf6fa44cacb Mon Sep 17 00:00:00 2001 From: Patrick Ogenstad Date: Thu, 29 Jan 2026 10:00:23 +0100 Subject: [PATCH] Add task to generate JSON schema for .infrahub.yml files --- tasks.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tasks.py b/tasks.py index c4c82004..b2434df0 100644 --- a/tasks.py +++ b/tasks.py @@ -1,4 +1,5 @@ import asyncio +import json import sys from pathlib import Path from shutil import which @@ -266,3 +267,17 @@ def generate_python_sdk(context: Context) -> None: # noqa: ARG001 """Generate documentation for the Python SDK.""" _generate_infrahub_sdk_configuration_documentation() _generate_infrahub_sdk_template_documentation() + + +@task +def generate_repository_jsonschema(context: Context) -> None: + """Generate JSON schema file for repository configuration. https://github.com/opsmill/infrahub-jsonschema""" + from infrahub_sdk.schema.repository import InfrahubRepositoryConfig + + repository_jsonschema = MAIN_DIRECTORY_PATH / "generated" / "repository-config" / "develop.json" + + with context.cd(MAIN_DIRECTORY_PATH): + schema = json.dumps(InfrahubRepositoryConfig.model_json_schema(), indent=4) + repository_jsonschema.parent.mkdir(parents=True, exist_ok=True) + repository_jsonschema.write_text(schema) + print(f"Wrote to {repository_jsonschema}")