Exemplo n.º 1
0
// ListResourceUsingInformerFunc returns a listing function based on the shared informer factory for the specified resource.
func ListResourceUsingInformerFunc(f informers.SharedInformerFactory, groupResource unversioned.GroupResource) ListFuncByNamespace {
	return func(namespace string, options api.ListOptions) ([]runtime.Object, error) {
		informer, err := f.ForResource(groupResource)
		if err != nil {
			return nil, err
		}
		return informer.Lister().ByNamespace(namespace).List(options.LabelSelector)
	}
}
// controllerFor returns a replenishment controller for the specified group resource.
func controllerFor(
	groupResource schema.GroupResource,
	f informers.SharedInformerFactory,
	handlerFuncs cache.ResourceEventHandlerFuncs) (cache.ControllerInterface, error) {
	genericInformer, err := f.ForResource(groupResource)
	if err != nil {
		return nil, err
	}
	informer := genericInformer.Informer()
	informer.AddEventHandler(handlerFuncs)
	return informer.GetController(), nil
}
Exemplo n.º 3
0
// ListResourceUsingInformerFunc returns a listing function based on the shared informer factory for the specified resource.
func ListResourceUsingInformerFunc(f informers.SharedInformerFactory, groupResource schema.GroupResource) ListFuncByNamespace {
	return func(namespace string, options v1.ListOptions) ([]runtime.Object, error) {
		labelSelector, err := labels.Parse(options.LabelSelector)
		if err != nil {
			return nil, err
		}
		informer, err := f.ForResource(groupResource)
		if err != nil {
			return nil, err
		}
		return informer.Lister().ByNamespace(namespace).List(labelSelector)
	}
}
Exemplo n.º 4
0
func (p *podNodeSelector) SetInformerFactory(f informers.SharedInformerFactory) {
	p.namespaceInformer = f.InternalNamespaces().Informer()
	p.SetReadyFunc(p.namespaceInformer.HasSynced)
}
Exemplo n.º 5
0
func (p *provision) SetInformerFactory(f informers.SharedInformerFactory) {
	p.namespaceInformer = f.Namespaces().Informer()
	p.SetReadyFunc(p.namespaceInformer.HasSynced)
}
Exemplo n.º 6
0
func (l *limitRanger) SetInformerFactory(f informers.SharedInformerFactory) {
	limitRangeInformer := f.InternalLimitRanges().Informer()
	l.SetReadyFunc(limitRangeInformer.HasSynced)
	l.lister = f.InternalLimitRanges().Lister()
}
Exemplo n.º 7
0
func (e *exists) SetInformerFactory(f informers.SharedInformerFactory) {
	e.namespaceInformer = f.InternalNamespaces().Informer()
	e.SetReadyFunc(e.namespaceInformer.HasSynced)
}
Exemplo n.º 8
0
func (l *lifecycle) SetInformerFactory(f informers.SharedInformerFactory) {
	l.namespaceInformer = f.Namespaces().Informer()
	l.SetReadyFunc(l.namespaceInformer.HasSynced)
}