func()

in pkg/appgw/istio_listeners.go [15:53]


func (c *appGwConfigBuilder) getListenerConfigsFromIstio(istioGateways []*v1alpha3.Gateway, istioVirtualServices []*v1alpha3.VirtualService, env environment.EnvVariables) map[listenerIdentifier]listenerAzConfig {
	knownHosts := make(map[string]interface{})
	for _, virtualService := range istioVirtualServices {
		for _, host := range virtualService.Spec.Hosts {
			knownHosts[host] = nil
		}
	}

	allListeners := make(map[listenerIdentifier]listenerAzConfig)
	for _, igwy := range istioGateways {
		for _, server := range igwy.Spec.Servers {
			if server.Port.Protocol != v1alpha3.ProtocolHTTP {
				klog.Infof("[istio] AGIC does not support Gateway with Server.Port.Protocol=%+v", server.Port.Protocol)
				continue
			}
			for _, host := range server.Hosts {
				if _, exist := knownHosts[host]; !exist {
					continue
				}
				listenerID := listenerIdentifier{
					FrontendPort: Port(server.Port.Number),
					HostNames:    [5]string{host},
				}
				allListeners[listenerID] = listenerAzConfig{Protocol: n.ApplicationGatewayProtocolHTTP}
			}
		}
	}

	// App Gateway must have at least one listener - the default one!
	if len(allListeners) == 0 {
		// TODO(aksgupta): refactor to get environment variable
		allListeners[defaultFrontendListenerIdentifier(c.appGw, env)] = listenerAzConfig{
			// Default protocol
			Protocol: n.ApplicationGatewayProtocolHTTP,
		}
	}

	return allListeners
}