...

Source file src/github.com/linkerd/linkerd2/controller/gen/client/informers/externalversions/generic.go

Documentation: github.com/linkerd/linkerd2/controller/gen/client/informers/externalversions

     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  
    24  	v1beta1 "github.com/linkerd/linkerd2/controller/gen/apis/externalworkload/v1beta1"
    25  	v1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/link/v1alpha1"
    26  	policyv1alpha1 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1alpha1"
    27  	v1beta3 "github.com/linkerd/linkerd2/controller/gen/apis/policy/v1beta3"
    28  	serverv1beta1 "github.com/linkerd/linkerd2/controller/gen/apis/server/v1beta1"
    29  	v1beta2 "github.com/linkerd/linkerd2/controller/gen/apis/server/v1beta2"
    30  	serverauthorizationv1beta1 "github.com/linkerd/linkerd2/controller/gen/apis/serverauthorization/v1beta1"
    31  	v1alpha2 "github.com/linkerd/linkerd2/controller/gen/apis/serviceprofile/v1alpha2"
    32  	schema "k8s.io/apimachinery/pkg/runtime/schema"
    33  	cache "k8s.io/client-go/tools/cache"
    34  )
    35  
    36  // GenericInformer is type of SharedIndexInformer which will locate and delegate to other
    37  // sharedInformers based on type
    38  type GenericInformer interface {
    39  	Informer() cache.SharedIndexInformer
    40  	Lister() cache.GenericLister
    41  }
    42  
    43  type genericInformer struct {
    44  	informer cache.SharedIndexInformer
    45  	resource schema.GroupResource
    46  }
    47  
    48  // Informer returns the SharedIndexInformer.
    49  func (f *genericInformer) Informer() cache.SharedIndexInformer {
    50  	return f.informer
    51  }
    52  
    53  // Lister returns the GenericLister.
    54  func (f *genericInformer) Lister() cache.GenericLister {
    55  	return cache.NewGenericLister(f.Informer().GetIndexer(), f.resource)
    56  }
    57  
    58  // ForResource gives generic access to a shared informer of the matching type
    59  // TODO extend this to unknown resources with a client pool
    60  func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) {
    61  	switch resource {
    62  	// Group=externalworkload, Version=v1beta1
    63  	case v1beta1.SchemeGroupVersion.WithResource("externalworkloads"):
    64  		return &genericInformer{resource: resource.GroupResource(), informer: f.Externalworkload().V1beta1().ExternalWorkloads().Informer()}, nil
    65  
    66  		// Group=link, Version=v1alpha1
    67  	case v1alpha1.SchemeGroupVersion.WithResource("links"):
    68  		return &genericInformer{resource: resource.GroupResource(), informer: f.Link().V1alpha1().Links().Informer()}, nil
    69  
    70  		// Group=linkerd.io, Version=v1alpha2
    71  	case v1alpha2.SchemeGroupVersion.WithResource("serviceprofiles"):
    72  		return &genericInformer{resource: resource.GroupResource(), informer: f.Linkerd().V1alpha2().ServiceProfiles().Informer()}, nil
    73  
    74  		// Group=policy, Version=v1alpha1
    75  	case policyv1alpha1.SchemeGroupVersion.WithResource("authorizationpolicies"):
    76  		return &genericInformer{resource: resource.GroupResource(), informer: f.Policy().V1alpha1().AuthorizationPolicies().Informer()}, nil
    77  	case policyv1alpha1.SchemeGroupVersion.WithResource("httproutes"):
    78  		return &genericInformer{resource: resource.GroupResource(), informer: f.Policy().V1alpha1().HTTPRoutes().Informer()}, nil
    79  	case policyv1alpha1.SchemeGroupVersion.WithResource("meshtlsauthentications"):
    80  		return &genericInformer{resource: resource.GroupResource(), informer: f.Policy().V1alpha1().MeshTLSAuthentications().Informer()}, nil
    81  	case policyv1alpha1.SchemeGroupVersion.WithResource("networkauthentications"):
    82  		return &genericInformer{resource: resource.GroupResource(), informer: f.Policy().V1alpha1().NetworkAuthentications().Informer()}, nil
    83  
    84  		// Group=policy, Version=v1beta3
    85  	case v1beta3.SchemeGroupVersion.WithResource("httproutes"):
    86  		return &genericInformer{resource: resource.GroupResource(), informer: f.Policy().V1beta3().HTTPRoutes().Informer()}, nil
    87  
    88  		// Group=server, Version=v1beta1
    89  	case serverv1beta1.SchemeGroupVersion.WithResource("servers"):
    90  		return &genericInformer{resource: resource.GroupResource(), informer: f.Server().V1beta1().Servers().Informer()}, nil
    91  
    92  		// Group=server, Version=v1beta2
    93  	case v1beta2.SchemeGroupVersion.WithResource("servers"):
    94  		return &genericInformer{resource: resource.GroupResource(), informer: f.Server().V1beta2().Servers().Informer()}, nil
    95  
    96  		// Group=serverauthorization, Version=v1beta1
    97  	case serverauthorizationv1beta1.SchemeGroupVersion.WithResource("serverauthorizations"):
    98  		return &genericInformer{resource: resource.GroupResource(), informer: f.Serverauthorization().V1beta1().ServerAuthorizations().Informer()}, nil
    99  
   100  	}
   101  
   102  	return nil, fmt.Errorf("no informer found for %v", resource)
   103  }
   104  

View as plain text