/* Copyright The Kubernetes Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ // Code generated by informer-gen. DO NOT EDIT. package v1alpha1 import ( context "context" time "time" v1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" schema "k8s.io/apimachinery/pkg/runtime/schema" watch "k8s.io/apimachinery/pkg/watch" cache "k8s.io/client-go/tools/cache" apissamplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/apis/samplecontroller/v1alpha1" versioned "k8s.io/sample-controller/pkg/generated/clientset/versioned" internalinterfaces "k8s.io/sample-controller/pkg/generated/informers/externalversions/internalinterfaces" samplecontrollerv1alpha1 "k8s.io/sample-controller/pkg/generated/listers/samplecontroller/v1alpha1" ) // FooInformer provides access to a shared informer and lister for // Foos. Prefer using the type-safe variant (see [TypedFooInformer]). type FooInformer interface { Informer() cache.SharedIndexInformer Lister() samplecontrollerv1alpha1.FooLister } // TypedFooInformer provides access to a shared informer and lister for // Foos, including the type-safe TypedInformer variant. // It is a superset of FooInformer. type TypedFooInformer interface { Informer() cache.SharedIndexInformer TypedInformer() FooIndexInformer Lister() samplecontrollerv1alpha1.FooLister } // FooIndexInformer is a wrapper around the underlying [cache.SharedIndexInformer] // with type-safe variants of several methods. type FooIndexInformer cache.TypedSharedIndexInformer[*apissamplecontrollerv1alpha1.Foo] // FooHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerFuncs] for Foo. type FooHandlerFuncs = cache.TypedResourceEventHandlerFuncs[*apissamplecontrollerv1alpha1.Foo] // FooDetailedHandlerFuncs is a specialization of [cache.TypedResourceEventHandlerDetailedFuncs] for Foo. type FooDetailedHandlerFuncs = cache.TypedResourceEventHandlerDetailedFuncs[*apissamplecontrollerv1alpha1.Foo] // FooFilteringHandler is a specialization of [cache.TypedFilteringResourceEventHandler] for Foo. type FooFilteringHandler = cache.TypedFilteringResourceEventHandler[*apissamplecontrollerv1alpha1.Foo] // FooIndexers is a specialization of [cache.TypedIndexers] for Foo. type FooIndexers = cache.TypedIndexers[*apissamplecontrollerv1alpha1.Foo] // DeletedFoo is a specialization of [cache.DeletedObject] for Foo. type DeletedFoo = cache.DeletedObject[*apissamplecontrollerv1alpha1.Foo] type fooInformer struct { factory internalinterfaces.SharedInformerFactory tweakListOptions internalinterfaces.TweakListOptionsFunc namespace string } // NewFooInformer constructs a new informer for Foo type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. // If you really need an independent one, prefer using the type-safe variant (see [NewTypedFooInformer]). func NewFooInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { return NewFooInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers}) } // NewTypedFooInformer constructs a new informer for Foo type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. func NewTypedFooInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers FooIndexers) FooIndexInformer { return NewTypedFooInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers)}) } // NewFilteredFooInformer constructs a new informer for Foo type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. // If you really need an independent one, prefer using the type-safe variant (see [NewTypedFilteredFooInformer]). func NewFilteredFooInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer { return NewTypedFooInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: indexers, TweakListOptions: tweakListOptions}) } // NewTypedFilteredFooInformer constructs a new informer for Foo type. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. func NewTypedFilteredFooInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers FooIndexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) FooIndexInformer { return NewTypedFooInformerWithOptions(client, namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.TypedIndexersToIndexers(indexers), TweakListOptions: tweakListOptions}) } // NewFooInformerWithOptions constructs a new informer for Foo type with additional options. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. // If you really need an independent one, prefer using the type-safe variant (see [NewTypedFooInformerWithOptions]). func NewFooInformerWithOptions(client versioned.Interface, namespace string, options internalinterfaces.InformerOptions) cache.SharedIndexInformer { return NewTypedFooInformerWithOptions(client, namespace, options) } // NewTypedFooInformerWithOptions constructs a new informer for Foo type with additional options. // Always prefer using an informer factory to get a shared informer instead of getting an independent // one. This reduces memory footprint and number of connections to the server. func NewTypedFooInformerWithOptions(client versioned.Interface, namespace string, options internalinterfaces.InformerOptions) FooIndexInformer { gvr := schema.GroupVersionResource{Group: "samplecontroller.k8s.io", Version: "v1alpha1", Resource: "foos"} identifier := options.InformerName.WithResource(gvr) tweakListOptions := options.TweakListOptions return cache.NewTypedSharedIndexInformer[*apissamplecontrollerv1alpha1.Foo](cache.NewSharedIndexInformerWithOptions( cache.ToListWatcherWithWatchListSemantics(&cache.ListWatch{ ListFunc: func(opts v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&opts) } return client.SamplecontrollerV1alpha1().Foos(namespace).List(context.Background(), opts) }, WatchFunc: func(opts v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&opts) } return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(context.Background(), opts) }, ListWithContextFunc: func(ctx context.Context, opts v1.ListOptions) (runtime.Object, error) { if tweakListOptions != nil { tweakListOptions(&opts) } return client.SamplecontrollerV1alpha1().Foos(namespace).List(ctx, opts) }, WatchFuncWithContext: func(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) { if tweakListOptions != nil { tweakListOptions(&opts) } return client.SamplecontrollerV1alpha1().Foos(namespace).Watch(ctx, opts) }, }, client), &apissamplecontrollerv1alpha1.Foo{}, cache.SharedIndexInformerOptions{ ResyncPeriod: options.ResyncPeriod, Indexers: options.Indexers, Identifier: identifier, }, )) } func (f *fooInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { return NewTypedFooInformerWithOptions(client, f.namespace, internalinterfaces.InformerOptions{ResyncPeriod: resyncPeriod, Indexers: cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, InformerName: f.factory.InformerName(), TweakListOptions: f.tweakListOptions}) } func (f *fooInformer) Informer() cache.SharedIndexInformer { return f.TypedInformer() } func (f *fooInformer) TypedInformer() FooIndexInformer { return cache.NewTypedSharedIndexInformer[*apissamplecontrollerv1alpha1.Foo](f.factory.InformerFor(&apissamplecontrollerv1alpha1.Foo{}, f.defaultInformer)) } func (f *fooInformer) Lister() samplecontrollerv1alpha1.FooLister { return samplecontrollerv1alpha1.NewFooLister(f.Informer().GetIndexer()) } // ToTypedFooInformer converts an untyped informer into a TypedFooInformer. // // WARNING: this conversion is only safe if the informer handles objects of type // *Foo. If that is not the case, calling type-safe methods of the returned // TypedFooInformer leads to runtime panics. A safer alternative is to pass // around a TypedFooInformer instances that was obtained from a // SharedInformerFactory. func ToTypedFooInformer(informer FooInformer) TypedFooInformer { if informer, ok := informer.(TypedFooInformer); ok { return informer } return &fooTypedInformerAdapter{informer} } type fooTypedInformerAdapter struct { FooInformer } func (a *fooTypedInformerAdapter) TypedInformer() FooIndexInformer { return cache.NewTypedSharedIndexInformer[*apissamplecontrollerv1alpha1.Foo](a.Informer()) } // ToFooIndexInformer converts an untyped informer into a FooIndexInformer. // // WARNING: this conversion is only safe if the informer handles objects of type // *Foo. If that is not the case, calling type-safe methods of the returned // FooIndexInformer leads to runtime panics. A safer alternative is to pass // around a FooIndexInformer instances that was obtained from a // SharedInformerFactory. func ToFooIndexInformer(informer cache.SharedIndexInformer) FooIndexInformer { if informer, ok := informer.(FooIndexInformer); ok { return informer } return cache.NewTypedSharedIndexInformer[*apissamplecontrollerv1alpha1.Foo](informer) }