source/gateway.go
func (sc *gatewaySource) endpointsFromGatewayConfig(config istiomodel.Config) ([]*endpoint.Endpoint, error) {
	var endpoints []*endpoint.Endpoint

	ttl, err := getTTLFromAnnotations(config.Annotations)
	if err != nil {
		log.Warn(err)
	}

	targets := getTargetsFromTargetAnnotation(config.Annotations)

	if len(targets) == 0 {
		targets, err = sc.targetsFromIstioIngressGatewayServices()
		if err != nil {
			return nil, err
		}
	}

	gateway := config.Spec.(*istionetworking.Gateway)

	providerSpecific := getProviderSpecificAnnotations(config.Annotations)

	for _, server := range gateway.Servers {
		for _, host := range server.Hosts {
			if host == "" {
				continue
			}
			endpoints = append(endpoints, endpointsForHostname(host, targets, ttl, providerSpecific)...)
		}
	}

	// Skip endpoints if we do not want entries from annotations
	if !sc.ignoreHostnameAnnotation {
		hostnameList := getHostnamesFromAnnotations(config.Annotations)
		for _, hostname := range hostnameList {
			endpoints = append(endpoints, endpointsForHostname(hostname, targets, ttl, providerSpecific)...)
		}
	}

	return endpoints, nil
}
func (sc *gatewaySource) endpointsFromGatewayConfig(config istiomodel.Config) ([]*endpoint.Endpoint, error) {
	var endpoints []*endpoint.Endpoint

	ttl, err := getTTLFromAnnotations(config.Annotations)
	if err != nil {
		log.Warn(err)
	}

	targets := getTargetsFromTargetAnnotation(config.Annotations)

	if len(targets) == 0 {
		targets, err = sc.targetsFromIstioIngressGatewayServices()
		if err != nil {
			return nil, err
		}
	}

	gateway := config.Spec.(*istionetworking.Gateway)

	providerSpecific := getProviderSpecificAnnotations(config.Annotations)

	for _, server := range gateway.Servers {
		for _, host := range server.Hosts {
			if host == "" {
				continue
			}
			endpoints = append(endpoints, endpointsForHostname(host, targets, ttl, providerSpecific)...)
		}
	}

	// Skip endpoints if we do not want entries from annotations
	if !sc.ignoreHostnameAnnotation {
		hostnameList := getHostnamesFromAnnotations(config.Annotations)
		for _, hostname := range hostnameList {
			endpoints = append(endpoints, endpointsForHostname(hostname, targets, ttl, providerSpecific)...)
		}
	}

	return endpoints, nil
}
func ( sc * gatewaySource ) endpointsFromGatewayConfig ( config istiomodel . Config ) ( [ ] * endpoint . Endpoint , error ) { var endpoints [ ] * endpoint . Endpoint ttl , err := getTTLFromAnnotations ( config . Annotations ) if err != nil { log . Warn ( err ) } targets := getTargetsFromTargetAnnotation ( config . Annotations ) if len ( targets ) == 0 { targets , err = sc . targetsFromIstioIngressGatewayServices ( ) if err != nil { return nil , err } } gateway := config . Spec . ( * istionetworking . Gateway ) providerSpecific := getProviderSpecificAnnotations ( config . Annotations ) for _ , server := range gateway . Servers { for _ , host := range server . Hosts { if host == " " { continue } endpoints = append ( endpoints , endpointsForHostname ( host , targets , ttl , providerSpecific ) ... ) } } // Skip endpoints if we do not want entries from annotations if ! sc . ignoreHostnameAnnotation { hostnameList := getHostnamesFromAnnotations ( config . Annotations ) for _ , hostname := range hostnameList { endpoints = append ( endpoints , endpointsForHostname ( hostname , targets , ttl , providerSpecific ) ... ) } } return endpoints , nil }
// endpointsFromGatewayConfig extracts the endpoints from an Istio Gateway Config object
endpointsFromGatewayConfig extracts the endpoints from an Istio Gateway Config object