mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-01 18:58:18 +00:00
Add LimitRange informer
This commit is contained in:
@@ -205,6 +205,42 @@ func (f *pvInformer) Lister() *cache.StoreToPVFetcher {
|
||||
return &cache.StoreToPVFetcher{Store: informer.GetStore()}
|
||||
}
|
||||
|
||||
//*****************************************************************************
|
||||
|
||||
// LimitRangeInformer is type of SharedIndexInformer which watches and lists all limit ranges.
|
||||
// Interface provides constructor for informer and lister for limit ranges.
|
||||
type LimitRangeInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() *cache.StoreToLimitRangeLister
|
||||
}
|
||||
|
||||
type limitRangeInformer struct {
|
||||
*sharedInformerFactory
|
||||
}
|
||||
|
||||
// Informer checks whether pvcInformer exists in sharedInformerFactory and if not, it creates new informer of type
|
||||
// limitRangeInformer and connects it to sharedInformerFactory
|
||||
func (f *limitRangeInformer) Informer() cache.SharedIndexInformer {
|
||||
f.lock.Lock()
|
||||
defer f.lock.Unlock()
|
||||
|
||||
informerType := reflect.TypeOf(&api.LimitRange{})
|
||||
informer, exists := f.informers[informerType]
|
||||
if exists {
|
||||
return informer
|
||||
}
|
||||
informer = NewLimitRangeInformer(f.client, f.defaultResync)
|
||||
f.informers[informerType] = informer
|
||||
|
||||
return informer
|
||||
}
|
||||
|
||||
// Lister returns lister for limitRangeInformer
|
||||
func (f *limitRangeInformer) Lister() *cache.StoreToLimitRangeLister {
|
||||
informer := f.Informer()
|
||||
return &cache.StoreToLimitRangeLister{Indexer: informer.GetIndexer()}
|
||||
}
|
||||
|
||||
// NewPodInformer returns a SharedIndexInformer that lists and watches all pods
|
||||
func NewPodInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
sharedIndexInformer := cache.NewSharedIndexInformer(
|
||||
@@ -295,3 +331,21 @@ func NewNamespaceInformer(client clientset.Interface, resyncPeriod time.Duration
|
||||
|
||||
return sharedIndexInformer
|
||||
}
|
||||
|
||||
// NewLimitRangeInformer returns a SharedIndexInformer that lists and watches all LimitRanges
|
||||
func NewLimitRangeInformer(client clientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
sharedIndexInformer := cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options api.ListOptions) (runtime.Object, error) {
|
||||
return client.Core().LimitRanges(api.NamespaceAll).List(options)
|
||||
},
|
||||
WatchFunc: func(options api.ListOptions) (watch.Interface, error) {
|
||||
return client.Core().LimitRanges(api.NamespaceAll).Watch(options)
|
||||
},
|
||||
},
|
||||
&api.LimitRange{},
|
||||
resyncPeriod,
|
||||
cache.Indexers{})
|
||||
|
||||
return sharedIndexInformer
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user