enricher/standard/src/main/java/io/fabric8/maven/enricher/standard/DefaultServiceEnricher.java
private List<ServicePort> extractPorts(List<ImageConfiguration> images) {
        List<ServicePort> ret = new ArrayList<>();
        boolean isMultiPort = Boolean.parseBoolean(getConfig(Config.multiPort));

        List<ServicePort> configuredPorts = extractPortsFromConfig();

        for (ImageConfiguration image : images) {
            Map<String, String> labels = extractLabelsFromConfig(image);
            List<String> podPorts = getPortsFromBuildConfiguration(image);
            List<String> portsFromImageLabels = getLabelWithService(labels);
            if (podPorts.isEmpty()) {
                continue;
            }

            // Extract first port and remove first element
            if(portsFromImageLabels == null || portsFromImageLabels.isEmpty()) {
                addPortIfNotNull(ret, extractPortsFromImageSpec(image.getName(), podPorts.remove(0), shiftOrNull(configuredPorts), null));
            } else {
                for (String imageLabelPort : portsFromImageLabels) {
                    addPortIfNotNull(ret, extractPortsFromImageSpec(image.getName(), podPorts.remove(0), shiftOrNull(configuredPorts), imageLabelPort));
                }
            }

            // Remaining port specs if multi-port is selected
            if (isMultiPort) {
                for (String port : podPorts) {
                    addPortIfNotNull(ret, extractPortsFromImageSpec(image.getName(), port, shiftOrNull(configuredPorts), null));
                }
            }
        }

        // If there are still ports configured add them directly
        if (isMultiPort) {
            ret.addAll(mirrorMissingTargetPorts(configuredPorts));
        } else if (ret.isEmpty() && !configuredPorts.isEmpty()) {
            ret.addAll(mirrorMissingTargetPorts(Collections.singletonList(configuredPorts.get(0))));
        }

        return ret;
    }
private List<ServicePort> extractPorts(List<ImageConfiguration> images) {
        List<ServicePort> ret = new ArrayList<>();
        boolean isMultiPort = Boolean.parseBoolean(getConfig(Config.multiPort));

        List<ServicePort> configuredPorts = extractPortsFromConfig();

        for (ImageConfiguration image : images) {
            Map<String, String> labels = extractLabelsFromConfig(image);
            List<String> podPorts = getPortsFromBuildConfiguration(image);
            List<String> portsFromImageLabels = getLabelWithService(labels);
            if (podPorts.isEmpty()) {
                continue;
            }

            // Extract first port and remove first element
            if(portsFromImageLabels == null || portsFromImageLabels.isEmpty()) {
                addPortIfNotNull(ret, extractPortsFromImageSpec(image.getName(), podPorts.remove(0), shiftOrNull(configuredPorts), null));
            } else {
                for (String imageLabelPort : portsFromImageLabels) {
                    addPortIfNotNull(ret, extractPortsFromImageSpec(image.getName(), podPorts.remove(0), shiftOrNull(configuredPorts), imageLabelPort));
                }
            }

            // Remaining port specs if multi-port is selected
            if (isMultiPort) {
                for (String port : podPorts) {
                    addPortIfNotNull(ret, extractPortsFromImageSpec(image.getName(), port, shiftOrNull(configuredPorts), null));
                }
            }
        }

        // If there are still ports configured add them directly
        if (isMultiPort) {
            ret.addAll(mirrorMissingTargetPorts(configuredPorts));
        } else if (ret.isEmpty() && !configuredPorts.isEmpty()) {
            ret.addAll(mirrorMissingTargetPorts(Collections.singletonList(configuredPorts.get(0))));
        }

        return ret;
    }
private List < ServicePort > extractPorts ( List < ImageConfiguration > images ) { List < ServicePort > ret = new ArrayList <> ( ) ; boolean isMultiPort = Boolean . parseBoolean ( getConfig ( Config . multiPort ) ) ; List < ServicePort > configuredPorts = extractPortsFromConfig ( ) ; for ( ImageConfiguration image : images ) { Map < String , String > labels = extractLabelsFromConfig ( image ) ; List < String > podPorts = getPortsFromBuildConfiguration ( image ) ; List < String > portsFromImageLabels = getLabelWithService ( labels ) ; if ( podPorts . isEmpty ( ) ) { continue ; } // Extract first port and remove first element if ( portsFromImageLabels == null || portsFromImageLabels . isEmpty ( ) ) { addPortIfNotNull ( ret , extractPortsFromImageSpec ( image . getName ( ) , podPorts . remove ( 0 ) , shiftOrNull ( configuredPorts ) , null ) ) ; } else { for ( String imageLabelPort : portsFromImageLabels ) { addPortIfNotNull ( ret , extractPortsFromImageSpec ( image . getName ( ) , podPorts . remove ( 0 ) , shiftOrNull ( configuredPorts ) , imageLabelPort ) ) ; } } // Remaining port specs if multi-port is selected if ( isMultiPort ) { for ( String port : podPorts ) { addPortIfNotNull ( ret , extractPortsFromImageSpec ( image . getName ( ) , port , shiftOrNull ( configuredPorts ) , null ) ) ; } } } // If there are still ports configured add them directly if ( isMultiPort ) { ret . addAll ( mirrorMissingTargetPorts ( configuredPorts ) ) ; } else if ( ret . isEmpty ( ) && ! configuredPorts . isEmpty ( ) ) { ret . addAll ( mirrorMissingTargetPorts ( Collections . singletonList ( configuredPorts . get ( 0 ) ) ) ) ; } return ret ; }
Port handling
Port handling