""" Service Registry Schema for Provisioning Platform Defines platform services (orchestrator, control-center, CoreDNS, Gitea, OCI registry, etc.) and their lifecycle management configuration. Version: 1.0.0 """ schema ServiceRegistry: """Platform service registry configuration""" services: {str: ServiceDefinition} check: len(services) > 0, "At least one service must be defined" schema ServiceDefinition: """Individual service definition""" name: str type: "platform" | "infrastructure" | "utility" category: "orchestration" | "auth" | "dns" | "git" | "registry" | "api" | "ui" | "monitoring" description?: str # Service requirements required_for: [str] = [] # Operations requiring this service dependencies: [str] = [] # Other services this depends on conflicts: [str] = [] # Services that conflict # Deployment configuration deployment: ServiceDeployment # Health check health_check: HealthCheck # Startup configuration startup: StartupConfig = StartupConfig {} # Resource limits resources?: ResourceLimits check: len(name) > 0, "Service name cannot be empty" not (name in dependencies), "Service cannot depend on itself" len(set(dependencies) & set(conflicts)) == 0, \ "Service cannot both depend on and conflict with same service" schema ServiceDeployment: """Service deployment configuration""" mode: "binary" | "docker" | "docker-compose" | "kubernetes" | "remote" binary?: BinaryDeployment docker?: DockerDeployment docker_compose?: DockerComposeDeployment kubernetes?: KubernetesDeployment remote?: RemoteDeployment check: (mode == "binary" and binary != Undefined) or \ (mode == "docker" and docker != Undefined) or \ (mode == "docker-compose" and docker_compose != Undefined) or \ (mode == "kubernetes" and kubernetes != Undefined) or \ (mode == "remote" and remote != Undefined), \ "Deployment configuration must match deployment mode" schema BinaryDeployment: """Binary service deployment""" binary_path: str args: [str] = [] working_dir?: str env: {str: str} = {} user?: str group?: str check: len(binary_path) > 0, "Binary path cannot be empty" schema DockerDeployment: """Docker container deployment""" image: str container_name: str ports: [str] = [] volumes: [str] = [] environment: {str: str} = {} command?: [str] networks: [str] = [] restart_policy: "no" | "always" | "on-failure" | "unless-stopped" = "unless-stopped" check: len(image) > 0, "Docker image cannot be empty" len(container_name) > 0, "Container name cannot be empty" schema DockerComposeDeployment: """Docker Compose deployment""" compose_file: str service_name: str project_name?: str env_file?: str check: len(compose_file) > 0, "Compose file path cannot be empty" len(service_name) > 0, "Service name cannot be empty" schema KubernetesDeployment: """Kubernetes deployment""" namespace: str deployment_name: str kubeconfig?: str manifests_path?: str helm_chart?: HelmChart check: len(namespace) > 0, "Namespace cannot be empty" len(deployment_name) > 0, "Deployment name cannot be empty" schema HelmChart: """Helm chart configuration""" chart: str release_name: str repo_url?: str version?: str values_file?: str check: len(chart) > 0, "Chart name cannot be empty" len(release_name) > 0, "Release name cannot be empty" schema RemoteDeployment: """Remote service deployment""" endpoint: str tls_enabled: bool = True auth_token_path?: str cert_path?: str check: len(endpoint) > 0, "Endpoint cannot be empty" schema HealthCheck: """Service health check configuration""" type: "http" | "tcp" | "command" | "file" | "none" http?: HttpHealthCheck tcp?: TcpHealthCheck command?: CommandHealthCheck file?: FileHealthCheck interval: int = 10 retries: int = 3 timeout: int = 5 check: (type == "http" and http != Undefined) or \ (type == "tcp" and tcp != Undefined) or \ (type == "command" and command != Undefined) or \ (type == "file" and file != Undefined) or \ (type == "none"), \ "Health check configuration must match health check type" interval > 0, "Interval must be positive" retries > 0, "Retries must be positive" timeout > 0, "Timeout must be positive" schema HttpHealthCheck: """HTTP health check""" endpoint: str expected_status: int = 200 method: "GET" | "POST" | "HEAD" = "GET" headers: {str: str} = {} check: len(endpoint) > 0, "Endpoint cannot be empty" expected_status >= 100 and expected_status < 600, \ "HTTP status must be valid (100-599)" schema TcpHealthCheck: """TCP health check""" host: str port: int check: len(host) > 0, "Host cannot be empty" port > 0 and port <= 65535, "Port must be 1-65535" schema CommandHealthCheck: """Command-based health check""" command: str expected_exit_code: int = 0 check: len(command) > 0, "Command cannot be empty" schema FileHealthCheck: """File-based health check""" path: str must_exist: bool = True check: len(path) > 0, "Path cannot be empty" schema StartupConfig: """Service startup configuration""" auto_start: bool = False start_timeout: int = 60 start_order: int = 100 restart_on_failure: bool = True max_restarts: int = 3 check: start_timeout > 0, "Start timeout must be positive" start_order > 0, "Start order must be positive" max_restarts >= 0, "Max restarts must be non-negative" schema ResourceLimits: """Resource limits for service""" cpu_limit?: str # e.g., "2", "500m" memory_limit?: str # e.g., "1Gi", "512Mi" disk_limit?: str # e.g., "10Gi" schema ServiceState: """Service runtime state""" name: str status: "running" | "stopped" | "failed" | "starting" | "stopping" | "unknown" pid?: int started_at?: str uptime?: int health_status: "healthy" | "unhealthy" | "unknown" = "unknown" last_health_check?: str restart_count: int = 0 schema ServiceOperation: """Service operation request""" service_name: str operation: "start" | "stop" | "restart" | "reload" | "health-check" force: bool = False timeout?: int check: len(service_name) > 0, "Service name cannot be empty"