chore: apply pre-commit hooks
This commit is contained in:
parent
a5f767b170
commit
1ec80883f0
79 changed files with 1807 additions and 1451 deletions
4
.github/workflows/cd.yml
vendored
4
.github/workflows/cd.yml
vendored
|
@ -10,9 +10,9 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
||||
- name: Build and Publish to PyPi
|
||||
uses: JRubics/poetry-publish@v1.10
|
||||
with:
|
||||
pypi_token: ${{ secrets.PYPI_TOKEN }}
|
||||
extra_build_dependency_packages: "graphviz"
|
||||
extra_build_dependency_packages: "graphviz"
|
||||
|
|
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
|
@ -12,19 +12,19 @@ jobs:
|
|||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
||||
- name: Switch to Current Branch
|
||||
run: git checkout ${{ env.BRANCH }}
|
||||
|
||||
- run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y graphviz
|
||||
|
||||
|
||||
- name: Setup Python 3.10.4
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: '3.10.4'
|
||||
|
||||
|
||||
- name: Validate Test Files
|
||||
run: |
|
||||
docker-compose -f tests/in/000001.yaml config -q
|
||||
|
@ -90,7 +90,7 @@ jobs:
|
|||
docker-compose -f tests/in/111101.yaml config -q
|
||||
docker-compose -f tests/in/111110.yaml config -q
|
||||
docker-compose -f tests/in/111111.yaml config -q
|
||||
|
||||
|
||||
- name: Setup Poetry
|
||||
uses: Gr1N/setup-poetry@v7
|
||||
with:
|
||||
|
|
10
.github/workflows/release-tagged-version.yml
vendored
10
.github/workflows/release-tagged-version.yml
vendored
|
@ -18,19 +18,19 @@ jobs:
|
|||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
|
||||
- name: Switch to Current Branch
|
||||
run: git checkout ${{ env.BRANCH }}
|
||||
|
||||
- run: |
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y graphviz
|
||||
|
||||
|
||||
- name: Setup Python 3.10.4
|
||||
uses: actions/setup-python@v3
|
||||
with:
|
||||
python-version: '3.10.4'
|
||||
|
||||
|
||||
- name: Setup Poetry
|
||||
uses: Gr1N/setup-poetry@v7
|
||||
with:
|
||||
|
@ -38,7 +38,7 @@ jobs:
|
|||
- run: |
|
||||
poetry install --no-root
|
||||
poetry build
|
||||
|
||||
|
||||
- name: "Release Tagged Version"
|
||||
uses: "marvinpinto/action-automatic-releases@latest"
|
||||
with:
|
||||
|
@ -46,4 +46,4 @@ jobs:
|
|||
prerelease: false
|
||||
files: |
|
||||
LICENSE
|
||||
dist/**
|
||||
dist/**
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -158,4 +158,4 @@ cython_debug/
|
|||
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
||||
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
||||
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
||||
#.idea/
|
||||
#.idea/
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
from compose_viz.cli import start_cli
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
start_cli()
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
from enum import Enum
|
||||
import typer
|
||||
from typing import Optional
|
||||
|
||||
import typer
|
||||
|
||||
from compose_viz import __app_name__, __version__
|
||||
from compose_viz.parser import Parser
|
||||
from compose_viz.graph import Graph
|
||||
from compose_viz.parser import Parser
|
||||
|
||||
|
||||
class VisualizationFormats(str, Enum):
|
||||
|
@ -47,7 +49,7 @@ def compose_viz(
|
|||
help="Show the version of compose-viz.",
|
||||
callback=_version_callback,
|
||||
is_eager=True,
|
||||
)
|
||||
),
|
||||
) -> None:
|
||||
parser = Parser()
|
||||
compose = parser.parse(input_path)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
from typing import List
|
||||
|
||||
from compose_viz.service import Service
|
||||
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
from typing import Optional
|
||||
|
||||
|
||||
class Extends:
|
||||
def __init__(self, service_name: str, from_file: str = None):
|
||||
def __init__(self, service_name: str, from_file: Optional[str] = None):
|
||||
self._service_name = service_name
|
||||
self._from_file = from_file
|
||||
|
||||
|
@ -9,4 +12,4 @@ class Extends:
|
|||
|
||||
@property
|
||||
def from_file(self):
|
||||
return self._from_file
|
||||
return self._from_file
|
||||
|
|
|
@ -5,17 +5,17 @@ from compose_viz.compose import Compose
|
|||
|
||||
def apply_vertex_style(type) -> dict:
|
||||
style = {
|
||||
'service': {
|
||||
'shape': 'component',
|
||||
"service": {
|
||||
"shape": "component",
|
||||
},
|
||||
'volume': {
|
||||
'shape': 'folder',
|
||||
"volume": {
|
||||
"shape": "folder",
|
||||
},
|
||||
'network': {
|
||||
'shape': 'pentagon',
|
||||
"network": {
|
||||
"shape": "pentagon",
|
||||
},
|
||||
'port': {
|
||||
'shape': 'circle',
|
||||
"port": {
|
||||
"shape": "circle",
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -24,18 +24,18 @@ def apply_vertex_style(type) -> dict:
|
|||
|
||||
def apply_edge_style(type) -> dict:
|
||||
style = {
|
||||
'ports': {
|
||||
'style': 'solid',
|
||||
"ports": {
|
||||
"style": "solid",
|
||||
},
|
||||
'links': {
|
||||
'style': 'solid',
|
||||
"links": {
|
||||
"style": "solid",
|
||||
},
|
||||
'volumes': {
|
||||
'style': 'dashed',
|
||||
"volumes": {
|
||||
"style": "dashed",
|
||||
},
|
||||
"depends_on": {
|
||||
"style": "dotted",
|
||||
},
|
||||
'depends_on': {
|
||||
'style': 'dotted',
|
||||
}
|
||||
}
|
||||
|
||||
return style[type]
|
||||
|
@ -44,7 +44,7 @@ def apply_edge_style(type) -> dict:
|
|||
class Graph:
|
||||
def __init__(self, compose: Compose, filename: str) -> None:
|
||||
self.dot = graphviz.Digraph()
|
||||
self.dot.attr('graph', background='#ffffff', pad='0.5', ratio='fill')
|
||||
self.dot.attr("graph", background="#ffffff", pad="0.5", ratio="fill")
|
||||
self.compose = compose
|
||||
self.filename = filename
|
||||
|
||||
|
@ -56,17 +56,17 @@ class Graph:
|
|||
|
||||
def render(self, format: str, cleanup: bool = True) -> None:
|
||||
for service in self.compose.services:
|
||||
self.add_vertex(service.name, 'service')
|
||||
self.add_vertex(service.name, "service")
|
||||
for network in service.networks:
|
||||
self.add_vertex("net#" + network, 'network')
|
||||
self.add_edge(service.name, "net#" + network, 'links')
|
||||
self.add_vertex("net#" + network, "network")
|
||||
self.add_edge(service.name, "net#" + network, "links")
|
||||
for volume in service.volumes:
|
||||
self.add_vertex(volume, 'volume')
|
||||
self.add_edge(service.name, volume, 'links')
|
||||
self.add_vertex(volume, "volume")
|
||||
self.add_edge(service.name, volume, "links")
|
||||
for port in service.ports:
|
||||
self.add_vertex(port, 'port')
|
||||
self.add_edge(service.name, port, 'ports')
|
||||
self.add_vertex(port, "port")
|
||||
self.add_edge(service.name, port, "ports")
|
||||
for depends_on in service.depends_on:
|
||||
self.dot.edge(depends_on, service.name, 'depends_on')
|
||||
self.dot.edge(depends_on, service.name, "depends_on")
|
||||
|
||||
self.dot.render(outfile=self.filename, format=format, cleanup=cleanup)
|
||||
|
|
|
@ -1,48 +1,60 @@
|
|||
from re import S
|
||||
from compose_viz.compose import Compose
|
||||
from compose_viz.compose import Service
|
||||
from typing import List, Optional
|
||||
|
||||
from ruamel.yaml import YAML
|
||||
|
||||
from compose_viz.compose import Compose, Service
|
||||
|
||||
|
||||
class Parser:
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def parse(self, file_path: str) -> Compose:
|
||||
# validate input file using `docker-compose config -q sys.argv[1]` first
|
||||
# load the yaml file
|
||||
with open(file_path, "r") as f:
|
||||
try:
|
||||
yaml = YAML(typ='safe', pure=True)
|
||||
yaml = YAML(typ="safe", pure=True)
|
||||
yaml_data = yaml.load(f)
|
||||
except YAML.YAMLError as exc:
|
||||
raise YAML.YAMLError
|
||||
except Exception as e:
|
||||
raise Exception(f"Error parsing file {file_path}: {e}")
|
||||
|
||||
# validate the yaml file
|
||||
if not yaml_data:
|
||||
print("Error: empty yaml file")
|
||||
raise ValueError
|
||||
|
||||
if not yaml_data.get("services"):
|
||||
print("Error: no services found")
|
||||
raise ValueError
|
||||
|
||||
# parse services data into Service objects
|
||||
services_data = yaml_data["services"]
|
||||
services = []
|
||||
|
||||
for service, service_name in zip(services_data.values(), services_data.keys()):
|
||||
#print("name: {}".format(service_name))
|
||||
# print("name: {}".format(service_name))
|
||||
|
||||
service_image: Optional[str] = None
|
||||
if service.get("image"):
|
||||
service_image = service["image"]
|
||||
#print("image: {}".format(service_image))
|
||||
# print("image: {}".format(service_image))
|
||||
|
||||
service_networks: List[str] = []
|
||||
if service.get("networks"):
|
||||
if(type(service["networks"]) is list):
|
||||
if type(service["networks"]) is list:
|
||||
service_networks = service["networks"]
|
||||
else:
|
||||
service_networks = list(service["networks"].keys())
|
||||
#print("networks: {}".format(service_networks))
|
||||
services.append(Service(
|
||||
name=service_name,
|
||||
image=service_image,
|
||||
networks=service_networks,
|
||||
))
|
||||
# print("networks: {}".format(service_networks))
|
||||
|
||||
services.append(
|
||||
Service(
|
||||
name=service_name,
|
||||
image=service_image,
|
||||
networks=service_networks,
|
||||
)
|
||||
)
|
||||
|
||||
# create Compose object
|
||||
compose = Compose(services)
|
||||
|
||||
|
|
|
@ -1,10 +1,20 @@
|
|||
from typing import List
|
||||
from typing import List, Optional
|
||||
|
||||
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:
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
image: Optional[str] = None,
|
||||
ports: List[str] = [],
|
||||
networks: List[str] = [],
|
||||
volumes: List[str] = [],
|
||||
depends_on: List[str] = [],
|
||||
links: List[str] = [],
|
||||
extends: Optional[Extends] = None,
|
||||
) -> None:
|
||||
self._name = name
|
||||
|
||||
if image is None and extends is None:
|
||||
|
|
|
@ -23,4 +23,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -7,4 +7,4 @@ services:
|
|||
service: base
|
||||
cli:
|
||||
extends:
|
||||
service: common
|
||||
service: common
|
||||
|
|
|
@ -25,4 +25,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -5,4 +5,4 @@ services:
|
|||
ports:
|
||||
- "8000:5000"
|
||||
redis:
|
||||
image: "redis:alpine"
|
||||
image: "redis:alpine"
|
||||
|
|
|
@ -29,4 +29,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -12,4 +12,4 @@ services:
|
|||
extends:
|
||||
service: frontend
|
||||
ports:
|
||||
- "8000:5001"
|
||||
- "8000:5001"
|
||||
|
|
|
@ -29,4 +29,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -7,4 +7,4 @@ services:
|
|||
redis:
|
||||
image: redis
|
||||
db:
|
||||
image: postgres
|
||||
image: postgres
|
||||
|
|
|
@ -26,4 +26,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -8,4 +8,4 @@ services:
|
|||
redis:
|
||||
image: redis
|
||||
db:
|
||||
image: postgres
|
||||
image: postgres
|
||||
|
|
|
@ -27,4 +27,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -14,4 +14,4 @@ services:
|
|||
backend:
|
||||
image: awesome/backend
|
||||
ports:
|
||||
- "8000:5001"
|
||||
- "8000:5001"
|
||||
|
|
|
@ -27,4 +27,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -16,4 +16,4 @@ services:
|
|||
extends:
|
||||
service: frontend
|
||||
ports:
|
||||
- "8000:5001"
|
||||
- "8000:5001"
|
||||
|
|
|
@ -28,4 +28,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -12,4 +12,4 @@ services:
|
|||
target: /var/run/postgres/postgres.sock
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -34,4 +34,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -10,4 +10,4 @@ services:
|
|||
- cli-volume:/var/lib/backup/data:ro
|
||||
volumes:
|
||||
common-volume:
|
||||
cli-volume:
|
||||
cli-volume:
|
||||
|
|
|
@ -35,4 +35,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -13,4 +13,4 @@ services:
|
|||
ports:
|
||||
- "8000:5000"
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -36,4 +36,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -20,4 +20,4 @@ services:
|
|||
ports:
|
||||
- "8000:5000"
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -37,4 +37,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -19,4 +19,4 @@ services:
|
|||
backend:
|
||||
image: awesome/backend
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -37,4 +37,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
volumes:
|
||||
|
@ -22,4 +22,4 @@ services:
|
|||
service: frontend
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
networks:
|
||||
|
@ -38,4 +38,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -25,4 +25,4 @@ services:
|
|||
ports:
|
||||
- "8000:5001"
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
|
|
@ -6,7 +6,7 @@ services:
|
|||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
volumes:
|
||||
|
@ -26,4 +26,4 @@ services:
|
|||
- "8000:5010"
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
networks:
|
||||
|
@ -40,4 +40,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -6,4 +6,4 @@ services:
|
|||
links:
|
||||
- "db:database"
|
||||
db:
|
||||
image: postgres
|
||||
image: postgres
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -28,4 +28,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
extends:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
networks:
|
||||
|
@ -29,4 +29,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -30,4 +30,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
extends:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
networks:
|
||||
|
@ -31,4 +31,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -30,4 +30,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
depends_on:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
networks:
|
||||
|
@ -31,4 +31,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -32,4 +32,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -5,7 +5,7 @@ services:
|
|||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
depends_on:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
networks:
|
||||
|
@ -33,4 +33,4 @@ services:
|
|||
networks:
|
||||
front-tier:
|
||||
back-tier:
|
||||
admin:
|
||||
admin:
|
||||
|
|
|
@ -21,4 +21,4 @@ services:
|
|||
db:
|
||||
image: postgres
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -39,4 +39,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
volumes:
|
||||
|
@ -24,4 +24,4 @@ services:
|
|||
image: postgres
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
networks:
|
||||
|
@ -40,4 +40,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -25,4 +25,4 @@ services:
|
|||
image: postgres
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -41,4 +41,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
volumes:
|
||||
|
@ -26,4 +26,4 @@ services:
|
|||
image: postgres
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
networks:
|
||||
|
@ -42,4 +42,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -23,4 +23,4 @@ services:
|
|||
db:
|
||||
image: postgres
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -41,4 +41,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
volumes:
|
||||
|
@ -26,4 +26,4 @@ services:
|
|||
image: postgres
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
networks:
|
||||
|
@ -42,4 +42,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -4,7 +4,7 @@ services:
|
|||
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -27,4 +27,4 @@ services:
|
|||
image: postgres
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
@ -43,4 +43,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -3,7 +3,7 @@ services:
|
|||
image: awesome/webapp
|
||||
monitoring:
|
||||
image: awesome/monitoring
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
volumes:
|
||||
|
@ -27,4 +27,4 @@ services:
|
|||
image: postgres
|
||||
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
networks:
|
||||
|
@ -44,4 +44,4 @@ networks:
|
|||
back-tier:
|
||||
admin:
|
||||
volumes:
|
||||
db-data:
|
||||
db-data:
|
||||
|
|
|
@ -9,7 +9,7 @@ services:
|
|||
image: awesome/monitoring
|
||||
networks:
|
||||
- admin
|
||||
|
||||
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
|
|
|
@ -1,77 +1,81 @@
|
|||
import os
|
||||
|
||||
import pytest
|
||||
|
||||
from typer.testing import CliRunner
|
||||
from compose_viz import cli
|
||||
|
||||
from compose_viz import cli
|
||||
|
||||
runner = CliRunner()
|
||||
|
||||
@pytest.mark.parametrize("file_number", [
|
||||
"000001",
|
||||
"000010",
|
||||
"000011",
|
||||
"000100",
|
||||
"000101",
|
||||
"000110",
|
||||
"000111",
|
||||
"001000",
|
||||
"001001",
|
||||
"001010",
|
||||
"001011",
|
||||
"001100",
|
||||
"001101",
|
||||
"001110",
|
||||
"001111",
|
||||
"010000",
|
||||
"010001",
|
||||
"010010",
|
||||
"010011",
|
||||
"010100",
|
||||
"010101",
|
||||
"010110",
|
||||
"010111",
|
||||
"011000",
|
||||
"011001",
|
||||
"011010",
|
||||
"011011",
|
||||
"011100",
|
||||
"011101",
|
||||
"011110",
|
||||
"011111",
|
||||
"100000",
|
||||
"100001",
|
||||
"100010",
|
||||
"100011",
|
||||
"100100",
|
||||
"100101",
|
||||
"100110",
|
||||
"100111",
|
||||
"101000",
|
||||
"101001",
|
||||
"101010",
|
||||
"101011",
|
||||
"101100",
|
||||
"101101",
|
||||
"101110",
|
||||
"101111",
|
||||
"110000",
|
||||
"110001",
|
||||
"110010",
|
||||
"110011",
|
||||
"110100",
|
||||
"110101",
|
||||
"110110",
|
||||
"110111",
|
||||
"111000",
|
||||
"111001",
|
||||
"111010",
|
||||
"111011",
|
||||
"111100",
|
||||
"111101",
|
||||
"111110",
|
||||
"111111",
|
||||
])
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"file_number",
|
||||
[
|
||||
"000001",
|
||||
"000010",
|
||||
"000011",
|
||||
"000100",
|
||||
"000101",
|
||||
"000110",
|
||||
"000111",
|
||||
"001000",
|
||||
"001001",
|
||||
"001010",
|
||||
"001011",
|
||||
"001100",
|
||||
"001101",
|
||||
"001110",
|
||||
"001111",
|
||||
"010000",
|
||||
"010001",
|
||||
"010010",
|
||||
"010011",
|
||||
"010100",
|
||||
"010101",
|
||||
"010110",
|
||||
"010111",
|
||||
"011000",
|
||||
"011001",
|
||||
"011010",
|
||||
"011011",
|
||||
"011100",
|
||||
"011101",
|
||||
"011110",
|
||||
"011111",
|
||||
"100000",
|
||||
"100001",
|
||||
"100010",
|
||||
"100011",
|
||||
"100100",
|
||||
"100101",
|
||||
"100110",
|
||||
"100111",
|
||||
"101000",
|
||||
"101001",
|
||||
"101010",
|
||||
"101011",
|
||||
"101100",
|
||||
"101101",
|
||||
"101110",
|
||||
"101111",
|
||||
"110000",
|
||||
"110001",
|
||||
"110010",
|
||||
"110011",
|
||||
"110100",
|
||||
"110101",
|
||||
"110110",
|
||||
"110111",
|
||||
"111000",
|
||||
"111001",
|
||||
"111010",
|
||||
"111011",
|
||||
"111100",
|
||||
"111101",
|
||||
"111110",
|
||||
"111111",
|
||||
],
|
||||
)
|
||||
def test_cli(file_number: str):
|
||||
input_path = f"tests/in/{file_number}.yaml"
|
||||
output_path = f"{file_number}.png"
|
||||
|
|
|
@ -1,22 +1,29 @@
|
|||
import pytest
|
||||
|
||||
from compose_viz.extends import Extends
|
||||
from compose_viz.service import Service
|
||||
|
||||
|
||||
|
||||
def test_extend_init():
|
||||
try:
|
||||
Extends(service_name='frontend', from_file='tests/in/000001.yaml')
|
||||
Extends(service_name='frontend')
|
||||
Extends(service_name="frontend", from_file="tests/in/000001.yaml")
|
||||
Extends(service_name="frontend")
|
||||
|
||||
assert True
|
||||
except:
|
||||
assert False
|
||||
except Exception as e:
|
||||
assert False, e
|
||||
|
||||
with pytest.raises(TypeError):
|
||||
Extends(from_file='tests/in/000001.yaml')
|
||||
|
||||
Extends(from_file="tests/in/000001.yaml") # type: ignore
|
||||
|
||||
|
||||
def test_service_init():
|
||||
with pytest.raises(ValueError, match=r"Both image and extends are not defined in service 'frontend', aborting."):
|
||||
Service(name='frontend')
|
||||
|
||||
with pytest.raises(ValueError, match=r"Only one of image and extends can be defined in service 'frontend', aborting."):
|
||||
Service(name='frontend', image='image', extends=Extends(service_name='frontend', from_file='tests/in/000001.yaml'))
|
||||
Service(name="frontend")
|
||||
|
||||
with pytest.raises(
|
||||
ValueError, match=r"Only one of image and extends can be defined in service 'frontend', aborting."
|
||||
):
|
||||
Service(
|
||||
name="frontend", image="image", extends=Extends(service_name="frontend", from_file="tests/in/000001.yaml")
|
||||
)
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,6 +1,6 @@
|
|||
from typer.testing import CliRunner
|
||||
from compose_viz import cli, __app_name__, __version__
|
||||
|
||||
from compose_viz import __app_name__, __version__, cli
|
||||
|
||||
runner = CliRunner()
|
||||
|
||||
|
|
Loading…
Reference in a new issue