generic.go 4.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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 externalversions
  15. import (
  16. "fmt"
  17. v1 "github.com/rook/rook/pkg/apis/ceph.rook.io/v1"
  18. schema "k8s.io/apimachinery/pkg/runtime/schema"
  19. cache "k8s.io/client-go/tools/cache"
  20. )
  21. // GenericInformer is type of SharedIndexInformer which will locate and delegate to other
  22. // sharedInformers based on type
  23. type GenericInformer interface {
  24. Informer() cache.SharedIndexInformer
  25. Lister() cache.GenericLister
  26. }
  27. type genericInformer struct {
  28. informer cache.SharedIndexInformer
  29. resource schema.GroupResource
  30. }
  31. // Informer returns the SharedIndexInformer.
  32. func (f *genericInformer) Informer() cache.SharedIndexInformer {
  33. return f.informer
  34. }
  35. // Lister returns the GenericLister.
  36. func (f *genericInformer) Lister() cache.GenericLister {
  37. return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
  38. }
  39. // ForResource gives generic access to a shared informer of the matching type
  40. // TODO extend this to unknown resources with a client pool
  41. func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
  42. switch resource {
  43. // Group=ceph.rook.io, Version=v1
  44. case v1.SchemeGroupVersion.WithResource("cephblockpools"):
  45. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephBlockPools().Informer()}, nil
  46. case v1.SchemeGroupVersion.WithResource("cephblockpoolradosnamespaces"):
  47. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephBlockPoolRadosNamespaces().Informer()}, nil
  48. case v1.SchemeGroupVersion.WithResource("cephbucketnotifications"):
  49. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephBucketNotifications().Informer()}, nil
  50. case v1.SchemeGroupVersion.WithResource("cephbuckettopics"):
  51. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephBucketTopics().Informer()}, nil
  52. case v1.SchemeGroupVersion.WithResource("cephcosidrivers"):
  53. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephCOSIDrivers().Informer()}, nil
  54. case v1.SchemeGroupVersion.WithResource("cephclients"):
  55. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephClients().Informer()}, nil
  56. case v1.SchemeGroupVersion.WithResource("cephclusters"):
  57. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephClusters().Informer()}, nil
  58. case v1.SchemeGroupVersion.WithResource("cephfilesystems"):
  59. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephFilesystems().Informer()}, nil
  60. case v1.SchemeGroupVersion.WithResource("cephfilesystemmirrors"):
  61. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephFilesystemMirrors().Informer()}, nil
  62. case v1.SchemeGroupVersion.WithResource("cephfilesystemsubvolumegroups"):
  63. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephFilesystemSubVolumeGroups().Informer()}, nil
  64. case v1.SchemeGroupVersion.WithResource("cephnfses"):
  65. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephNFSes().Informer()}, nil
  66. case v1.SchemeGroupVersion.WithResource("cephobjectrealms"):
  67. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephObjectRealms().Informer()}, nil
  68. case v1.SchemeGroupVersion.WithResource("cephobjectstores"):
  69. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephObjectStores().Informer()}, nil
  70. case v1.SchemeGroupVersion.WithResource("cephobjectstoreusers"):
  71. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephObjectStoreUsers().Informer()}, nil
  72. case v1.SchemeGroupVersion.WithResource("cephobjectzones"):
  73. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephObjectZones().Informer()}, nil
  74. case v1.SchemeGroupVersion.WithResource("cephobjectzonegroups"):
  75. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephObjectZoneGroups().Informer()}, nil
  76. case v1.SchemeGroupVersion.WithResource("cephrbdmirrors"):
  77. return &genericInformer{resource: resource.GroupResource(), informer: f.Ceph().V1().CephRBDMirrors().Informer()}, nil
  78. }
  79. return nil, fmt.Errorf("no informer found for %v", resource)
  80. }