1/* 2Copyright The Kubernetes Authors. 3 4Licensed under the Apache License, Version 2.0 (the "License"); 5you may not use this file except in compliance with the License. 6You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10Unless required by applicable law or agreed to in writing, software 11distributed under the License is distributed on an "AS IS" BASIS, 12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13See the License for the specific language governing permissions and 14limitations under the License. 15*/ 16 17// Code generated by informer-gen. DO NOT EDIT. 18 19package externalversions 20 21import ( 22 "fmt" 23 24 schema "k8s.io/apimachinery/pkg/runtime/schema" 25 cache "k8s.io/client-go/tools/cache" 26 v1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1" 27 v1beta1 "k8s.io/kube-aggregator/pkg/apis/apiregistration/v1beta1" 28) 29 30// GenericInformer is type of SharedIndexInformer which will locate and delegate to other 31// sharedInformers based on type 32type GenericInformer interface { 33 Informer() cache.SharedIndexInformer 34 Lister() cache.GenericLister 35} 36 37type genericInformer struct { 38 informer cache.SharedIndexInformer 39 resource schema.GroupResource 40} 41 42// Informer returns the SharedIndexInformer. 43func (f *genericInformer) Informer() cache.SharedIndexInformer { 44 return f.informer 45} 46 47// Lister returns the GenericLister. 48func (f *genericInformer) Lister() cache.GenericLister { 49 return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource) 50} 51 52// ForResource gives generic access to a shared informer of the matching type 53// TODO extend this to unknown resources with a client pool 54func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { 55 switch resource { 56 // Group=apiregistration.k8s.io, Version=v1 57 case v1.SchemeGroupVersion.WithResource("apiservices"): 58 return &genericInformer{resource: resource.GroupResource(), informer: f.Apiregistration().V1().APIServices().Informer()}, nil 59 60 // Group=apiregistration.k8s.io, Version=v1beta1 61 case v1beta1.SchemeGroupVersion.WithResource("apiservices"): 62 return &genericInformer{resource: resource.GroupResource(), informer: f.Apiregistration().V1beta1().APIServices().Informer()}, nil 63 64 } 65 66 return nil, fmt.Errorf("no informer found for %v", resource) 67} 68