func generateConfigs(tpl integration.Config, resolveMode endpointResolveMode, kep *v1.Endpoints) []integration.Config {
	if kep == nil {
		log.Warn("Nil Kubernetes Endpoints object, cannot generate config templates")
		return []integration.Config{tpl}
	}
	generatedConfigs := []integration.Config{}
	namespace := kep.Namespace
	name := kep.Name

	// Check resolve annotation to know how we should process this endpoint
	var resolveFunc func(*integration.Config, v1.EndpointAddress)
	switch resolveMode {
	// IP: we explicitly ignore what's behind this address (nothing to do)
	case kubeEndpointResolveIP:
	// In case of unknown value, fallback to auto
	default:
		log.Warnf("Unknown resolve value: %s for endpoint: %s/%s - fallback to auto mode", resolveMode, namespace, name)
		fallthrough
	// Auto or empty (default to auto): we try to resolve the POD behind this address
	case "":
		fallthrough
	case kubeEndpointResolveAuto:
		resolveFunc = utils.ResolveEndpointConfigAuto
	}

	for i := range kep.Subsets {
		for j := range kep.Subsets[i].Addresses {
			// Set a new entity containing the endpoint's IP
			entity := apiserver.EntityForEndpoints(namespace, name, kep.Subsets[i].Addresses[j].IP)
			newConfig := integration.Config{
				Entity:                  entity,
				Name:                    tpl.Name,
				Instances:               tpl.Instances,
				InitConfig:              tpl.InitConfig,
				MetricConfig:            tpl.MetricConfig,
				LogsConfig:              tpl.LogsConfig,
				ADIdentifiers:           []string{entity},
				ClusterCheck:            true,
				Provider:                tpl.Provider,
				Source:                  tpl.Source,
				IgnoreAutodiscoveryTags: tpl.IgnoreAutodiscoveryTags,
			}

			if resolveFunc != nil {
				resolveFunc(&newConfig, kep.Subsets[i].Addresses[j])
			}

			generatedConfigs = append(generatedConfigs, newConfig)
		}
	}
	return generatedConfigs
}
// generateConfigs creates a config template for each Endpoints IP
generateConfigs creates a config template for each Endpoints IP
// generateConfigs creates a config template for each Endpoints IP
func generateConfigs(tpl integration.Config, resolveMode endpointResolveMode, kep *v1.Endpoints) []integration.Config {
	if kep == nil {
		log.Warn("Nil Kubernetes Endpoints object, cannot generate config templates")
		return []integration.Config{tpl}
	}
	generatedConfigs := []integration.Config{}
	namespace := kep.Namespace
	name := kep.Name
	var resolveFunc func(*integration.Config, v1.EndpointAddress)
	switch resolveMode {
	case kubeEndpointResolveIP:
	default:
		log.Warnf("Unknown resolve value: %s for endpoint: %s/%s - fallback to auto mode", resolveMode, namespace, name)
		fallthrough
	case "":
		fallthrough
	case kubeEndpointResolveAuto:
		resolveFunc = utils.ResolveEndpointConfigAuto
	}
	for i := range kep.Subsets {
		for j := range kep.Subsets[i].Addresses {
			entity := apiserver.EntityForEndpoints(namespace, name, kep.Subsets[i].Addresses[j].IP)
			newConfig := integration.Config{
				Entity:                  entity,
				Name:                    tpl.Name,
				Instances:               tpl.Instances,
				InitConfig:              tpl.InitConfig,
				MetricConfig:            tpl.MetricConfig,
				LogsConfig:              tpl.LogsConfig,
				ADIdentifiers:           []string{entity},
				ClusterCheck:            true,
				Provider:                tpl.Provider,
				Source:                  tpl.Source,
				IgnoreAutodiscoveryTags: tpl.IgnoreAutodiscoveryTags,
			}
			if resolveFunc != nil {
				resolveFunc(&newConfig, kep.Subsets[i].Addresses[j])
			}
			generatedConfigs = append(generatedConfigs, newConfig)
		}
	}
	return generatedConfigs
}
func generateConfigs ( tpl integration . Config , resolveMode endpointResolveMode , kep * v1 . Endpoints ) [ ] integration . Config { if kep == nil { log . Warn ( " " ) return [ ] integration . Config { tpl } } generatedConfigs := [ ] integration . Config { } namespace := kep . Namespace name := kep . Name var resolveFunc func ( * integration . Config , v1 . EndpointAddress ) switch resolveMode { case kubeEndpointResolveIP : default : log . Warnf ( " " , resolveMode , namespace , name ) fallthrough case " " : fallthrough case kubeEndpointResolveAuto : resolveFunc = utils . ResolveEndpointConfigAuto } for i := range kep . Subsets { for j := range kep . Subsets [ i ] . Addresses { entity := apiserver . EntityForEndpoints ( namespace , name , kep . Subsets [ i ] . Addresses [ j ] . IP ) newConfig := integration . Config { Entity : entity , Name : tpl . Name , Instances : tpl . Instances , InitConfig : tpl . InitConfig , MetricConfig : tpl . MetricConfig , LogsConfig : tpl . LogsConfig , ADIdentifiers : [ ] string { entity } , ClusterCheck : true , Provider : tpl . Provider , Source : tpl . Source , IgnoreAutodiscoveryTags : tpl . IgnoreAutodiscoveryTags , } if resolveFunc != nil { resolveFunc ( & newConfig , kep . Subsets [ i ] . Addresses [ j ] ) } generatedConfigs = append ( generatedConfigs , newConfig ) } } return generatedConfigs }
generateConfigs creates a config template for each Endpoints IP
generateConfigs creates a config template for each Endpoints IP
// Check resolve annotation to know how we should process this endpoint // IP: we explicitly ignore what's behind this address (nothing to do) // In case of unknown value, fallback to auto // Auto or empty (default to auto): we try to resolve the POD behind this address // Set a new entity containing the endpoint's IP