func generateListenerID()

in pkg/appgw/configbuilder.go [228:270]


func generateListenerID(ingress *networking.Ingress, rule *networking.IngressRule, protocol n.ApplicationGatewayProtocol, overridePort *Port, usePrivateIP bool) listenerIdentifier {
	frontendPort := Port(80)
	if protocol == n.ApplicationGatewayProtocolHTTPS {
		frontendPort = Port(443)
	}
	if overridePort != nil {
		if *overridePort > 0 && *overridePort < 65000 {
			frontendPort = *overridePort
			klog.V(3).Infof("Using custom port specified in the override annotation: %d", *overridePort)
		} else {
			klog.V(3).Infof("Derived listener port from ingress: %d", frontendPort)
		}

	}

	frontendType := FrontendTypePublic
	if usePrivateIP {
		frontendType = FrontendTypePrivate
	}

	listenerID := listenerIdentifier{
		FrontendPort: frontendPort,
		FrontendType: frontendType,
	}

	var hostNames []string
	if rule != nil && rule.Host != "" {
		hostNames = append(hostNames, rule.Host)
	}

	extendedHostNames, err := annotations.GetHostNameExtensions(ingress)
	if err != nil && !controllererrors.IsErrorCode(err, controllererrors.ErrorMissingAnnotation) {
		klog.V(3).Infof("Error while parsing host name extensions: %s", err)
	} else {
		if extendedHostNames != nil {
			hostNames = append(hostNames, extendedHostNames...)
		}
	}

	hostNames = utils.RemoveDuplicateStrings(hostNames)
	listenerID.setHostNames(hostNames)
	return listenerID
}