func NewKubeEndpointsConfigProvider(config config.ConfigurationProviders) (ConfigProvider, error) {
	// Using GetAPIClient (no wait) as Client should already be initialized by Cluster Agent main entrypoint before
	ac, err := apiserver.GetAPIClient()
	if err != nil {
		return nil, fmt.Errorf("cannot connect to apiserver: %s", err)
	}

	servicesInformer := ac.InformerFactory.Core().V1().Services()
	if servicesInformer == nil {
		return nil, fmt.Errorf("cannot get service informer: %s", err)
	}

	p := &kubeEndpointsConfigProvider{
		serviceLister:      servicesInformer.Lister(),
		monitoredEndpoints: make(map[string]bool),
	}

	servicesInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc:    p.invalidate,
		UpdateFunc: p.invalidateIfChangedService,
		DeleteFunc: p.invalidate,
	})

	endpointsInformer := ac.InformerFactory.Core().V1().Endpoints()
	if endpointsInformer == nil {
		return nil, fmt.Errorf("cannot get endpoint informer: %s", err)
	}

	p.endpointsLister = endpointsInformer.Lister()

	endpointsInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		UpdateFunc: p.invalidateIfChangedEndpoints,
	})

	return p, nil
}
// NewKubeEndpointsConfigProvider returns a new ConfigProvider connected to apiserver.
// Connectivity is not checked at this stage to allow for retries, Collect will do it.
NewKubeEndpointsConfigProvider returns a new ConfigProvider connected to apiserver.
Connectivity is not checked at this stage to allow for retries, Collect will do it.
// NewKubeEndpointsConfigProvider returns a new ConfigProvider connected to apiserver . // Connectivity is not checked at this stage to allow for retries Collect will do it .
func NewKubeEndpointsConfigProvider(config config.ConfigurationProviders) (ConfigProvider, error) {
	ac, err := apiserver.GetAPIClient()
	if err != nil {
		return nil, fmt.Errorf("cannot connect to apiserver: %s", err)
	}
	servicesInformer := ac.InformerFactory.Core().V1().Services()
	if servicesInformer == nil {
		return nil, fmt.Errorf("cannot get service informer: %s", err)
	}
	p := &kubeEndpointsConfigProvider{
		serviceLister:      servicesInformer.Lister(),
		monitoredEndpoints: make(map[string]bool),
	}
	servicesInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		AddFunc:    p.invalidate,
		UpdateFunc: p.invalidateIfChangedService,
		DeleteFunc: p.invalidate,
	})
	endpointsInformer := ac.InformerFactory.Core().V1().Endpoints()
	if endpointsInformer == nil {
		return nil, fmt.Errorf("cannot get endpoint informer: %s", err)
	}
	p.endpointsLister = endpointsInformer.Lister()
	endpointsInformer.Informer().AddEventHandler(cache.ResourceEventHandlerFuncs{
		UpdateFunc: p.invalidateIfChangedEndpoints,
	})
	return p, nil
}
func NewKubeEndpointsConfigProvider ( config config . ConfigurationProviders ) ( ConfigProvider , error ) { ac , err := apiserver . GetAPIClient ( ) if err != nil { return nil , fmt . Errorf ( " " , err ) } servicesInformer := ac . InformerFactory . Core ( ) . V1 ( ) . Services ( ) if servicesInformer == nil { return nil , fmt . Errorf ( " " , err ) } p := & kubeEndpointsConfigProvider { serviceLister : servicesInformer . Lister ( ) , monitoredEndpoints : make ( map [ string ] bool ) , } servicesInformer . Informer ( ) . AddEventHandler ( cache . ResourceEventHandlerFuncs { AddFunc : p . invalidate , UpdateFunc : p . invalidateIfChangedService , DeleteFunc : p . invalidate , } ) endpointsInformer := ac . InformerFactory . Core ( ) . V1 ( ) . Endpoints ( ) if endpointsInformer == nil { return nil , fmt . Errorf ( " " , err ) } p . endpointsLister = endpointsInformer . Lister ( ) endpointsInformer . Informer ( ) . AddEventHandler ( cache . ResourceEventHandlerFuncs { UpdateFunc : p . invalidateIfChangedEndpoints , } ) return p , nil }
NewKubeEndpointsConfigProvider returns a new ConfigProvider connected to apiserver.
NewKubeEndpointsConfigProvider returns a new ConfigProvider connected to apiserver .
// Using GetAPIClient (no wait) as Client should already be initialized by Cluster Agent main entrypoint before