package generic
import "k8s.io/apiserver/pkg/admission/plugin/validatingadmissionpolicy/internal/generic"
Package generic contains a typed wrapper over cache SharedIndexInformer and Lister (maybe eventually should have a home there?)
This interface is being experimented with as an easier way to write controllers with a bit less boilerplate.
Informer/Lister classes are thin wrappers providing a type-safe interface over regular interface{}-based Informers/Listers
Controller[T] provides a reusable way to reconcile objects out of an informer using the tried and true controller design pattern found all over k8s codebase based upon syncFunc/reconcile
Index ¶
- func NewLister[T runtime.Object](indexer cache.Indexer) lister[T]
- type Controller
- type ControllerOptions
- type Informer
- type Lister
- type NamespacedLister
Functions ¶
func NewLister ¶
Types ¶
type Controller ¶
type Controller[T runtime.Object] interface { // Meant to be run inside a goroutine // Waits for and reacts to changes in whatever type the controller // is concerned with. // // Returns an error always non-nil explaining why the worker stopped Run(ctx context.Context) error // Retrieves the informer used to back this controller Informer() Informer[T] // Returns true if the informer cache has synced, and all the objects from // the initial list have been reconciled at least once. HasSynced() bool }
func NewController ¶
func NewController[T runtime.Object]( informer Informer[T], reconciler func(namepace, name string, newObj T) error, options ControllerOptions, ) Controller[T]
type ControllerOptions ¶
type Informer ¶
type Informer[T any] interface { cache.SharedIndexInformer Lister[T] }
func NewInformer ¶
func NewInformer[T runtime.Object](informe cache.SharedIndexInformer) Informer[T]
type Lister ¶
type Lister[T any] interface { NamespacedLister[T] Namespaced(namespace string) NamespacedLister[T] }
Lister[T] helps list Ts. All objects returned here must be treated as read-only.
type NamespacedLister ¶
type NamespacedLister[T any] interface { // List lists all ValidationRuleSets in the indexer for a given namespace. // Objects returned here must be treated as read-only. List(selector labels.Selector) (ret []T, err error) // Get retrieves the ValidationRuleSet from the indexer for a given namespace and name. // Objects returned here must be treated as read-only. Get(name string) (T, error) }
Source Files ¶
controller.go doc.go informer.go interface.go lister.go
- Version
- v0.27.7
- Published
- Oct 21, 2023
- Platform
- js/wasm
- Imports
- 18 packages
- Last checked
- 2 minutes ago –
Tools for package owners.