feat: imeplement value error in service initialization

This commit is contained in:
Xyphuz 2022-05-18 15:14:32 +08:00
parent 012fd8d698
commit a58e818033

View file

@ -6,6 +6,10 @@ from compose_viz.extends import Extends
class Service: class Service:
def __init__(self, name: str, image: str = None, ports: List[str] = [], networks: List[str] = [], volumes: List[str] = [], depends_on: List[str] = [], links: List[str] = [], extends: Extends = None) -> None: def __init__(self, name: str, image: str = None, ports: List[str] = [], networks: List[str] = [], volumes: List[str] = [], depends_on: List[str] = [], links: List[str] = [], extends: Extends = None) -> None:
self._name = name self._name = name
if image is None and extends is None:
raise ValueError(f"Both image and extends are not defined in service '{name}', aborting.")
self._image = image self._image = image
self._ports = ports self._ports = ports
self._networks = networks self._networks = networks