Merge pull request #42 from compose-viz/dev

Fix #38 #41
This commit is contained in:
Xyphuz 2023-01-10 22:11:12 +08:00 committed by GitHub
commit 52262faf39
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 776 additions and 753 deletions

View file

@ -28,7 +28,7 @@ jobs:
- name: Setup Poetry
uses: Gr1N/setup-poetry@v7
with:
poetry-version: 1.1.7
poetry-version: 1.2.1
- name: Install Dependencies
run: |

View file

@ -1,2 +1,2 @@
__app_name__ = "compose_viz"
__version__ = "0.2.4"
__version__ = "0.2.5"

View file

@ -102,7 +102,7 @@ class Parser:
container_port = str(int(port_data))
host_port = f"0.0.0.0:{container_port}"
elif type(port_data) is str:
regex = r"(?P<host_ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:)?((?P<host_port>\d+(\-\d+)?):)?((?P<container_port>\d+(\-\d+)?))?(/(?P<protocol>\w+))?" # noqa: E501
regex = r"((?P<host_ip>\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}:)|:)?((?P<host_port>\d+(\-\d+)?):)?((?P<container_port>\d+(\-\d+)?))?(/(?P<protocol>\w+))?" # noqa: E501
match = re.match(regex, port_data)
if match:

View file

@ -102,8 +102,10 @@
"shm_size": {"type": ["integer", "string"]},
"extra_hosts": {"$ref": "#/definitions/list_or_dict"},
"isolation": {"type": "string"},
"privileged": {"type": "boolean"},
"secrets": {"$ref": "#/definitions/service_config_or_secret"},
"tags":{"type": "array", "items": {"type": "string"}}
"tags": {"type": "array", "items": {"type": "string"}},
"platforms": {"type": "array", "items": {"type": "string"}}
},
"additionalProperties": false,
"patternProperties": {"^x-": {}}
@ -139,6 +141,7 @@
},
"cap_add": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"cap_drop": {"type": "array", "items": {"type": "string"}, "uniqueItems": true},
"cgroup": {"type": "string", "enum": ["host", "private"]},
"cgroup_parent": {"type": "string"},
"command": {
"oneOf": [
@ -364,6 +367,7 @@
}
},
"user": {"type": "string"},
"uts": {"type": "string"},
"userns_mode": {"type": "string"},
"volumes": {
"type": "array",
@ -686,6 +690,7 @@
"type": "object",
"properties": {
"name": {"type": "string"},
"environment": {"type": "string"},
"file": {"type": "string"},
"external": {
"type": ["boolean", "object"],

View file

@ -1,14 +1,18 @@
# generated by datamodel-codegen:
# filename: compose-spec.json
# timestamp: 2022-05-27T05:44:40+00:00
# timestamp: 2023-01-10T13:17:45+00:00
from __future__ import annotations
from enum import Enum
from typing import Any, Dict, List, Optional, Union
from pydantic import Extra, Field, conint, constr
from pydantic_yaml import YamlModel
from pydantic_yaml import YamlModel, YamlStrEnum
class Cgroup(YamlStrEnum):
host = "host"
private = "private"
class CredentialSpec(YamlModel):
@ -20,7 +24,7 @@ class CredentialSpec(YamlModel):
registry: Optional[str] = None
class Condition(Enum):
class Condition(YamlStrEnum):
service_started = "service_started"
service_healthy = "service_healthy"
service_completed_successfully = "service_completed_successfully"
@ -60,7 +64,7 @@ class Port(YamlModel):
protocol: Optional[str] = None
class PullPolicy(Enum):
class PullPolicy(YamlStrEnum):
always = "always"
never = "never"
if_not_present = "if_not_present"
@ -76,7 +80,7 @@ class Ulimit(YamlModel):
soft: int
class Selinux(Enum):
class Selinux(YamlStrEnum):
z = "z"
Z = "Z"
@ -131,7 +135,7 @@ class Healthcheck(YamlModel):
start_period: Optional[str] = None
class Order(Enum):
class Order(YamlStrEnum):
start_first = "start-first"
stop_first = "stop-first"
@ -148,7 +152,7 @@ class RollbackConfig(YamlModel):
order: Optional[Order] = None
class ConfigOrder(Enum):
class ConfigOrder(YamlStrEnum):
start_first = "start-first"
stop_first = "stop-first"
@ -265,7 +269,9 @@ class ListOfStrings(YamlModel):
class ListOrDict(YamlModel):
__root__: Union[Dict[constr(regex=r".+"), Optional[Union[str, float, bool]]], List[str]] # type: ignore # noqa: F722, E501
__root__: Union[
Dict[constr(regex=r".+"), Optional[Union[str, float, bool]]], List[str] # type: ignore # noqa: F722
]
class BlkioLimit(YamlModel):
@ -321,8 +327,10 @@ class BuildItem(YamlModel):
shm_size: Optional[Union[int, str]] = None
extra_hosts: Optional[ListOrDict] = None
isolation: Optional[str] = None
privileged: Optional[bool] = None
secrets: Optional[ServiceConfigOrSecret] = None
tags: Optional[List[str]] = None
platforms: Optional[List[str]] = None
class BlkioConfig(YamlModel):
@ -371,7 +379,7 @@ class Network(YamlModel):
driver: Optional[str] = None
driver_opts: Optional[Dict[constr(regex=r"^.+$"), Union[str, float]]] = None # type: ignore # noqa: F722
ipam: Optional[Ipam] = None
external: Optional[ExternalNetwork] = None
external: Optional[bool | ExternalNetwork] = None
internal: Optional[bool] = None
enable_ipv6: Optional[bool] = None
attachable: Optional[bool] = None
@ -394,6 +402,7 @@ class Secret(YamlModel):
extra = Extra.forbid
name: Optional[str] = None
environment: Optional[str] = None
file: Optional[str] = None
external: Optional[ExternalSecret] = None
labels: Optional[ListOrDict] = None
@ -459,6 +468,7 @@ class Service(YamlModel):
blkio_config: Optional[BlkioConfig] = None
cap_add: Optional[List[str]] = Field(None, unique_items=True)
cap_drop: Optional[List[str]] = Field(None, unique_items=True)
cgroup: Optional[Cgroup] = None
cgroup_parent: Optional[str] = None
command: Optional[Union[str, List[str]]] = None
configs: Optional[ServiceConfigOrSecret] = None
@ -473,7 +483,9 @@ class Service(YamlModel):
cpus: Optional[Union[float, str]] = None
cpuset: Optional[str] = None
credential_spec: Optional[CredentialSpec] = None
depends_on: Optional[Union[ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), DependsOn]]] = None # type: ignore # noqa: F722, E501
depends_on: Optional[
Union[ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), DependsOn]] # type: ignore # noqa: F722, E501
] = None
device_cgroup_rules: Optional[ListOfStrings] = None
devices: Optional[List[str]] = Field(None, unique_items=True)
dns: Optional[StringOrList] = None
@ -503,10 +515,14 @@ class Service(YamlModel):
mem_swappiness: Optional[int] = None
memswap_limit: Optional[Union[float, str]] = None
network_mode: Optional[str] = None
networks: Optional[Union[ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Optional[ServiceNetwork]]]] = None # type: ignore # noqa: F722, E501
networks: Optional[
Union[
ListOfStrings, Dict[constr(regex=r"^[a-zA-Z0-9._-]+$"), Optional[ServiceNetwork]] # type: ignore # noqa: F722, E501
]
] = None
oom_kill_disable: Optional[bool] = None
oom_score_adj: Optional[conint(ge=-1000, le=1000)] = None # type: ignore
pid: Optional[Optional[str]] = None
pid: Optional[str] = None
pids_limit: Optional[Union[float, str]] = None
platform: Optional[str] = None
ports: Optional[List[Union[float, str, Port]]] = Field(None, unique_items=True)
@ -529,6 +545,7 @@ class Service(YamlModel):
tty: Optional[bool] = None
ulimits: Optional[Dict[constr(regex=r"^[a-z]+$"), Union[int, Ulimit]]] = None # type: ignore # noqa: F722
user: Optional[str] = None
uts: Optional[str] = None
userns_mode: Optional[str] = None
volumes: Optional[List[Union[str, ServiceVolume]]] = Field(None, unique_items=True)
volumes_from: Optional[List[str]] = Field(None, unique_items=True)

1462
poetry.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,6 +1,6 @@
[tool.poetry]
name = "compose-viz"
version = "0.2.4"
version = "0.2.5"
description = "A compose file visualization tool that supports compose-spec and allows you to gernerate graph in several formats."
authors = ["Xyphuz Wu <xyphuzwu@gmail.com>"]
readme = "README.md"
@ -23,7 +23,7 @@ pydantic-yaml = "^0.7.0"
pytest = "^7.1.2"
pre-commit = "^2.19.0"
coverage = "^6.3.3"
pytest-cov = "^3.0.0"
pytest-cov = "^4.0.0"
[build-system]
requires = ["poetry-core>=1.0.0"]

View file

@ -172,6 +172,10 @@ from compose_viz.parser import Parser
container_port="6060",
protocol=Protocol.udp,
),
Port(
host_port="0.0.0.0:7777",
container_port="7777",
),
Port(
host_port="127.0.0.1:8080",
container_port="80",

View file

@ -26,3 +26,5 @@ networks:
front-tier:
back-tier:
admin:
traefik-public:
external: true

View file

@ -11,6 +11,7 @@ services:
- "127.0.0.1:8001:8001"
- "127.0.0.1:5000-5010:5000-5010"
- "6060:6060/udp"
- ":7777"
- target: 80
host_ip: 127.0.0.1
published: 8080