func (im *TXTRegistry) Records() ([]*endpoint.Endpoint, error) {
	// If we have the zones cached AND we have refreshed the cache since the
	// last given interval, then just use the cached results.
	if im.recordsCache != nil && time.Since(im.recordsCacheRefreshTime) < im.cacheInterval {
		log.Debug("Using cached records.")
		return im.recordsCache, nil
	}

	records, err := im.provider.Records()
	if err != nil {
		return nil, err
	}

	endpoints := []*endpoint.Endpoint{}

	labelMap := map[string]endpoint.Labels{}

	for _, record := range records {
		if record.RecordType != endpoint.RecordTypeTXT {
			endpoints = append(endpoints, record)
			continue
		}
		// We simply assume that TXT records for the registry will always have only one target.
		labels, err := endpoint.NewLabelsFromString(record.Targets[0])
		if err == endpoint.ErrInvalidHeritage {
			//if no heritage is found or it is invalid
			//case when value of txt record cannot be identified
			//record will not be removed as it will have empty owner
			endpoints = append(endpoints, record)
			continue
		}
		if err != nil {
			return nil, err
		}
		endpointDNSName := im.mapper.toEndpointName(record.DNSName)
		labelMap[endpointDNSName] = labels
	}

	for _, ep := range endpoints {
		ep.Labels = endpoint.NewLabels()
		if labels, ok := labelMap[ep.DNSName]; ok {
			for k, v := range labels {
				ep.Labels[k] = v
			}
		}
	}

	// Update the cache.
	if im.cacheInterval > 0 {
		im.recordsCache = endpoints
		im.recordsCacheRefreshTime = time.Now()
	}

	return endpoints, nil
}
func (im *TXTRegistry) Records() ([]*endpoint.Endpoint, error) {
	
	
	if im.recordsCache != nil && time.Since(im.recordsCacheRefreshTime) < im.cacheInterval {
		log.Debug("Using cached records.")
		return im.recordsCache, nil
	}

	records, err := im.provider.Records()
	if err != nil {
		return nil, err
	}

	endpoints := []*endpoint.Endpoint{}

	labelMap := map[string]endpoint.Labels{}

	for _, record := range records {
		if record.RecordType != endpoint.RecordTypeTXT {
			endpoints = append(endpoints, record)
			continue
		}
		
		labels, err := endpoint.NewLabelsFromString(record.Targets[0])
		if err == endpoint.ErrInvalidHeritage {
			
			
			
			endpoints = append(endpoints, record)
			continue
		}
		if err != nil {
			return nil, err
		}
		endpointDNSName := im.mapper.toEndpointName(record.DNSName)
		labelMap[endpointDNSName] = labels
	}

	for _, ep := range endpoints {
		ep.Labels = endpoint.NewLabels()
		if labels, ok := labelMap[ep.DNSName]; ok {
			for k, v := range labels {
				ep.Labels[k] = v
			}
		}
	}

	
	if im.cacheInterval > 0 {
		im.recordsCache = endpoints
		im.recordsCacheRefreshTime = time.Now()
	}

	return endpoints, nil
}
func ( im * TXTRegistry ) Records ( ) ( [ ] * endpoint . Endpoint , error ) { // If we have the zones cached AND we have refreshed the cache since the // last given interval, then just use the cached results. if im . recordsCache != nil && time . Since ( im . recordsCacheRefreshTime ) < im . cacheInterval { log . Debug ( " " ) return im . recordsCache , nil } records , err := im . provider . Records ( ) if err != nil { return nil , err } endpoints := [ ] * endpoint . Endpoint { } labelMap := map [ string ] endpoint . Labels { } for _ , record := range records { if record . RecordType != endpoint . RecordTypeTXT { endpoints = append ( endpoints , record ) continue } // We simply assume that TXT records for the registry will always have only one target. labels , err := endpoint . NewLabelsFromString ( record . Targets [ 0 ] ) if err == endpoint . ErrInvalidHeritage { //if no heritage is found or it is invalid //case when value of txt record cannot be identified //record will not be removed as it will have empty owner endpoints = append ( endpoints , record ) continue } if err != nil { return nil , err } endpointDNSName := im . mapper . toEndpointName ( record . DNSName ) labelMap [ endpointDNSName ] = labels } for _ , ep := range endpoints { ep . Labels = endpoint . NewLabels ( ) if labels , ok := labelMap [ ep . DNSName ] ; ok { for k , v := range labels { ep . Labels [ k ] = v } } } // Update the cache. if im . cacheInterval > 0 { im . recordsCache = endpoints im . recordsCacheRefreshTime = time . Now ( ) } return endpoints , nil }
// Records returns the current records from the registry excluding TXT Records
// If TXT records was created previously to indicate ownership its corresponding value
// will be added to the endpoints Labels map
Records returns the current records from the registry excluding TXT Records If TXT records was created previously to indicate ownership its corresponding value will be added to the endpoints Labels map