feat: add extends
This commit is contained in:
parent
8eb932577d
commit
012fd8d698
3 changed files with 21 additions and 1 deletions
12
compose_viz/extends.py
Normal file
12
compose_viz/extends.py
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
class Extends:
|
||||||
|
def __init__(self, from_file: str, service_name: str):
|
||||||
|
self._from_file = from_file
|
||||||
|
self._service_name = service_name
|
||||||
|
|
||||||
|
@property
|
||||||
|
def from_file(self):
|
||||||
|
return self._from_file
|
||||||
|
|
||||||
|
@property
|
||||||
|
def service_name(self):
|
||||||
|
return self._service_name
|
|
@ -1,8 +1,10 @@
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
|
from compose_viz.extends import Extends
|
||||||
|
|
||||||
|
|
||||||
class Service:
|
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:
|
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
|
||||||
self._image = image
|
self._image = image
|
||||||
self._ports = ports
|
self._ports = ports
|
||||||
|
|
6
tests/test_extends.py
Normal file
6
tests/test_extends.py
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import pytest
|
||||||
|
from compose_viz.service import Service
|
||||||
|
|
||||||
|
def test_parse_file():
|
||||||
|
with pytest.raises(ValueError, match=r"Both image and extends are not defined in service 'frontend', aborting."):
|
||||||
|
Service(name='frontend')
|
Loading…
Reference in a new issue