This commit is contained in:
2025-12-15 00:52:57 -06:00
parent e874da07f8
commit cef96db21a

View File

@@ -11,14 +11,14 @@ TCo_NetABC = TypeVar("TCo_NetABC", bound=T_NetAbc, covariant=True)
class ServiceYamlAbc[T_net: T_NetAbc](TypedDict):
command: NotRequired[list[str]]
container_name: str
entrypoint: list[str]
container_name: NotRequired[str]
entrypoint: NotRequired[list[str]]
environment: NotRequired[dict[str, T_Primitive]]
image: str
labels: NotRequired[list[str]]
logging: dict[str, str]
logging: NotRequired[dict[str, str]]
networks: NotRequired[list[T_net]]
restart: str
restart: NotRequired[str]
security_opt: NotRequired[list[str]]
user: NotRequired[str]
volumes: NotRequired[list[str]]
@@ -46,7 +46,7 @@ type T_Compose = ServiceYaml | TraefikServiceYaml
class ServiceAbc[T_net: T_NetAbc, T_Yaml: T_Compose](metaclass=ABCMeta):
command: tuple[str, ...] | None
container_name: str
entrypoint: tuple[str, ...]
entrypoint: tuple[str, ...] | None
environment: dict[str, T_Primitive] | None
image: str
labels: frozenset[str] | None
@@ -61,10 +61,14 @@ class ServiceAbc[T_net: T_NetAbc, T_Yaml: T_Compose](metaclass=ABCMeta):
def from_dict(cls, data: T_Yaml) -> Self:
command = data.get("command")
volumes = data.get("volumes")
entry = data.get("entrypoint")
name = data.get("container_name")
if name is None:
raise KeyError
return cls(
tuple(command) if command else None,
data["container_name"],
tuple(data["entrypoint"]),
name,
tuple(entry) if entry else None,
data.get("environment"),
data["image"],
_get_labels(data),