Initial curated ITWorx_MCP_Hub source from 368fba691ea8d23403b4d56b53b5ec670d7c5020
This commit is contained in:
commit
cb5be898ea
663 files changed
+82674
No files matched your search
@@ -0,0 +1,5 @@
|
||||
"""Control-plane projection for registered Gitea repositories."""
|
||||
|
||||
from .registry import GiteaRegistration, registration_from_project
|
||||
|
||||
__all__ = ["GiteaRegistration", "registration_from_project"]
|
||||
@@ -0,0 +1,55 @@
|
||||
"""Build a Gitea connector projection from scoped Hub configuration."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from packages.connector_kit import GiteaError, GiteaSettings, RegisteredRepository
|
||||
from packages.hub_core.domain import Connector, Project
|
||||
|
||||
|
||||
class GiteaRegistration:
|
||||
"""Immutable connector settings plus the exact project repository allowlist."""
|
||||
|
||||
def __init__(
|
||||
self, settings: GiteaSettings, repositories: tuple[RegisteredRepository, ...]
|
||||
) -> None:
|
||||
self.settings = settings
|
||||
self.repositories = repositories
|
||||
|
||||
|
||||
def registration_from_project(project: Project, connector: Connector) -> GiteaRegistration:
|
||||
if connector.type != "gitea" or not connector.enabled:
|
||||
raise GiteaError(
|
||||
"GITEA_CONNECTOR_NOT_ENABLED", "Gitea connector is not enabled for this project"
|
||||
)
|
||||
if connector.project_id != project.id or project.repository_provider != "gitea":
|
||||
raise GiteaError(
|
||||
"GITEA_REPOSITORY_NOT_REGISTERED", "project repository is not configured for Gitea"
|
||||
)
|
||||
if not connector.endpoint or not connector.credential_reference:
|
||||
raise GiteaError(
|
||||
"GITEA_CONNECTOR_MISCONFIGURED", "Gitea endpoint or secret reference is missing"
|
||||
)
|
||||
settings_values = {
|
||||
"timeout_seconds": connector.configuration.get(
|
||||
"timeout_seconds", connector.configuration.get("requestTimeoutSeconds", 15)
|
||||
),
|
||||
"max_page_size": connector.configuration.get(
|
||||
"max_page_size", connector.configuration.get("maxPageSize", 100)
|
||||
),
|
||||
}
|
||||
settings = GiteaSettings(
|
||||
base_url=connector.endpoint,
|
||||
token_reference=connector.credential_reference,
|
||||
**settings_values,
|
||||
)
|
||||
if not project.repository_owner or not project.repository_name:
|
||||
raise GiteaError("GITEA_REPOSITORY_NOT_REGISTERED", "project has no registered repository")
|
||||
repository = RegisteredRepository(
|
||||
repository_ref=f"{project.slug}-repository",
|
||||
project_id=project.id,
|
||||
owner=project.repository_owner,
|
||||
name=project.repository_name,
|
||||
source_uri=f"itworx-git://{project.slug}/{project.slug}-repository",
|
||||
private=project.classification != "public",
|
||||
)
|
||||
return GiteaRegistration(settings, (repository,))
|
||||
Reference in new issue
Block a user