Replace manual upsert logic with SQLite native upsert in Docker CRUD repositories, enhance Ansible backup playbook with better error handling and file permissions, add favicon endpoint, and improve playbook editor UI with syntax highlighting, lint integration, quality badges, and enhanced code editing features
Tests / Backend Tests (Python) (3.10) (push) Has been cancelled
Tests / Backend Tests (Python) (3.11) (push) Has been cancelled
Tests / Backend Tests (Python) (3.12) (push) Has been cancelled
Tests / Frontend Tests (JS) (push) Has been cancelled
Tests / Integration Tests (push) Has been cancelled
Tests / All Tests Passed (push) Has been cancelled

This commit is contained in:
2025-12-17 15:36:49 -05:00
parent 785db4b302
commit 05087aa380
77 changed files with 15286 additions and 304 deletions
+24 -19
View File
@@ -87,23 +87,10 @@ class DockerContainerRepository:
labels: Optional[dict] = None,
compose_project: Optional[str] = None
) -> DockerContainer:
"""Create or update a container."""
existing = await self.get_by_container_id(host_id, container_id)
"""Create or update a container using SQLite upsert."""
from sqlalchemy.dialects.sqlite import insert as sqlite_insert
if existing:
existing.name = name
existing.image = image
existing.state = state
existing.status = status
existing.health = health
existing.created_at = created_at
existing.ports = ports
existing.labels = labels
existing.compose_project = compose_project
existing.last_update_at = datetime.utcnow()
return existing
container = DockerContainer(
stmt = sqlite_insert(DockerContainer).values(
host_id=host_id,
container_id=container_id,
name=name,
@@ -114,10 +101,28 @@ class DockerContainerRepository:
created_at=created_at,
ports=ports,
labels=labels,
compose_project=compose_project
compose_project=compose_project,
last_update_at=datetime.utcnow()
)
self.session.add(container)
return container
stmt = stmt.on_conflict_do_update(
index_elements=['host_id', 'container_id'],
set_={
'name': stmt.excluded.name,
'image': stmt.excluded.image,
'state': stmt.excluded.state,
'status': stmt.excluded.status,
'health': stmt.excluded.health,
'created_at': stmt.excluded.created_at,
'ports': stmt.excluded.ports,
'labels': stmt.excluded.labels,
'compose_project': stmt.excluded.compose_project,
'last_update_at': stmt.excluded.last_update_at
}
)
await self.session.execute(stmt)
# Return the upserted container
return await self.get_by_container_id(host_id, container_id)
async def delete_by_host(self, host_id: str) -> int:
"""Delete all containers for a host."""
+18 -13
View File
@@ -62,25 +62,30 @@ class DockerImageRepository:
size: Optional[int] = None,
created: Optional[datetime] = None
) -> DockerImage:
"""Create or update an image."""
existing = await self.get_by_image_id(host_id, image_id)
"""Create or update an image using SQLite upsert."""
from sqlalchemy.dialects.sqlite import insert as sqlite_insert
if existing:
existing.repo_tags = repo_tags
existing.size = size
existing.created = created
existing.last_update_at = datetime.utcnow()
return existing
image = DockerImage(
stmt = sqlite_insert(DockerImage).values(
host_id=host_id,
image_id=image_id,
repo_tags=repo_tags,
size=size,
created=created
created=created,
last_update_at=datetime.utcnow()
)
self.session.add(image)
return image
stmt = stmt.on_conflict_do_update(
index_elements=['host_id', 'image_id'],
set_={
'repo_tags': stmt.excluded.repo_tags,
'size': stmt.excluded.size,
'created': stmt.excluded.created,
'last_update_at': stmt.excluded.last_update_at
}
)
await self.session.execute(stmt)
# Return the upserted image
return await self.get_by_image_id(host_id, image_id)
async def delete_by_host(self, host_id: str) -> int:
"""Delete all images for a host."""
+18 -13
View File
@@ -55,25 +55,30 @@ class DockerVolumeRepository:
mountpoint: Optional[str] = None,
scope: Optional[str] = None
) -> DockerVolume:
"""Create or update a volume."""
existing = await self.get_by_name(host_id, name)
"""Create or update a volume using SQLite upsert."""
from sqlalchemy.dialects.sqlite import insert as sqlite_insert
if existing:
existing.driver = driver
existing.mountpoint = mountpoint
existing.scope = scope
existing.last_update_at = datetime.utcnow()
return existing
volume = DockerVolume(
stmt = sqlite_insert(DockerVolume).values(
host_id=host_id,
name=name,
driver=driver,
mountpoint=mountpoint,
scope=scope
scope=scope,
last_update_at=datetime.utcnow()
)
self.session.add(volume)
return volume
stmt = stmt.on_conflict_do_update(
index_elements=['host_id', 'name'],
set_={
'driver': stmt.excluded.driver,
'mountpoint': stmt.excluded.mountpoint,
'scope': stmt.excluded.scope,
'last_update_at': stmt.excluded.last_update_at
}
)
await self.session.execute(stmt)
# Return the upserted volume
return await self.get_by_name(host_id, name)
async def delete_by_host(self, host_id: str) -> int:
"""Delete all volumes for a host."""