commit
09f8c65e7c
6 changed files with 24 additions and 23 deletions
|
@ -64,14 +64,15 @@ class Parser:
|
|||
if type(port_data) is dict:
|
||||
# define a nested function to limit variable scope
|
||||
def long_syntax():
|
||||
assert type(port_data) is dict
|
||||
assert port_data["target"]
|
||||
|
||||
container_port: str = port_data["target"]
|
||||
container_port: str = str(port_data["target"])
|
||||
host_port: str = ""
|
||||
protocol: Protocol = Protocol.tcp
|
||||
|
||||
if port_data.get("host_port"):
|
||||
host_port = port_data["host_port"]
|
||||
if port_data.get("published"):
|
||||
host_port = str(port_data["published"])
|
||||
else:
|
||||
host_port = container_port
|
||||
|
||||
|
@ -80,7 +81,7 @@ class Parser:
|
|||
host_port = f"{host_ip}:{host_port}"
|
||||
|
||||
if port_data.get("protocol"):
|
||||
protocol = Protocol(port_data["protocol"])
|
||||
protocol = Protocol[str(port_data["protocol"])]
|
||||
|
||||
assert host_port, "Error parsing port, aborting."
|
||||
|
||||
|
@ -105,6 +106,7 @@ class Parser:
|
|||
# - "6060:6060/udp"
|
||||
|
||||
def short_syntax():
|
||||
assert 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
|
||||
match = re.match(regex, port_data)
|
||||
if match:
|
||||
|
@ -151,12 +153,12 @@ class Parser:
|
|||
if type(volume_data) is dict:
|
||||
assert volume_data["source"] and volume_data["target"], "Invalid volume input, aborting."
|
||||
|
||||
volume_source: str = volume_data["source"]
|
||||
volume_target: str = volume_data["target"]
|
||||
volume_source: str = str(volume_data["source"])
|
||||
volume_target: str = str(volume_data["target"])
|
||||
volume_type: VolumeType = VolumeType.volume
|
||||
|
||||
if volume_data.get("type"):
|
||||
volume_type = VolumeType[volume_data["type"]]
|
||||
volume_type = VolumeType[str(volume_data["type"])]
|
||||
|
||||
service_volumes.append(Volume(source=volume_source, target=volume_target, type=volume_type))
|
||||
elif type(volume_data) is str:
|
||||
|
|
|
@ -3,6 +3,6 @@ services:
|
|||
web:
|
||||
build: .
|
||||
ports:
|
||||
- "8000:5000"
|
||||
- "8080"
|
||||
redis:
|
||||
image: "redis:alpine"
|
||||
|
|
|
@ -2,7 +2,10 @@ services:
|
|||
frontend:
|
||||
image: awesome/webapp
|
||||
ports:
|
||||
- "8000:5000"
|
||||
- target: 80
|
||||
host_ip: 127.0.0.1
|
||||
published: 8080
|
||||
protocol: udp
|
||||
networks:
|
||||
- front-tier
|
||||
- back-tier
|
||||
|
@ -10,14 +13,14 @@ services:
|
|||
monitoring:
|
||||
image: awesome/monitoring
|
||||
ports:
|
||||
- "8000:5001"
|
||||
- "127.0.0.1:8081:5001"
|
||||
networks:
|
||||
- admin
|
||||
|
||||
backend:
|
||||
image: awesome/backend
|
||||
ports:
|
||||
- "8000:5010"
|
||||
- "8000:5010/udp"
|
||||
networks:
|
||||
back-tier:
|
||||
aliases:
|
||||
|
|
|
@ -2,7 +2,7 @@ services:
|
|||
frontend:
|
||||
image: awesome/webapp
|
||||
ports:
|
||||
- "8000:5000"
|
||||
- target: 80
|
||||
|
||||
monitoring:
|
||||
extends:
|
||||
|
|
|
@ -2,11 +2,7 @@ services:
|
|||
backend:
|
||||
image: awesome/backend
|
||||
volumes:
|
||||
- type: volume
|
||||
source: db-data
|
||||
target: /data
|
||||
volume:
|
||||
nocopy: true
|
||||
- "db-data:/data"
|
||||
- type: bind
|
||||
source: /var/run/postgres/postgres.sock
|
||||
target: /var/run/postgres/postgres.sock
|
||||
|
|
|
@ -3,7 +3,7 @@ import pytest
|
|||
from compose_viz.compose import Compose
|
||||
from compose_viz.extends import Extends
|
||||
from compose_viz.parser import Parser
|
||||
from compose_viz.port import Port
|
||||
from compose_viz.port import Port, Protocol
|
||||
from compose_viz.service import Service
|
||||
from compose_viz.volume import AccessMode, Volume, VolumeType
|
||||
|
||||
|
@ -82,7 +82,7 @@ from compose_viz.volume import AccessMode, Volume, VolumeType
|
|||
name="web",
|
||||
image="build from .",
|
||||
ports=[
|
||||
Port(host_port="8000", container_port="5000"),
|
||||
Port(host_port="8080", container_port="8080"),
|
||||
],
|
||||
),
|
||||
Service(
|
||||
|
@ -100,7 +100,7 @@ from compose_viz.volume import AccessMode, Volume, VolumeType
|
|||
name="frontend",
|
||||
image="awesome/webapp",
|
||||
ports=[
|
||||
Port(host_port="8000", container_port="5000"),
|
||||
Port(host_port="127.0.0.1:8080", container_port="80", protocol=Protocol.udp),
|
||||
],
|
||||
networks=["front-tier", "back-tier"],
|
||||
),
|
||||
|
@ -108,7 +108,7 @@ from compose_viz.volume import AccessMode, Volume, VolumeType
|
|||
name="monitoring",
|
||||
image="awesome/monitoring",
|
||||
ports=[
|
||||
Port(host_port="8000", container_port="5001"),
|
||||
Port(host_port="127.0.0.1:8081", container_port="5001"),
|
||||
],
|
||||
networks=["admin"],
|
||||
),
|
||||
|
@ -116,7 +116,7 @@ from compose_viz.volume import AccessMode, Volume, VolumeType
|
|||
name="backend",
|
||||
image="awesome/backend",
|
||||
ports=[
|
||||
Port(host_port="8000", container_port="5010"),
|
||||
Port(host_port="8000", container_port="5010", protocol=Protocol.udp),
|
||||
],
|
||||
networks=["back-tier", "admin"],
|
||||
),
|
||||
|
@ -131,7 +131,7 @@ from compose_viz.volume import AccessMode, Volume, VolumeType
|
|||
name="frontend",
|
||||
image="awesome/webapp",
|
||||
ports=[
|
||||
Port(host_port="8000", container_port="5000"),
|
||||
Port(host_port="80", container_port="80"),
|
||||
],
|
||||
),
|
||||
Service(
|
||||
|
|
Loading…
Reference in a new issue