From cb7a6e4f2e2e3c4634f5361c52bb29c687a5882b Mon Sep 17 00:00:00 2001 From: tegwick Date: Mon, 15 Jun 2026 10:11:41 +0200 Subject: [PATCH] Bundle hub registration schema in the installed package Load the schema from reuse_surface/hub/ next to store.py and declare package-data so pip install includes the YAML in site-packages. Fixes hub register 500 in the container image. --- pyproject.toml | 5 +- .../hub/hub-registration.schema.yaml | 148 ++++++++++++++++++ reuse_surface/hub/store.py | 4 +- 3 files changed, 153 insertions(+), 4 deletions(-) create mode 100644 reuse_surface/hub/hub-registration.schema.yaml diff --git a/pyproject.toml b/pyproject.toml index 50ead13..1b19b4b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -26,4 +26,7 @@ reuse-surface = "reuse_surface.cli:main" [tool.setuptools.packages.find] where = ["."] -include = ["reuse_surface*"] \ No newline at end of file +include = ["reuse_surface*"] + +[tool.setuptools.package-data] +reuse_surface = ["hub/hub-registration.schema.yaml"] \ No newline at end of file diff --git a/reuse_surface/hub/hub-registration.schema.yaml b/reuse_surface/hub/hub-registration.schema.yaml new file mode 100644 index 0000000..84bff23 --- /dev/null +++ b/reuse_surface/hub/hub-registration.schema.yaml @@ -0,0 +1,148 @@ +$schema: https://json-schema.org/draft/2020-12/schema +$id: https://reuse-surface.local/schemas/hub-registration.schema.yaml +title: Federation Hub Repo Registration +description: > + Schema for a repository registration stored by the federation hub service. + Extends federation source fields with hub metadata. +type: object +additionalProperties: false +required: [repo, url, enabled, domain] +properties: + repo: + type: string + minLength: 1 + pattern: '^[a-z][a-z0-9-]*$' + description: Stable repository slug (primary key) + url: + type: string + format: uri + pattern: '^https?://' + description: Published HTTP(S) URL to capabilities.yaml + enabled: + type: boolean + required: + type: boolean + default: false + domain: + type: string + minLength: 1 + description: Capability domain label (e.g. helix_forge) + description: + type: string + cache_ttl_seconds: + type: integer + minimum: 0 + default: 86400 + auth_env: + type: string + minLength: 1 + description: > + Hub-side environment variable name holding a token for fetching this + source index (not exposed in API responses) + auth_header: + type: string + minLength: 1 + default: Authorization + registered_at: + type: string + format: date-time + description: Hub metadata — set on create + updated_at: + type: string + format: date-time + description: Hub metadata — set on create/update + registered_by: + type: string + description: Optional actor label from write token or client header +$defs: + registration_request: + type: object + additionalProperties: false + required: [repo, url, domain] + properties: + repo: + type: string + minLength: 1 + pattern: '^[a-z][a-z0-9-]*$' + url: + type: string + format: uri + pattern: '^https?://' + enabled: + type: boolean + default: true + required: + type: boolean + default: false + domain: + type: string + minLength: 1 + description: + type: string + cache_ttl_seconds: + type: integer + minimum: 0 + default: 86400 + auth_env: + type: string + minLength: 1 + auth_header: + type: string + minLength: 1 + default: Authorization + registered_by: + type: string + registration_update: + type: object + additionalProperties: false + properties: + url: + type: string + format: uri + pattern: '^https?://' + enabled: + type: boolean + required: + type: boolean + domain: + type: string + minLength: 1 + description: + type: string + cache_ttl_seconds: + type: integer + minimum: 0 + auth_env: + type: string + minLength: 1 + auth_header: + type: string + minLength: 1 + registered_by: + type: string + minProperties: 1 + repo_list: + type: object + additionalProperties: false + required: [repos, count] + properties: + repos: + type: array + items: + $ref: '#' + count: + type: integer + minimum: 0 + error_response: + type: object + additionalProperties: false + required: [error, message] + properties: + error: + type: string + message: + type: string + details: + type: array + items: + type: string \ No newline at end of file diff --git a/reuse_surface/hub/store.py b/reuse_surface/hub/store.py index 2a3b9ad..56acd19 100644 --- a/reuse_surface/hub/store.py +++ b/reuse_surface/hub/store.py @@ -9,9 +9,7 @@ from typing import Any import yaml from jsonschema import Draft202012Validator -from reuse_surface.registry import ROOT - -SCHEMA_PATH = ROOT / "schemas" / "hub-registration.schema.yaml" +SCHEMA_PATH = Path(__file__).resolve().parent / "hub-registration.schema.yaml" def _utc_now() -> str: