ads
This commit is contained in:
@@ -3,12 +3,10 @@ API Controller for A/D Infrastructure
|
||||
Manages docker-compose services with authentication
|
||||
"""
|
||||
import os
|
||||
import subprocess
|
||||
import asyncio
|
||||
from datetime import datetime
|
||||
from typing import Optional, List
|
||||
from typing import Optional, List, Tuple
|
||||
from fastapi import FastAPI, HTTPException, Depends, Header
|
||||
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials
|
||||
from pydantic import BaseModel
|
||||
import asyncpg
|
||||
from contextlib import asynccontextmanager
|
||||
@@ -27,14 +25,11 @@ class ServiceCreate(BaseModel):
|
||||
git_url: Optional[str] = None
|
||||
|
||||
class ServiceAction(BaseModel):
|
||||
action: str # start, stop, restart
|
||||
action: str
|
||||
|
||||
class GitPullRequest(BaseModel):
|
||||
auto: bool = False
|
||||
|
||||
class LogRequest(BaseModel):
|
||||
lines: int = 100
|
||||
|
||||
# Auth dependency
|
||||
async def verify_token(authorization: str = Header(None)):
|
||||
if not authorization or not authorization.startswith("Bearer "):
|
||||
@@ -114,7 +109,7 @@ def parse_docker_status(ps_output: str) -> dict:
|
||||
'containers': containers
|
||||
}
|
||||
|
||||
async def run_docker_compose_command(service_path: str, command: List[str]) -> tuple[int, str, str]:
|
||||
async def run_docker_compose_command(service_path: str, command: List[str]) -> Tuple[int, str, str]:
|
||||
"""Run docker-compose command and return (returncode, stdout, stderr)"""
|
||||
compose_file = find_compose_file(service_path)
|
||||
if not compose_file:
|
||||
|
||||
Reference in New Issue
Block a user