forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
securitycontextconstraints_informers.go
62 lines (51 loc) · 1.64 KB
/
securitycontextconstraints_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
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"
)
type SecurityContextConstraintsInformer interface {
Informer() framework.SharedIndexInformer
Indexer() cache.Indexer
Lister() *oscache.IndexerToSecurityContextConstraintsLister
}
type securityContextConstraintsInformer struct {
*sharedInformerFactory
}
func (s *securityContextConstraintsInformer) Informer() framework.SharedIndexInformer {
s.lock.Lock()
defer s.lock.Unlock()
informerObj := &kapi.SecurityContextConstraints{}
informerType := reflect.TypeOf(informerObj)
informer, exists := s.informers[informerType]
if exists {
return informer
}
informer = framework.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options kapi.ListOptions) (runtime.Object, error) {
return s.kubeClient.SecurityContextConstraints().List(options)
},
WatchFunc: func(options kapi.ListOptions) (watch.Interface, error) {
return s.kubeClient.SecurityContextConstraints().Watch(options)
},
},
informerObj,
s.defaultResync,
cache.Indexers{},
)
s.informers[informerType] = informer
return informer
}
func (s *securityContextConstraintsInformer) Indexer() cache.Indexer {
informer := s.Informer()
return informer.GetIndexer()
}
func (s *securityContextConstraintsInformer) Lister() *oscache.IndexerToSecurityContextConstraintsLister {
informer := s.Informer()
return &oscache.IndexerToSecurityContextConstraintsLister{Indexer: informer.GetIndexer()}
}