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