func()

in pkg/appgw/requestroutingrules.go [469:504]


func (c *appGwConfigBuilder) getListenerPriorities(cbCtx *ConfigBuilderContext) map[listenerIdentifier]*int32 {
	prioritySet, priorityNil := false, false
	priorityExists := make(map[int32]bool)
	allPriorities := make(map[listenerIdentifier]*int32)
	for _, ingress := range cbCtx.IngressList {
		klog.V(3).Infof("Getting Request Routing Rules Priority for Ingress: %s/%s", ingress.Namespace, ingress.Name)
		azListenerConfigs := c.getListenersFromIngress(ingress, cbCtx.EnvVariables)
		for listenerID := range azListenerConfigs {
			if priority, err := annotations.GetRequestRoutingRulePriority(ingress); err == nil {
				klog.V(3).Infof("Request Routing Rules Priority for Ingress: %s/%s is Priority: %d", ingress.Namespace, ingress.Name, *priority)
				prioritySet = true
				if _, value := priorityExists[*priority]; !value {
					priorityExists[*priority] = true
				} else {
					klog.Errorf(
						"Request Routing Rules Priority for Ingress: %s/%s is duplicated. Priority must be unique across all the request routing rules.",
						ingress.Namespace,
						ingress.Name)
				}
				allPriorities[listenerID] = priority
			} else if controllererrors.IsErrorCode(err, controllererrors.ErrorMissingAnnotation) {
				klog.V(9).Infof("Request Routing Rules Priority for Ingress: %s/%s is Priority: nil", ingress.Namespace, ingress.Name)
				priorityNil = true
				allPriorities[listenerID] = nil
			} else if controllererrors.IsErrorCode(err, controllererrors.ErrorInvalidContent) {
				klog.Errorf("%s for Ingress: %s/%s", err.Error(), ingress.Namespace, ingress.Name)
			}
		}
	}

	if priorityNil && prioritySet {
		klog.Error("Either all or no Ingress should have the priority specified.")
	}

	return allPriorities
}