clusterrole.go 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. /*
  2. Copyright The Kubernetes Authors.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. // Code generated by informer-gen. DO NOT EDIT.
  14. package v1alpha1
  15. import (
  16. "context"
  17. time "time"
  18. rbacv1alpha1 "k8s.io/api/rbac/v1alpha1"
  19. v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
  20. runtime "k8s.io/apimachinery/pkg/runtime"
  21. watch "k8s.io/apimachinery/pkg/watch"
  22. internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
  23. kubernetes "k8s.io/client-go/kubernetes"
  24. v1alpha1 "k8s.io/client-go/listers/rbac/v1alpha1"
  25. cache "k8s.io/client-go/tools/cache"
  26. )
  27. // ClusterRoleInformer provides access to a shared informer and lister for
  28. // ClusterRoles.
  29. type ClusterRoleInformer interface {
  30. Informer() cache.SharedIndexInformer
  31. Lister() v1alpha1.ClusterRoleLister
  32. }
  33. type clusterRoleInformer struct {
  34. factory internalinterfaces.SharedInformerFactory
  35. tweakListOptions internalinterfaces.TweakListOptionsFunc
  36. }
  37. // NewClusterRoleInformer constructs a new informer for ClusterRole type.
  38. // Always prefer using an informer factory to get a shared informer instead of getting an independent
  39. // one. This reduces memory footprint and number of connections to the server.
  40. func NewClusterRoleInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
  41. return NewFilteredClusterRoleInformer(client, resyncPeriod, indexers, nil)
  42. }
  43. // NewFilteredClusterRoleInformer constructs a new informer for ClusterRole type.
  44. // Always prefer using an informer factory to get a shared informer instead of getting an independent
  45. // one. This reduces memory footprint and number of connections to the server.
  46. func NewFilteredClusterRoleInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
  47. return cache.NewSharedIndexInformer(
  48. &cache.ListWatch{
  49. ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
  50. if tweakListOptions != nil {
  51. tweakListOptions(&options)
  52. }
  53. return client.RbacV1alpha1().ClusterRoles().List(context.TODO(), options)
  54. },
  55. WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
  56. if tweakListOptions != nil {
  57. tweakListOptions(&options)
  58. }
  59. return client.RbacV1alpha1().ClusterRoles().Watch(context.TODO(), options)
  60. },
  61. },
  62. &rbacv1alpha1.ClusterRole{},
  63. resyncPeriod,
  64. indexers,
  65. )
  66. }
  67. func (f *clusterRoleInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
  68. return NewFilteredClusterRoleInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
  69. }
  70. func (f *clusterRoleInformer) Informer() cache.SharedIndexInformer {
  71. return f.factory.InformerFor(&rbacv1alpha1.ClusterRole{}, f.defaultInformer)
  72. }
  73. func (f *clusterRoleInformer) Lister() v1alpha1.ClusterRoleLister {
  74. return v1alpha1.NewClusterRoleLister(f.Informer().GetIndexer())
  75. }