/
role.go
57 lines (49 loc) · 2.21 KB
/
role.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
// This file was automatically generated by informer-gen
package internalversion
import (
authorization "github.com/openshift/origin/pkg/authorization/apis/authorization"
internalinterfaces "github.com/openshift/origin/pkg/authorization/generated/informers/internalversion/internalinterfaces"
internalclientset "github.com/openshift/origin/pkg/authorization/generated/internalclientset"
internalversion "github.com/openshift/origin/pkg/authorization/generated/listers/authorization/internalversion"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
cache "k8s.io/client-go/tools/cache"
time "time"
)
// RoleInformer provides access to a shared informer and lister for
// Roles.
type RoleInformer interface {
Informer() cache.SharedIndexInformer
Lister() internalversion.RoleLister
}
type roleInformer struct {
factory internalinterfaces.SharedInformerFactory
}
// NewRoleInformer constructs a new informer for Role type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewRoleInformer(client internalclientset.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
return client.Authorization().Roles(namespace).List(options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
return client.Authorization().Roles(namespace).Watch(options)
},
},
&authorization.Role{},
resyncPeriod,
indexers,
)
}
func defaultRoleInformer(client internalclientset.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewRoleInformer(client, v1.NamespaceAll, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc})
}
func (f *roleInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&authorization.Role{}, defaultRoleInformer)
}
func (f *roleInformer) Lister() internalversion.RoleLister {
return internalversion.NewRoleLister(f.Informer().GetIndexer())
}