github.com/kubeflow/training-operator@v1.7.0/pkg/client/informers/externalversions/kubeflow.org/v1/paddlejob.go (about) 1 // Copyright 2023 The Kubeflow Authors 2 // 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 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 // Code generated by informer-gen. DO NOT EDIT. 16 17 package v1 18 19 import ( 20 "context" 21 time "time" 22 23 kubefloworgv1 "github.com/kubeflow/training-operator/pkg/apis/kubeflow.org/v1" 24 versioned "github.com/kubeflow/training-operator/pkg/client/clientset/versioned" 25 internalinterfaces "github.com/kubeflow/training-operator/pkg/client/informers/externalversions/internalinterfaces" 26 v1 "github.com/kubeflow/training-operator/pkg/client/listers/kubeflow.org/v1" 27 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" 28 runtime "k8s.io/apimachinery/pkg/runtime" 29 watch "k8s.io/apimachinery/pkg/watch" 30 cache "k8s.io/client-go/tools/cache" 31 ) 32 33 // PaddleJobInformer provides access to a shared informer and lister for 34 // PaddleJobs. 35 type PaddleJobInformer interface { 36 Informer() cache.SharedIndexInformer 37 Lister() v1.PaddleJobLister 38 } 39 40 type paddleJobInformer struct { 41 factory internalinterfaces.SharedInformerFactory 42 tweakListOptions internalinterfaces.TweakListOptionsFunc 43 namespace string 44 } 45 46 // NewPaddleJobInformer constructs a new informer for PaddleJob type. 47 // Always prefer using an informer factory to get a shared informer instead of getting an independent 48 // one. This reduces memory footprint and number of connections to the server. 49 func NewPaddleJobInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { 50 return NewFilteredPaddleJobInformer(client, namespace, resyncPeriod, indexers, nil) 51 } 52 53 // NewFilteredPaddleJobInformer constructs a new informer for PaddleJob type. 54 // Always prefer using an informer factory to get a shared informer instead of getting an independent 55 // one. This reduces memory footprint and number of connections to the server. 56 func NewFilteredPaddleJobInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { 57 return cache.NewSharedIndexInformer( 58 &cache.ListWatch{ 59 ListFunc: func(options metav1.ListOptions) (runtime.Object, error) { 60 if tweakListOptions != nil { 61 tweakListOptions(&options) 62 } 63 return client.KubeflowV1().PaddleJobs(namespace).List(context.TODO(), options) 64 }, 65 WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) { 66 if tweakListOptions != nil { 67 tweakListOptions(&options) 68 } 69 return client.KubeflowV1().PaddleJobs(namespace).Watch(context.TODO(), options) 70 }, 71 }, 72 &kubefloworgv1.PaddleJob{}, 73 resyncPeriod, 74 indexers, 75 ) 76 } 77 78 func (f *paddleJobInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { 79 return NewFilteredPaddleJobInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) 80 } 81 82 func (f *paddleJobInformer) Informer() cache.SharedIndexInformer { 83 return f.factory.InformerFor(&kubefloworgv1.PaddleJob{}, f.defaultInformer) 84 } 85 86 func (f *paddleJobInformer) Lister() v1.PaddleJobLister { 87 return v1.NewPaddleJobLister(f.Informer().GetIndexer()) 88 }