forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
legacy_kube_informers.go
64 lines (53 loc) · 1.67 KB
/
legacy_kube_informers.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package shared
import (
"reflect"
kapi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
)
type ReplicationControllerInformer interface {
Informer() cache.SharedIndexInformer
Indexer() cache.Indexer
Lister() *cache.StoreToReplicationControllerLister
}
type replicationControllerInformer struct {
*sharedInformerFactory
}
func (f *replicationControllerInformer) Informer() cache.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerObj := &kapi.ReplicationController{}
informerType := reflect.TypeOf(informerObj)
informer, exists := f.informers[informerType]
if exists {
return informer
}
lw := f.customListerWatchers.GetListerWatcher(kapi.Resource("replicationcontrollers"))
if lw == nil {
lw = &cache.ListWatch{
ListFunc: func(options kapi.ListOptions) (runtime.Object, error) {
return f.kubeClient.Core().ReplicationControllers(kapi.NamespaceAll).List(options)
},
WatchFunc: func(options kapi.ListOptions) (watch.Interface, error) {
return f.kubeClient.Core().ReplicationControllers(kapi.NamespaceAll).Watch(options)
},
}
}
informer = cache.NewSharedIndexInformer(
lw,
informerObj,
f.defaultResync,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
f.informers[informerType] = informer
return informer
}
func (f *replicationControllerInformer) Indexer() cache.Indexer {
informer := f.Informer()
return informer.GetIndexer()
}
func (f *replicationControllerInformer) Lister() *cache.StoreToReplicationControllerLister {
informer := f.Informer()
return &cache.StoreToReplicationControllerLister{Indexer: informer.GetIndexer()}
}