From 064da8092c41c3ad5e3e152c06e36d506994ca71 Mon Sep 17 00:00:00 2001 From: uccu Date: Sun, 15 May 2022 01:15:31 +0800 Subject: [PATCH] chore: add compose and service getter --- compose_viz/compose.py | 6 +++++- compose_viz/service.py | 48 +++++++++++++++++++++++++++++++++++------- 2 files changed, 45 insertions(+), 9 deletions(-) diff --git a/compose_viz/compose.py b/compose_viz/compose.py index 6c65a8a..4cafca1 100644 --- a/compose_viz/compose.py +++ b/compose_viz/compose.py @@ -4,7 +4,11 @@ from compose_viz.service import Service class Compose: def __init__(self, services: List[Service]) -> None: - self.services = services + self._services = services def extract_networks(self) -> List[str]: raise NotImplementedError + + @property + def services(self): + return self._services diff --git a/compose_viz/service.py b/compose_viz/service.py index 6e42483..5b809e3 100644 --- a/compose_viz/service.py +++ b/compose_viz/service.py @@ -3,11 +3,43 @@ from typing import List class Service: def __init__(self, name: str, image: str, ports: List[str] = [], networks: List[str] = [], volumes: List[str] = [], depends_on: List[str] = [], links: List[str] = [], extends: List[str] = []) -> None: - self.name = name - self.image = image - self.ports = ports - self.networks = networks - self.volumes = volumes - self.depends_on = depends_on - self.links = links - self.extends = extends + self._name = name + self._image = image + self._ports = ports + self._networks = networks + self._volumes = volumes + self._depends_on = depends_on + self._links = links + self._extends = extends + + @property + def name(self): + return self._name + + @property + def image(self): + return self._image + + @property + def ports(self): + return self._ports + + @property + def networks(self): + return self._networks + + @property + def volumes(self): + return self._volumes + + @property + def depends_on(self): + return self._depends_on + + @property + def links(self): + return self._links + + @property + def extends(self): + return self._extends