sync
This commit is contained in:
@@ -20,4 +20,5 @@ requires = ["uv_build>=0.9.17,<0.10.0"]
|
||||
build-backend = "uv_build"
|
||||
|
||||
[tool.pyright]
|
||||
analysis.diagnosticMode = "workspace"
|
||||
#reportExplicitAny = false
|
||||
|
||||
3
pyrightconfig.json
Normal file
3
pyrightconfig.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"basedpyright.analysis.diagnosticMode": "workspace"
|
||||
}
|
||||
@@ -23,9 +23,10 @@ class App(ReplaceStatic):
|
||||
class Url(ReplaceStatic):
|
||||
src = ReplaceDynamic("url")
|
||||
|
||||
@property
|
||||
@override
|
||||
def __str__(self) -> str:
|
||||
val = super(Url, self).__str__()
|
||||
def dest(self) -> str:
|
||||
val = super(Url, self).dest
|
||||
if not val:
|
||||
return val
|
||||
return ".".join((val, "ccamper7", "net"))
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from collections.abc import Callable
|
||||
from dataclasses import dataclass, field
|
||||
from itertools import chain
|
||||
from typing import ClassVar, Self, final, override
|
||||
from typing import ClassVar, Self, final
|
||||
|
||||
|
||||
def format_src(src: str) -> str:
|
||||
@@ -21,14 +21,6 @@ class ReplaceUnique:
|
||||
def auto_format(cls, src: str, dest: str):
|
||||
return cls(format_src(src), dest)
|
||||
|
||||
# @override
|
||||
# def __str__(self) -> str:
|
||||
# if not self.dest:
|
||||
# return ""
|
||||
# if isinstance(self.dest, str):
|
||||
# return self.dest
|
||||
# return self.dest()
|
||||
|
||||
|
||||
@final
|
||||
@dataclass(frozen=True, slots=True)
|
||||
@@ -56,18 +48,18 @@ class ReplaceDynamic:
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class ReplaceStatic:
|
||||
src: ClassVar[ReplaceDynamic]
|
||||
dest: None | str | Callable[[], str]
|
||||
_dest: None | str | Callable[[], str]
|
||||
|
||||
def __call__(self, string: str) -> str:
|
||||
return string.replace(self.src.fmt, str(self))
|
||||
return string.replace(self.src.fmt, self.dest)
|
||||
|
||||
@override
|
||||
def __str__(self) -> str:
|
||||
if not self.dest:
|
||||
@property
|
||||
def dest(self) -> str:
|
||||
if not self._dest:
|
||||
return ""
|
||||
if isinstance(self.dest, str):
|
||||
return self.dest
|
||||
return self.dest()
|
||||
if isinstance(self._dest, str):
|
||||
return self._dest
|
||||
return self._dest()
|
||||
|
||||
@classmethod
|
||||
def two_stage(cls, dest: str) -> tuple[Self, ReplaceDynamic]:
|
||||
|
||||
@@ -27,7 +27,7 @@ class NetArgs:
|
||||
|
||||
@override
|
||||
def __str__(self) -> str:
|
||||
return f"{OrgData.org_app!s}_{self.name}"
|
||||
return f"{OrgData.org_app.dest}_{self.name}"
|
||||
|
||||
@property
|
||||
def external(self) -> bool:
|
||||
|
||||
@@ -3,7 +3,7 @@ from typing import Self, final, override
|
||||
|
||||
from docker_compose.cfg.compose_paths import ServicePath
|
||||
from docker_compose.cfg.org import OrgData, Url
|
||||
from docker_compose.cfg.replace import ReplaceStatic, ReplaceUnique
|
||||
from docker_compose.cfg.replace import ReplaceUnique
|
||||
from docker_compose.compose.services_yaml import (
|
||||
HealthCheck,
|
||||
ServiceYamlRead,
|
||||
@@ -17,10 +17,10 @@ from docker_compose.util.Ts import T_Primitive
|
||||
class Service:
|
||||
_traefik_labels = frozenset(
|
||||
(
|
||||
f"traefik.http.routers.{OrgData.org_app!s}.rule=Host(`{Url!s}`)",
|
||||
f"traefik.http.routers.{OrgData.org_app.src}.entrypoints=websecure",
|
||||
f"traefik.docker.network={OrgData.org_app.src}_proxy",
|
||||
f"traefik.http.routers.{OrgData.org_app.src}.tls.certresolver=le",
|
||||
f"traefik.http.routers.{OrgData.org_app.dest}.rule=Host(`{Url.src}`)",
|
||||
f"traefik.http.routers.{OrgData.org_app.dest}.entrypoints=websecure",
|
||||
f"traefik.docker.network={OrgData.org_app.dest}_proxy",
|
||||
f"traefik.http.routers.{OrgData.org_app.dest}.tls.certresolver=le",
|
||||
)
|
||||
)
|
||||
|
||||
@@ -57,7 +57,7 @@ class Service:
|
||||
return cls.from_dict(path.fqdn, path.as_dict)
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, fqdn: ReplaceStatic, data: ServiceYamlRead) -> Self:
|
||||
def from_dict(cls, fqdn: ReplaceUnique, data: ServiceYamlRead) -> Self:
|
||||
# helper = ServiceYamlProps(data)
|
||||
labels = frozenset(data.get("labels", ()))
|
||||
# ports = (f'"{p}"' for p in data.get("ports", ()))
|
||||
|
||||
Reference in New Issue
Block a user