Treat SQL-backed Django models as the source of truth for pobsync configuration, exporting runtime YAML only as a compatibility layer for the existing engine. Add a database-driven scheduler command, Docker scheduler services, schedule run-state fields, and tests for scheduler, config export, and retention behavior.
24 lines
896 B
Python
24 lines
896 B
Python
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
from typing import Any
|
|
|
|
from django.conf import settings
|
|
from django.core.management.base import BaseCommand
|
|
|
|
from pobsync_backend.config_repository import export_runtime_configs
|
|
|
|
|
|
class Command(BaseCommand):
|
|
help = "Export Django database configs to pobsync runtime YAML files."
|
|
|
|
def add_arguments(self, parser) -> None:
|
|
parser.add_argument("--prefix", default=settings.POBSYNC_HOME, help="Pobsync home directory")
|
|
parser.add_argument("--host", default=None, help="Export only one enabled host")
|
|
|
|
def handle(self, *args: Any, **options: Any) -> None:
|
|
written = export_runtime_configs(prefix=Path(options["prefix"]), host=options["host"])
|
|
for path in written:
|
|
self.stdout.write(str(path))
|
|
self.stdout.write(self.style.SUCCESS(f"Exported {len(written)} config file(s)."))
|