github.com/kubeflow/training-operator@v1.7.0/pkg/client/informers/externalversions/kubeflow.org/v1/xgboostjob.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  // XGBoostJobInformer provides access to a shared informer and lister for
    34  // XGBoostJobs.
    35  type XGBoostJobInformer interface {
    36  	Informer() cache.SharedIndexInformer
    37  	Lister() v1.XGBoostJobLister
    38  }
    39  
    40  type xGBoostJobInformer struct {
    41  	factory          internalinterfaces.SharedInformerFactory
    42  	tweakListOptions internalinterfaces.TweakListOptionsFunc
    43  	namespace        string
    44  }
    45  
    46  // NewXGBoostJobInformer constructs a new informer for XGBoostJob 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 NewXGBoostJobInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
    50  	return NewFilteredXGBoostJobInformer(client, namespace, resyncPeriod, indexers, nil)
    51  }
    52  
    53  // NewFilteredXGBoostJobInformer constructs a new informer for XGBoostJob 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 NewFilteredXGBoostJobInformer(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().XGBoostJobs(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().XGBoostJobs(namespace).Watch(context.TODO(), options)
    70  			},
    71  		},
    72  		&kubefloworgv1.XGBoostJob{},
    73  		resyncPeriod,
    74  		indexers,
    75  	)
    76  }
    77  
    78  func (f *xGBoostJobInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
    79  	return NewFilteredXGBoostJobInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
    80  }
    81  
    82  func (f *xGBoostJobInformer) Informer() cache.SharedIndexInformer {
    83  	return f.factory.InformerFor(&kubefloworgv1.XGBoostJob{}, f.defaultInformer)
    84  }
    85  
    86  func (f *xGBoostJobInformer) Lister() v1.XGBoostJobLister {
    87  	return v1.NewXGBoostJobLister(f.Informer().GetIndexer())
    88  }