sync
This commit is contained in:
34
src/docker_compose/domain/render/bind_vols.py
Normal file
34
src/docker_compose/domain/render/bind_vols.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Iterator
|
||||
from pathlib import Path
|
||||
from typing import TYPE_CHECKING, final
|
||||
|
||||
from pydantic.dataclasses import dataclass
|
||||
|
||||
from docker_compose import ROOT
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from docker_compose.domain.render.render import Render
|
||||
|
||||
|
||||
@final
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class BindVols:
|
||||
# data_rep = Replace("data", str(DATA_ROOT))
|
||||
render: Render
|
||||
|
||||
def __call__(self):
|
||||
# def mk_bind_vols(self) -> None:
|
||||
for path in self:
|
||||
path.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
def __iter__(self) -> Iterator[Path]:
|
||||
for app in self.render.template.services:
|
||||
for vol in app.volumes:
|
||||
path = Path(self.render.org_data(vol.src))
|
||||
if ROOT not in path.parents:
|
||||
continue
|
||||
if not path.is_dir():
|
||||
continue
|
||||
yield path
|
||||
Reference in New Issue
Block a user