feat: route SBOM writes to Nexus behind flag
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 1s
Build and Publish Multi-Context Image / build-and-push (push) Successful in 24s

Assistant: codex
Assistant-Model: gpt-5.6-sol
Assistant-Session: 01a028f0-a42f-7582-89a8-ebaad7343834
This commit is contained in:
tegwick 2026-08-22 19:55:08 +02:00
parent d01ae3971d
commit b75234a533
7 changed files with 111 additions and 4 deletions

View file

@ -21,12 +21,18 @@ def reads_from_nexus() -> bool:
return settings.sbom_nexus_read_mode == "nexus"
async def get_json(
def writes_to_nexus() -> bool:
return settings.sbom_nexus_write_mode == "nexus"
async def request_json(
method: str,
path: str,
*,
params: dict[str, Any] | None = None,
body: dict[str, Any] | None = None,
) -> Any:
"""Fetch one Nexus resource; never fall back silently to legacy storage."""
"""Call Nexus; never fall back silently to legacy storage."""
if not settings.sbom_nexus_url:
raise SBOMNexusError(503, "SBOM Nexus read mode is enabled without SBOM_NEXUS_URL")
@ -35,7 +41,7 @@ async def get_json(
base_url=settings.sbom_nexus_url.rstrip("/"),
timeout=settings.sbom_nexus_timeout_seconds,
) as client:
response = await client.get(path, params=params)
response = await client.request(method, path, params=params, json=body)
except httpx.RequestError as exc:
raise SBOMNexusError(502, f"SBOM Nexus is unavailable: {exc.__class__.__name__}") from exc
@ -54,3 +60,11 @@ async def get_json(
return response.json()
except ValueError as exc:
raise SBOMNexusError(502, "SBOM Nexus returned invalid JSON") from exc
async def get_json(path: str, *, params: dict[str, Any] | None = None) -> Any:
return await request_json("GET", path, params=params)
async def post_json(path: str, *, body: dict[str, Any]) -> Any:
return await request_json("POST", path, body=body)