2022-05-07 18:42:14 +02:00
|
|
|
from typing import List
|
|
|
|
|
2022-05-18 09:12:24 +02:00
|
|
|
from compose_viz.extends import Extends
|
|
|
|
|
2022-05-07 18:42:14 +02:00
|
|
|
|
|
|
|
class Service:
|
2022-05-18 09:12:24 +02:00
|
|
|
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:
|
2022-05-14 19:15:31 +02:00
|
|
|
self._name = name
|
2022-05-18 09:14:32 +02:00
|
|
|
|
|
|
|
if image is None and extends is None:
|
|
|
|
raise ValueError(f"Both image and extends are not defined in service '{name}', aborting.")
|
|
|
|
|
2022-05-14 19:15:31 +02:00
|
|
|
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
|
2022-05-14 20:27:33 +02:00
|
|
|
|
2022-05-14 19:15:31 +02:00
|
|
|
@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
|