chore: apply pre-commit hooks
This commit is contained in:
parent
747dd06be1
commit
eca68a8190
8 changed files with 26 additions and 49 deletions
|
@ -16,8 +16,8 @@ class Service:
|
|||
depends_on: List[str] = [],
|
||||
links: List[str] = [],
|
||||
extends: Optional[Extends] = None,
|
||||
cgroup_parent: str = None,
|
||||
container_name: str = None,
|
||||
cgroup_parent: Optional[str] = None,
|
||||
container_name: Optional[str] = None,
|
||||
devices: List[str] = [],
|
||||
env_file: List[str] = [],
|
||||
expose: List[str] = [],
|
||||
|
|
|
@ -176,35 +176,32 @@ class Parser:
|
|||
if service_data.links is not None:
|
||||
service_links = service_data.links
|
||||
|
||||
|
||||
cgroup_parent: Optional[str] = None
|
||||
if service_data.cgroup_parent is not None:
|
||||
cgroup_parent = service_data.cgroup_parent
|
||||
|
||||
|
||||
container_name: Optional[str] = None
|
||||
if service_data.container_name is not None:
|
||||
container_name = service_data.container_name
|
||||
|
||||
|
||||
|
||||
env_file: List[str] = []
|
||||
if service_data.env_file is not None:
|
||||
if type(service_data.env_file) is spec.StringOrList:
|
||||
if(type(service_data.env_file.__root__) is spec.ListOfStrings):
|
||||
if type(service_data.env_file.__root__) is spec.ListOfStrings:
|
||||
env_file = service_data.env_file.__root__.__root__
|
||||
elif(type(service_data.env_file.__root__) is str):
|
||||
elif type(service_data.env_file.__root__) is str:
|
||||
env_file.append(service_data.env_file.__root__)
|
||||
|
||||
|
||||
expose: List[str] = []
|
||||
if service_data.expose is not None:
|
||||
expose = service_data.expose
|
||||
|
||||
for port in service_data.expose:
|
||||
expose.append(str(port))
|
||||
|
||||
profiles: List[str] = []
|
||||
if service_data.profiles is not None:
|
||||
if type(service_data.profiles) is spec.ListOfStrings:
|
||||
profiles = service_data.profiles.__root__
|
||||
|
||||
|
||||
services.append(
|
||||
Service(
|
||||
name=service_name,
|
||||
|
|
|
@ -248,7 +248,7 @@ from compose_viz.parser import Parser
|
|||
Service(
|
||||
name="frontend",
|
||||
image="awesome/frontend",
|
||||
cgroup_parent="system",
|
||||
cgroup_parent="system",
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -260,7 +260,7 @@ from compose_viz.parser import Parser
|
|||
Service(
|
||||
name="frontend",
|
||||
image="awesome/frontend",
|
||||
container_name="myfrontend",
|
||||
container_name="myfrontend",
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -272,24 +272,17 @@ from compose_viz.parser import Parser
|
|||
Service(
|
||||
name="frontend",
|
||||
image="awesome/frontend",
|
||||
env_file=[
|
||||
"a.env"
|
||||
],
|
||||
env_file=["a.env"],
|
||||
),
|
||||
Service(
|
||||
name="backend",
|
||||
image="awesome/backend",
|
||||
env_file=[
|
||||
"b.env"
|
||||
],
|
||||
env_file=["b.env"],
|
||||
),
|
||||
Service(
|
||||
name="db",
|
||||
image="awesome/db",
|
||||
env_file=[
|
||||
"c.env",
|
||||
"d.env"
|
||||
],
|
||||
env_file=["c.env", "d.env"],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -301,46 +294,34 @@ from compose_viz.parser import Parser
|
|||
Service(
|
||||
name="frontend",
|
||||
image="awesome/frontend",
|
||||
expose=[
|
||||
"27118"
|
||||
],
|
||||
expose=["27118"],
|
||||
),
|
||||
Service(
|
||||
name="backend",
|
||||
image="awesome/backend",
|
||||
expose=[
|
||||
"27017",
|
||||
"27018"
|
||||
],
|
||||
expose=["27017", "27018"],
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
(
|
||||
(
|
||||
"profiles/docker-compose",
|
||||
Compose(
|
||||
services=[
|
||||
Service(
|
||||
name="frontend",
|
||||
image="awesome/frontend",
|
||||
profiles=[
|
||||
"frontend"
|
||||
],
|
||||
profiles=["frontend"],
|
||||
),
|
||||
Service(
|
||||
name="phpmyadmin",
|
||||
image="phpmyadmin",
|
||||
profiles=[
|
||||
"debug"
|
||||
],
|
||||
profiles=["debug"],
|
||||
),
|
||||
Service(
|
||||
name="db",
|
||||
image="awesome/db",
|
||||
profiles=[
|
||||
"db",
|
||||
"sql"
|
||||
],
|
||||
profiles=["db", "sql"],
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@ -380,10 +361,9 @@ def test_parse_file(test_file_path: str, expected: Compose) -> None:
|
|||
assert actual_service.extends.service_name == expected_service.extends.service_name
|
||||
assert actual_service.extends.from_file == expected_service.extends.from_file
|
||||
|
||||
|
||||
assert actual_service.cgroup_parent == expected_service.cgroup_parent
|
||||
assert actual_service.container_name == expected_service.container_name
|
||||
|
||||
assert actual_service.expose == expected_service.expose
|
||||
assert actual_service.env_file == expected_service.env_file
|
||||
assert actual_service.profiles == expected_service.profiles
|
||||
assert actual_service.profiles == expected_service.profiles
|
||||
|
|
|
@ -3,4 +3,4 @@ version: "3.9"
|
|||
services:
|
||||
frontend:
|
||||
image: awesome/frontend
|
||||
cgroup_parent: "system"
|
||||
cgroup_parent: "system"
|
||||
|
|
|
@ -3,4 +3,4 @@ version: "3.9"
|
|||
services:
|
||||
frontend:
|
||||
image: awesome/frontend
|
||||
container_name: "myfrontend"
|
||||
container_name: "myfrontend"
|
||||
|
|
|
@ -9,4 +9,4 @@ services:
|
|||
image: awesome/backend
|
||||
devices:
|
||||
- "/dev/ttyUSB1:/dev/ttyUSB1"
|
||||
- "/dev/ttyUSB2:/dev/ttyUSB2"
|
||||
- "/dev/ttyUSB2:/dev/ttyUSB2"
|
||||
|
|
|
@ -9,4 +9,4 @@ services:
|
|||
image: awesome/backend
|
||||
expose:
|
||||
- "27017"
|
||||
- "27018"
|
||||
- "27018"
|
||||
|
|
|
@ -11,4 +11,4 @@ services:
|
|||
image: awesome/db
|
||||
profiles:
|
||||
- db
|
||||
- sql
|
||||
- sql
|
||||
|
|
Loading…
Reference in a new issue