This commit is contained in:
2026-05-28 14:26:02 +07:00
parent b0443d5950
commit 991d6f5257
13 changed files with 464 additions and 22 deletions

View File

@@ -1,8 +1,8 @@
from __future__ import annotations
from app.config import settings
from app.models.schemas import AppManifest, DebComponent
from app.utils.validators import validate_url_host
from app.models.schemas import AppManifest, DebComponent, DockerComponent
from app.utils.validators import validate_docker_registry, validate_url_host
class ManifestValidator:
@@ -15,12 +15,17 @@ class ManifestValidator:
component = DebComponent.model_validate(raw_component).model_dump(by_alias=True)
validate_url_host(component["downloadUrl"], settings.allowed_download_hosts)
components.append(component)
elif component_type == "docker" and not settings.allow_docker:
raise ValueError("Docker components are not enabled on this Agent")
elif component_type == "docker_compose" and not settings.allow_docker_compose:
raise ValueError("Docker Compose components are not enabled on this Agent")
elif component_type == "docker":
if not settings.allow_docker:
raise ValueError("Docker components are not enabled on this Agent")
component = DockerComponent.model_validate(raw_component).model_dump(by_alias=True)
validate_docker_registry(component["image"], settings.allowed_docker_registries)
components.append(component)
elif component_type == "docker_compose":
if not settings.allow_docker_compose:
raise ValueError("Docker Compose components are not enabled on this Agent")
raise ValueError("Docker Compose components are not implemented on this Agent")
else:
raise ValueError(f"Unsupported component type: {component_type}")
manifest["components"] = sorted(components, key=lambda item: item.get("installOrder", 10))
return manifest