아바타 저장소 승격 계약을 완성
This commit is contained in:
parent
ac9b702688
commit
ccdcfcd2f5
36 changed files with 14734 additions and 222 deletions
61
scripts/probe-public-runtime-database-identity.py
Normal file
61
scripts/probe-public-runtime-database-identity.py
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Emit only the credential-free identity of the connected runtime database."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import asyncio
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
REPO_ROOT = Path(__file__).resolve().parents[1]
|
||||
API_ROOT = REPO_ROOT / "apps" / "api"
|
||||
if str(API_ROOT) not in sys.path:
|
||||
sys.path.insert(0, str(API_ROOT))
|
||||
if str(Path(__file__).resolve().parent) not in sys.path:
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent))
|
||||
|
||||
from app.config import settings # noqa: E402
|
||||
from public_runtime_database_identity import ( # noqa: E402
|
||||
connected_database_target_sha256,
|
||||
)
|
||||
|
||||
|
||||
async def _probe() -> str:
|
||||
import asyncpg
|
||||
|
||||
connection = await asyncpg.connect(
|
||||
settings.database_url,
|
||||
command_timeout=settings.db_command_timeout,
|
||||
)
|
||||
try:
|
||||
return await connected_database_target_sha256(connection)
|
||||
finally:
|
||||
await connection.close()
|
||||
|
||||
|
||||
def main() -> int:
|
||||
try:
|
||||
digest = asyncio.run(_probe())
|
||||
except BaseException:
|
||||
print(
|
||||
json.dumps(
|
||||
{"status": "failed", "reason": "database_identity_probe_failed"},
|
||||
ensure_ascii=True,
|
||||
separators=(",", ":"),
|
||||
)
|
||||
)
|
||||
return 1
|
||||
print(
|
||||
json.dumps(
|
||||
{"status": "passed", "database_target_sha256": digest},
|
||||
ensure_ascii=True,
|
||||
separators=(",", ":"),
|
||||
)
|
||||
)
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue