diff --git a/app/app-standard-v3.yml b/app/app-standard-v3.yml index 7801447..39b0b4c 100644 --- a/app/app-standard-v3.yml +++ b/app/app-standard-v3.yml @@ -104,6 +104,10 @@ properties: type: array items: type: number + requiredUdpPorts: + type: array + items: + type: number description: Ports this container requires to be exposed to work properly port: type: number diff --git a/app/lib/composegenerator/v3/generate.py b/app/lib/composegenerator/v3/generate.py index 5042f25..f12a0e1 100644 --- a/app/lib/composegenerator/v3/generate.py +++ b/app/lib/composegenerator/v3/generate.py @@ -86,6 +86,10 @@ def createComposeConfigFromV3(app: dict, nodeRoot: str): for container in newApp.containers: container.ports = container.requiredPorts del container.requiredPorts + for container in newApp.containers: + for udpPort in container.requiredUdpPorts: + container.ports.append(udpPort) + del container.requiredUdpPorts newApp = configureMainPort(newApp, nodeRoot) for container in newApp.containers: # TODO: Make this dynamic and not hardcoded diff --git a/app/lib/composegenerator/v3/types.py b/app/lib/composegenerator/v3/types.py index 9d0075e..64c1051 100644 --- a/app/lib/composegenerator/v3/types.py +++ b/app/lib/composegenerator/v3/types.py @@ -37,6 +37,7 @@ class Container: permissions: list = field(default_factory=list) port: Union[int, None] = None requiredPorts: list = field(default_factory=list) + requiredUdpPorts: list = field(default_factory=list) preferredOutsidePort: Union[int, None] = None requiresPort: Union[bool, None] = None environment: Union[dict, None] = None diff --git a/app/lib/metadata.py b/app/lib/metadata.py index 34cd7db..b5c393d 100644 --- a/app/lib/metadata.py +++ b/app/lib/metadata.py @@ -149,9 +149,11 @@ def getPortsV3App(app, appId): validatePort(appContainer, appContainer["preferredOutsidePort"], appId, 1) else: validatePort(appContainer, appContainer["port"], appId, 0) - elif "requiredPorts" not in appContainer: + elif "requiredPorts" not in appContainer and "requiredUdpPorts" not in appContainer: validatePort(appContainer, getNewPort(appPorts.keys()), appId, 0, True) if "requiredPorts" in appContainer: for port in appContainer["requiredPorts"]: - realPort = int(str(port).split(":")[0]) - validatePort(appContainer, realPort, appId, 2) \ No newline at end of file + validatePort(appContainer, port, appId, 2) + if "requiredUdpPorts" in appContainer: + for port in appContainer["requiredUdpPorts"]: + validatePort(appContainer, port, appId, 2) \ No newline at end of file