func getAppsForInformer()

in grpc-xds/control-plane-go/pkg/informers/manager.go [144:167]


func getAppsForInformer(logger logr.Logger, informer informercache.SharedIndexInformer) []applications.Application {
	var apps []applications.Application
	for _, eps := range informer.GetIndexer().List() {
		endpointSlice, err := validateEndpointSlice(eps)
		if err != nil {
			logger.Error(err, "Skipping EndpointSlice")
			continue
		}
		k8sServiceName := endpointSlice.GetObjectMeta().GetLabels()[discoveryv1.LabelServiceName]
		namespace := endpointSlice.GetObjectMeta().GetNamespace()
		servingPort := findServingPort(endpointSlice)
		healthCheckPort, exists := findHealthCheckPort(endpointSlice)
		if !exists {
			// Default to using the serving port for health checks.
			healthCheckPort = servingPort
		}
		servingProtocol := findProtocol(servingPort)
		healthCheckProtocol := findProtocol(healthCheckPort)
		appEndpoints := getApplicationEndpoints(endpointSlice)
		app := applications.NewApplication(namespace, k8sServiceName, uint32(*servingPort.Port), servingProtocol, uint32(*healthCheckPort.Port), healthCheckProtocol, appEndpoints)
		apps = append(apps, app)
	}
	return apps
}