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] = [],
|
depends_on: List[str] = [],
|
||||||
links: List[str] = [],
|
links: List[str] = [],
|
||||||
extends: Optional[Extends] = None,
|
extends: Optional[Extends] = None,
|
||||||
cgroup_parent: str = None,
|
cgroup_parent: Optional[str] = None,
|
||||||
container_name: str = None,
|
container_name: Optional[str] = None,
|
||||||
devices: List[str] = [],
|
devices: List[str] = [],
|
||||||
env_file: List[str] = [],
|
env_file: List[str] = [],
|
||||||
expose: List[str] = [],
|
expose: List[str] = [],
|
||||||
|
|
|
@ -176,35 +176,32 @@ class Parser:
|
||||||
if service_data.links is not None:
|
if service_data.links is not None:
|
||||||
service_links = service_data.links
|
service_links = service_data.links
|
||||||
|
|
||||||
|
|
||||||
cgroup_parent: Optional[str] = None
|
cgroup_parent: Optional[str] = None
|
||||||
if service_data.cgroup_parent is not None:
|
if service_data.cgroup_parent is not None:
|
||||||
cgroup_parent = service_data.cgroup_parent
|
cgroup_parent = service_data.cgroup_parent
|
||||||
|
|
||||||
container_name: Optional[str] = None
|
container_name: Optional[str] = None
|
||||||
if service_data.container_name is not None:
|
if service_data.container_name is not None:
|
||||||
container_name = service_data.container_name
|
container_name = service_data.container_name
|
||||||
|
|
||||||
|
|
||||||
env_file: List[str] = []
|
env_file: List[str] = []
|
||||||
if service_data.env_file is not None:
|
if service_data.env_file is not None:
|
||||||
if type(service_data.env_file) is spec.StringOrList:
|
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__
|
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__)
|
env_file.append(service_data.env_file.__root__)
|
||||||
|
|
||||||
|
|
||||||
expose: List[str] = []
|
expose: List[str] = []
|
||||||
if service_data.expose is not None:
|
if service_data.expose is not None:
|
||||||
expose = service_data.expose
|
for port in service_data.expose:
|
||||||
|
expose.append(str(port))
|
||||||
|
|
||||||
profiles: List[str] = []
|
profiles: List[str] = []
|
||||||
if service_data.profiles is not None:
|
if service_data.profiles is not None:
|
||||||
if type(service_data.profiles) is spec.ListOfStrings:
|
if type(service_data.profiles) is spec.ListOfStrings:
|
||||||
profiles = service_data.profiles.__root__
|
profiles = service_data.profiles.__root__
|
||||||
|
|
||||||
|
|
||||||
services.append(
|
services.append(
|
||||||
Service(
|
Service(
|
||||||
name=service_name,
|
name=service_name,
|
||||||
|
|
|
@ -248,7 +248,7 @@ from compose_viz.parser import Parser
|
||||||
Service(
|
Service(
|
||||||
name="frontend",
|
name="frontend",
|
||||||
image="awesome/frontend",
|
image="awesome/frontend",
|
||||||
cgroup_parent="system",
|
cgroup_parent="system",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -260,7 +260,7 @@ from compose_viz.parser import Parser
|
||||||
Service(
|
Service(
|
||||||
name="frontend",
|
name="frontend",
|
||||||
image="awesome/frontend",
|
image="awesome/frontend",
|
||||||
container_name="myfrontend",
|
container_name="myfrontend",
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -272,24 +272,17 @@ from compose_viz.parser import Parser
|
||||||
Service(
|
Service(
|
||||||
name="frontend",
|
name="frontend",
|
||||||
image="awesome/frontend",
|
image="awesome/frontend",
|
||||||
env_file=[
|
env_file=["a.env"],
|
||||||
"a.env"
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Service(
|
Service(
|
||||||
name="backend",
|
name="backend",
|
||||||
image="awesome/backend",
|
image="awesome/backend",
|
||||||
env_file=[
|
env_file=["b.env"],
|
||||||
"b.env"
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Service(
|
Service(
|
||||||
name="db",
|
name="db",
|
||||||
image="awesome/db",
|
image="awesome/db",
|
||||||
env_file=[
|
env_file=["c.env", "d.env"],
|
||||||
"c.env",
|
|
||||||
"d.env"
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -301,46 +294,34 @@ from compose_viz.parser import Parser
|
||||||
Service(
|
Service(
|
||||||
name="frontend",
|
name="frontend",
|
||||||
image="awesome/frontend",
|
image="awesome/frontend",
|
||||||
expose=[
|
expose=["27118"],
|
||||||
"27118"
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Service(
|
Service(
|
||||||
name="backend",
|
name="backend",
|
||||||
image="awesome/backend",
|
image="awesome/backend",
|
||||||
expose=[
|
expose=["27017", "27018"],
|
||||||
"27017",
|
|
||||||
"27018"
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
(
|
(
|
||||||
"profiles/docker-compose",
|
"profiles/docker-compose",
|
||||||
Compose(
|
Compose(
|
||||||
services=[
|
services=[
|
||||||
Service(
|
Service(
|
||||||
name="frontend",
|
name="frontend",
|
||||||
image="awesome/frontend",
|
image="awesome/frontend",
|
||||||
profiles=[
|
profiles=["frontend"],
|
||||||
"frontend"
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Service(
|
Service(
|
||||||
name="phpmyadmin",
|
name="phpmyadmin",
|
||||||
image="phpmyadmin",
|
image="phpmyadmin",
|
||||||
profiles=[
|
profiles=["debug"],
|
||||||
"debug"
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
Service(
|
Service(
|
||||||
name="db",
|
name="db",
|
||||||
image="awesome/db",
|
image="awesome/db",
|
||||||
profiles=[
|
profiles=["db", "sql"],
|
||||||
"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.service_name == expected_service.extends.service_name
|
||||||
assert actual_service.extends.from_file == expected_service.extends.from_file
|
assert actual_service.extends.from_file == expected_service.extends.from_file
|
||||||
|
|
||||||
|
|
||||||
assert actual_service.cgroup_parent == expected_service.cgroup_parent
|
assert actual_service.cgroup_parent == expected_service.cgroup_parent
|
||||||
assert actual_service.container_name == expected_service.container_name
|
assert actual_service.container_name == expected_service.container_name
|
||||||
|
|
||||||
assert actual_service.expose == expected_service.expose
|
assert actual_service.expose == expected_service.expose
|
||||||
assert actual_service.env_file == expected_service.env_file
|
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:
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
image: awesome/frontend
|
image: awesome/frontend
|
||||||
cgroup_parent: "system"
|
cgroup_parent: "system"
|
||||||
|
|
|
@ -3,4 +3,4 @@ version: "3.9"
|
||||||
services:
|
services:
|
||||||
frontend:
|
frontend:
|
||||||
image: awesome/frontend
|
image: awesome/frontend
|
||||||
container_name: "myfrontend"
|
container_name: "myfrontend"
|
||||||
|
|
|
@ -9,4 +9,4 @@ services:
|
||||||
image: awesome/backend
|
image: awesome/backend
|
||||||
devices:
|
devices:
|
||||||
- "/dev/ttyUSB1:/dev/ttyUSB1"
|
- "/dev/ttyUSB1:/dev/ttyUSB1"
|
||||||
- "/dev/ttyUSB2:/dev/ttyUSB2"
|
- "/dev/ttyUSB2:/dev/ttyUSB2"
|
||||||
|
|
|
@ -9,4 +9,4 @@ services:
|
||||||
image: awesome/backend
|
image: awesome/backend
|
||||||
expose:
|
expose:
|
||||||
- "27017"
|
- "27017"
|
||||||
- "27018"
|
- "27018"
|
||||||
|
|
|
@ -11,4 +11,4 @@ services:
|
||||||
image: awesome/db
|
image: awesome/db
|
||||||
profiles:
|
profiles:
|
||||||
- db
|
- db
|
||||||
- sql
|
- sql
|
||||||
|
|
Loading…
Reference in a new issue