From a58e81803320fdb736b70765be9b4a96215fa7d9 Mon Sep 17 00:00:00 2001 From: Xyphuz Date: Wed, 18 May 2022 15:14:32 +0800 Subject: [PATCH] feat: imeplement value error in service initialization --- compose_viz/service.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/compose_viz/service.py b/compose_viz/service.py index acf28aa..f1da6a8 100644 --- a/compose_viz/service.py +++ b/compose_viz/service.py @@ -6,6 +6,10 @@ from compose_viz.extends import Extends 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: 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._ports = ports self._networks = networks