forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
imagestream_informers.go
63 lines (52 loc) · 1.61 KB
/
imagestream_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
package shared
import (
"reflect"
kapi "k8s.io/kubernetes/pkg/api"
"k8s.io/kubernetes/pkg/client/cache"
"k8s.io/kubernetes/pkg/controller/framework"
"k8s.io/kubernetes/pkg/runtime"
"k8s.io/kubernetes/pkg/watch"
oscache "github.com/openshift/origin/pkg/client/cache"
imageapi "github.com/openshift/origin/pkg/image/api"
)
type ImageStreamInformer interface {
Informer() framework.SharedIndexInformer
Indexer() cache.Indexer
Lister() *oscache.StoreToImageStreamLister
}
type imageStreamInformer struct {
*sharedInformerFactory
}
func (f *imageStreamInformer) Informer() framework.SharedIndexInformer {
f.lock.Lock()
defer f.lock.Unlock()
informerObj := &imageapi.ImageStream{}
informerType := reflect.TypeOf(informerObj)
informer, exists := f.informers[informerType]
if exists {
return informer
}
informer = framework.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options kapi.ListOptions) (runtime.Object, error) {
return f.originClient.ImageStreams(kapi.NamespaceAll).List(options)
},
WatchFunc: func(options kapi.ListOptions) (watch.Interface, error) {
return f.originClient.ImageStreams(kapi.NamespaceAll).Watch(options)
},
},
informerObj,
f.defaultResync,
cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc},
)
f.informers[informerType] = informer
return informer
}
func (f *imageStreamInformer) Indexer() cache.Indexer {
informer := f.Informer()
return informer.GetIndexer()
}
func (f *imageStreamInformer) Lister() *oscache.StoreToImageStreamLister {
informer := f.Informer()
return &oscache.StoreToImageStreamLister{Indexer: informer.GetIndexer()}
}