public List<ManifestSnippet> generatePortsManifest(List<Port> portList, String podSpecOwner, int containerIndex) throws HyscaleException {
        List<ManifestSnippet> manifestSnippetList = new ArrayList<>();
        if (portList != null && !portList.isEmpty()) {
            Set<V1ContainerPort> v1ContainerPorts = Sets.newHashSet();
            Set<V1ServicePort> v1ServicePorts = Sets.newHashSet();
            portList.stream().filter(port -> port != null && StringUtils.isNotBlank(port.getPort())).forEach(each -> {
                V1ContainerPort v1ContainerPort = new V1ContainerPort();
                V1ServicePort v1ServicePort = new V1ServicePort();
                String[] portAndProtocol = updatePortProtocol(each).getPort().split(ToolConstants.PORTS_PROTOCOL_SEPARATOR);
                String portName = NormalizationUtil.normalize(portAndProtocol[0] + ManifestGenConstants.NAME_DELIMITER + portAndProtocol[1]);
                String protocol = portAndProtocol[1].toUpperCase();
                v1ContainerPort.setProtocol(protocol);
                v1ServicePort.setProtocol(protocol);
                int portValue = Integer.parseInt(portAndProtocol[0]);
                v1ContainerPort.setContainerPort(portValue);
                v1ContainerPort.setName(portName);
                logger.debug("Processing ports {}.", v1ContainerPort.getName());
                v1ContainerPorts.add(v1ContainerPort);
                v1ServicePort.setName(portName);
                logger.debug("Processing ports {}.", v1ServicePort.getName());
                v1ServicePort.setPort(portValue);
                v1ServicePort.setTargetPort(new IntOrString(portValue));
                v1ServicePorts.add(v1ServicePort);
                logger.debug("Fetched container and service ports ");
            });
            try {
                manifestSnippetList.add(buildServicePortsSnippet(v1ServicePorts));
                manifestSnippetList.add(buildContainerPortsSnippet(v1ContainerPorts, podSpecOwner, containerIndex));
                logger.info("Successfully completed processing ports");
            } catch (Exception e) {
                HyscaleException ex = new HyscaleException(e, ManifestErrorCodes.ERROR_WHILE_CREATING_MANIFEST);
                logger.error("Error while generating Manifest Files", ex);
                throw ex;
            }
        }
        return manifestSnippetList;
    }
This class is to generate the default ports taken from the
service spec for the manifest snippet.
Handles Ports for Services as well as Agents.
manifest-generator/generator-services/src/main/java/io/hyscale/generator/services/builder/DefaultPortsBuilder.java