Documentation
¶
Index ¶
- Constants
- Variables
- type CompositeCache
- func (cc *CompositeCache) Get(ctx context.Context, key client.ObjectKey, obj client.Object, ...) error
- func (cc *CompositeCache) GetDefaultCache() cache.Cache
- func (cc *CompositeCache) GetInformer(ctx context.Context, obj client.Object, opts ...cache.InformerGetOption) (cache.Informer, error)
- func (cc *CompositeCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind, ...) (cache.Informer, error)
- func (cc *CompositeCache) GetLogger() logr.Logger
- func (cc *CompositeCache) GetViewCache() *ViewCache
- func (cc *CompositeCache) IndexField(ctx context.Context, obj client.Object, field string, ...) error
- func (cc *CompositeCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (cc *CompositeCache) RemoveInformer(ctx context.Context, obj client.Object) error
- func (cc *CompositeCache) Start(ctx context.Context) error
- func (cc *CompositeCache) WaitForCacheSync(ctx context.Context) bool
- type Delta
- type DeltaType
- type FakeInformer
- func (f *FakeInformer) Add(obj metav1.Object)
- func (f *FakeInformer) AddEventHandler(handler toolscache.ResourceEventHandler) (toolscache.ResourceEventHandlerRegistration, error)
- func (f *FakeInformer) AddEventHandlerWithResyncPeriod(handler toolscache.ResourceEventHandler, _ time.Duration) (toolscache.ResourceEventHandlerRegistration, error)
- func (f *FakeInformer) AddIndexers(indexers toolscache.Indexers) error
- func (f *FakeInformer) Delete(obj metav1.Object)
- func (f *FakeInformer) GetController() toolscache.Controller
- func (f *FakeInformer) GetIndexer() toolscache.Indexer
- func (f *FakeInformer) GetStore() toolscache.Store
- func (f *FakeInformer) HasSynced() bool
- func (f *FakeInformer) Informer() toolscache.SharedIndexInformer
- func (f *FakeInformer) IsStopped() bool
- func (f *FakeInformer) LastSyncResourceVersion() string
- func (f *FakeInformer) RemoveEventHandler(handle toolscache.ResourceEventHandlerRegistration) error
- func (f *FakeInformer) Run(<-chan struct{})
- func (f *FakeInformer) SetTransform(t toolscache.TransformFunc) error
- func (f *FakeInformer) SetWatchErrorHandler(toolscache.WatchErrorHandler) error
- func (f *FakeInformer) Update(oldObj, newObj metav1.Object)
- type FakeRuntimeCache
- func (c *FakeRuntimeCache) Add(obj any) error
- func (c *FakeRuntimeCache) Delete(obj any) error
- func (c *FakeRuntimeCache) Get(ctx context.Context, key client.ObjectKey, obj client.Object, ...) error
- func (c *FakeRuntimeCache) GetInformer(ctx context.Context, obj client.Object, opts ...cache.InformerGetOption) (cache.Informer, error)
- func (c *FakeRuntimeCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind, ...) (cache.Informer, error)
- func (c *FakeRuntimeCache) IndexField(ctx context.Context, obj client.Object, field string, ...) error
- func (c *FakeRuntimeCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (c *FakeRuntimeCache) RemoveInformer(ctx context.Context, obj client.Object) error
- func (c *FakeRuntimeCache) Start(ctx context.Context) error
- func (c *FakeRuntimeCache) Update(oldObj, newObj any) error
- func (c *FakeRuntimeCache) WaitForCacheSync(ctx context.Context) bool
- type Lister
- type Options
- type Store
- func (s *Store) Add(obj object.Object) error
- func (s *Store) Delete(obj object.Object) error
- func (s *Store) Get(obj object.Object) (object.Object, bool, error)
- func (s *Store) GetByKey(key string) (object.Object, bool, error)
- func (s *Store) List() []object.Object
- func (s *Store) ListKeys() []string
- func (s *Store) Replace(objs []object.Object, arg string) error
- func (s *Store) Resync() error
- func (s *Store) Update(obj object.Object) error
- type ViewCache
- func (c *ViewCache) Add(obj object.Object) error
- func (c *ViewCache) Delete(obj object.Object) error
- func (c *ViewCache) Dump(ctx context.Context, gvk schema.GroupVersionKind) []string
- func (c *ViewCache) Get(ctx context.Context, key client.ObjectKey, obj client.Object, ...) error
- func (c *ViewCache) GetCacheForKind(gvk schema.GroupVersionKind) (toolscache.Indexer, error)
- func (c *ViewCache) GetInformer(ctx context.Context, obj client.Object, opts ...cache.InformerGetOption) (cache.Informer, error)
- func (c *ViewCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind, _ ...cache.InformerGetOption) (cache.Informer, error)
- func (c *ViewCache) IndexField(ctx context.Context, obj client.Object, field string, ...) error
- func (c *ViewCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (c *ViewCache) RegisterCacheForKind(gvk schema.GroupVersionKind) error
- func (c *ViewCache) RegisterInformerForKind(gvk schema.GroupVersionKind) error
- func (c *ViewCache) RemoveInformer(ctx context.Context, obj client.Object) error
- func (c *ViewCache) Start(ctx context.Context) error
- func (c *ViewCache) Update(oldObj, newObj object.Object) error
- func (c *ViewCache) WaitForCacheSync(_ context.Context) bool
- func (c *ViewCache) Watch(ctx context.Context, list client.ObjectList, opts ...client.ListOption) (watch.Interface, error)
- type ViewCacheInformer
- func (c *ViewCacheInformer) AddEventHandler(handler toolscache.ResourceEventHandler) (toolscache.ResourceEventHandlerRegistration, error)
- func (c *ViewCacheInformer) AddEventHandlerWithResyncPeriod(handler toolscache.ResourceEventHandler, resyncPeriod time.Duration) (toolscache.ResourceEventHandlerRegistration, error)
- func (c *ViewCacheInformer) AddIndexers(indexers toolscache.Indexers) error
- func (c *ViewCacheInformer) GetController() toolscache.Controller
- func (c *ViewCacheInformer) GetIndexer() toolscache.Indexer
- func (c *ViewCacheInformer) GetStore() toolscache.Store
- func (c *ViewCacheInformer) HasSynced() bool
- func (c *ViewCacheInformer) IsStopped() bool
- func (c *ViewCacheInformer) LastSyncResourceVersion() string
- func (c *ViewCacheInformer) RemoveEventHandler(registration toolscache.ResourceEventHandlerRegistration) error
- func (c *ViewCacheInformer) Run(stopCh <-chan struct{})
- func (c *ViewCacheInformer) SetTransform(transform toolscache.TransformFunc) error
- func (c *ViewCacheInformer) SetWatchErrorHandler(handler toolscache.WatchErrorHandler) error
- func (c *ViewCacheInformer) TriggerEvent(eventType toolscache.DeltaType, oldObj, newObj object.Object, ...)
- type ViewCacheWatcher
Constants ¶
const ( Added = DeltaType(toolscache.Added) Deleted = DeltaType(toolscache.Deleted) Updated = DeltaType(toolscache.Updated) Replaced = DeltaType(toolscache.Replaced) Sync = DeltaType(toolscache.Sync) Upserted = DeltaType("Upserted") // for events that are either an update/replace or an add )
const DefaultWatchChannelBuffer = 256
Variables ¶
var NilDelta = Delta{Object: nil}
NilDelta is a placeholder for a delta that means no change.
Functions ¶
This section is empty.
Types ¶
type CompositeCache ¶
type CompositeCache struct {
// contains filtered or unexported fields
}
func NewCompositeCache ¶
func NewCompositeCache(config *rest.Config, opts Options) (*CompositeCache, error)
func (*CompositeCache) GetDefaultCache ¶
func (cc *CompositeCache) GetDefaultCache() cache.Cache
func (*CompositeCache) GetInformer ¶
func (cc *CompositeCache) GetInformer(ctx context.Context, obj client.Object, opts ...cache.InformerGetOption) (cache.Informer, error)
func (*CompositeCache) GetInformerForKind ¶
func (cc *CompositeCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind, opts ...cache.InformerGetOption) (cache.Informer, error)
func (*CompositeCache) GetLogger ¶
func (cc *CompositeCache) GetLogger() logr.Logger
func (*CompositeCache) GetViewCache ¶
func (cc *CompositeCache) GetViewCache() *ViewCache
func (*CompositeCache) IndexField ¶
func (cc *CompositeCache) IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error
func (*CompositeCache) List ¶
func (cc *CompositeCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
func (*CompositeCache) RemoveInformer ¶
func (*CompositeCache) WaitForCacheSync ¶
func (cc *CompositeCache) WaitForCacheSync(ctx context.Context) bool
type Delta ¶
Delta registers a change (addition, deletion, etc) on an object. By convention, Object is nil if no change occurs.
func (Delta) IsUnchanged ¶
type FakeInformer ¶
type FakeInformer struct { // Synced is returned by the HasSynced functions to implement the Informer interface Synced bool // RunCount is incremented each time RunInformersAndControllers is called RunCount int Indexer Lister // contains filtered or unexported fields }
FakeInformer provides fake Informer functionality for testing.
func (*FakeInformer) Add ¶
func (f *FakeInformer) Add(obj metav1.Object)
Add fakes an Add event for obj.
func (*FakeInformer) AddEventHandler ¶
func (f *FakeInformer) AddEventHandler(handler toolscache.ResourceEventHandler) (toolscache.ResourceEventHandlerRegistration, error)
AddEventHandler implements the Informer interface. Adds an EventHandler to the fake Informers. TODO(community): Implement Registration.
func (*FakeInformer) AddEventHandlerWithResyncPeriod ¶
func (f *FakeInformer) AddEventHandlerWithResyncPeriod(handler toolscache.ResourceEventHandler, _ time.Duration) (toolscache.ResourceEventHandlerRegistration, error)
AddEventHandlerWithResyncPeriod does nothing. TODO(community): Implement this.
func (*FakeInformer) AddIndexers ¶
func (f *FakeInformer) AddIndexers(indexers toolscache.Indexers) error
AddIndexers does nothing. TODO(community): Implement this.
func (*FakeInformer) Delete ¶
func (f *FakeInformer) Delete(obj metav1.Object)
Delete fakes an Delete event for obj.
func (*FakeInformer) GetController ¶
func (f *FakeInformer) GetController() toolscache.Controller
GetController does nothing. TODO(community): Implement this.
func (*FakeInformer) GetIndexer ¶
func (f *FakeInformer) GetIndexer() toolscache.Indexer
GetIndexer does nothing. TODO(community): Implement this.
func (*FakeInformer) GetStore ¶
func (f *FakeInformer) GetStore() toolscache.Store
GetStore does nothing. TODO(community): Implement this.
func (*FakeInformer) HasSynced ¶
func (f *FakeInformer) HasSynced() bool
HasSynced implements the Informer interface. Returns f.Synced.
func (*FakeInformer) Informer ¶
func (f *FakeInformer) Informer() toolscache.SharedIndexInformer
Informer returns the fake Informer.
func (*FakeInformer) IsStopped ¶
func (f *FakeInformer) IsStopped() bool
IsStopped does nothing. TODO(community): Implement this.
func (*FakeInformer) LastSyncResourceVersion ¶
func (f *FakeInformer) LastSyncResourceVersion() string
LastSyncResourceVersion does nothing. TODO(community): Implement this.
func (*FakeInformer) RemoveEventHandler ¶
func (f *FakeInformer) RemoveEventHandler(handle toolscache.ResourceEventHandlerRegistration) error
RemoveEventHandler does nothing. TODO(community): Implement this.
func (*FakeInformer) Run ¶
func (f *FakeInformer) Run(<-chan struct{})
Run implements the Informer interface. Increments f.RunCount.
func (*FakeInformer) SetTransform ¶
func (f *FakeInformer) SetTransform(t toolscache.TransformFunc) error
SetTransform does nothing. TODO(community): Implement this.
func (*FakeInformer) SetWatchErrorHandler ¶
func (f *FakeInformer) SetWatchErrorHandler(toolscache.WatchErrorHandler) error
SetWatchErrorHandler does nothing. TODO(community): Implement this.
func (*FakeInformer) Update ¶
func (f *FakeInformer) Update(oldObj, newObj metav1.Object)
Update fakes an Update event for obj.
type FakeRuntimeCache ¶
type FakeRuntimeCache struct { InformersByGVK map[schema.GroupVersionKind]toolscache.SharedIndexInformer Error error Synced *bool Store *Store }
FakeRuntimeCache is a fake implementation of Informers. Client can store only a single object. Source: sigs.k8s.io/controller-runtime/pkg/cache/informertest/fake_cache.go.
func NewFakeRuntimeCache ¶
func NewFakeRuntimeCache(s *runtime.Scheme) *FakeRuntimeCache
func (*FakeRuntimeCache) Add ¶
func (c *FakeRuntimeCache) Add(obj any) error
func (*FakeRuntimeCache) Delete ¶
func (c *FakeRuntimeCache) Delete(obj any) error
func (*FakeRuntimeCache) GetInformer ¶
func (c *FakeRuntimeCache) GetInformer(ctx context.Context, obj client.Object, opts ...cache.InformerGetOption) (cache.Informer, error)
GetInformer implements Informers.
func (*FakeRuntimeCache) GetInformerForKind ¶
func (c *FakeRuntimeCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind, opts ...cache.InformerGetOption) (cache.Informer, error)
GetInformerForKind implements Informers.
func (*FakeRuntimeCache) IndexField ¶
func (c *FakeRuntimeCache) IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error
IndexField implements Cache.
func (*FakeRuntimeCache) List ¶
func (c *FakeRuntimeCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
func (*FakeRuntimeCache) RemoveInformer ¶
RemoveInformer implements Informers.
func (*FakeRuntimeCache) Start ¶
func (c *FakeRuntimeCache) Start(ctx context.Context) error
Start implements Informers.
func (*FakeRuntimeCache) Update ¶
func (c *FakeRuntimeCache) Update(oldObj, newObj any) error
func (*FakeRuntimeCache) WaitForCacheSync ¶
func (c *FakeRuntimeCache) WaitForCacheSync(ctx context.Context) bool
WaitForCacheSync implements Informers.
type Options ¶
type Options struct { cache.Options // DefaultCache is the controller-runtime cache used for anything that is not a view. DefaultCache cache.Cache // Logger is for logging. Currently only the viewcache generates log messages. Logger logr.Logger }
Options are generic caching options
type Store ¶
type Store struct {
Store toolscache.Store
}
Store is like toolscache.Store but it also deep-copies objects
func (*Store) Add ¶
Add adds the given object to the database associated with the given object's key
func (*Store) Delete ¶
Delete deletes the given object from the database associated with the given object's key
func (*Store) ListKeys ¶
ListKeys returns a list of all the keys currently associated with non-empty databases
func (*Store) Replace ¶
Replace will delete the contents of the store, using instead the given list. Store takes ownership of the list, you should not reference it after calling this function.
type ViewCache ¶
type ViewCache struct {
// contains filtered or unexported fields
}
func NewViewCache ¶
func (*ViewCache) GetCacheForKind ¶
func (c *ViewCache) GetCacheForKind(gvk schema.GroupVersionKind) (toolscache.Indexer, error)
func (*ViewCache) GetInformer ¶
func (*ViewCache) GetInformerForKind ¶
func (c *ViewCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind, _ ...cache.InformerGetOption) (cache.Informer, error)
func (*ViewCache) IndexField ¶
func (*ViewCache) List ¶
func (c *ViewCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
func (*ViewCache) RegisterCacheForKind ¶
func (c *ViewCache) RegisterCacheForKind(gvk schema.GroupVersionKind) error
func (*ViewCache) RegisterInformerForKind ¶
func (c *ViewCache) RegisterInformerForKind(gvk schema.GroupVersionKind) error
func (*ViewCache) RemoveInformer ¶
func (*ViewCache) Start ¶
Start runs all the informers known to this cache until the context is closed. It blocks.
type ViewCacheInformer ¶
type ViewCacheInformer struct {
// contains filtered or unexported fields
}
func NewViewCacheInformer ¶
func NewViewCacheInformer(gvk schema.GroupVersionKind, indexer toolscache.Indexer, logger logr.Logger) *ViewCacheInformer
func (*ViewCacheInformer) AddEventHandler ¶
func (c *ViewCacheInformer) AddEventHandler(handler toolscache.ResourceEventHandler) (toolscache.ResourceEventHandlerRegistration, error)
func (*ViewCacheInformer) AddEventHandlerWithResyncPeriod ¶
func (c *ViewCacheInformer) AddEventHandlerWithResyncPeriod(handler toolscache.ResourceEventHandler, resyncPeriod time.Duration) (toolscache.ResourceEventHandlerRegistration, error)
func (*ViewCacheInformer) AddIndexers ¶
func (c *ViewCacheInformer) AddIndexers(indexers toolscache.Indexers) error
func (*ViewCacheInformer) GetController ¶
func (c *ViewCacheInformer) GetController() toolscache.Controller
func (*ViewCacheInformer) GetIndexer ¶
func (c *ViewCacheInformer) GetIndexer() toolscache.Indexer
func (*ViewCacheInformer) GetStore ¶
func (c *ViewCacheInformer) GetStore() toolscache.Store
func (*ViewCacheInformer) HasSynced ¶
func (c *ViewCacheInformer) HasSynced() bool
func (*ViewCacheInformer) IsStopped ¶
func (c *ViewCacheInformer) IsStopped() bool
func (*ViewCacheInformer) LastSyncResourceVersion ¶
func (c *ViewCacheInformer) LastSyncResourceVersion() string
func (*ViewCacheInformer) RemoveEventHandler ¶
func (c *ViewCacheInformer) RemoveEventHandler(registration toolscache.ResourceEventHandlerRegistration) error
func (*ViewCacheInformer) Run ¶
func (c *ViewCacheInformer) Run(stopCh <-chan struct{})
func (*ViewCacheInformer) SetTransform ¶
func (c *ViewCacheInformer) SetTransform(transform toolscache.TransformFunc) error
func (*ViewCacheInformer) SetWatchErrorHandler ¶
func (c *ViewCacheInformer) SetWatchErrorHandler(handler toolscache.WatchErrorHandler) error
func (*ViewCacheInformer) TriggerEvent ¶
func (c *ViewCacheInformer) TriggerEvent(eventType toolscache.DeltaType, oldObj, newObj object.Object, isInitialList bool)
TriggerEvent will send an event on newObj of eventType to all registered handlers. Set isInitialList to true if event is an Added as a part of the initial object list. For all event types except Update events the oldObj must not be nil.
type ViewCacheWatcher ¶
type ViewCacheWatcher struct {
// contains filtered or unexported fields
}
func (*ViewCacheWatcher) ResultChan ¶
func (w *ViewCacheWatcher) ResultChan() <-chan watch.Event
func (*ViewCacheWatcher) Stop ¶
func (w *ViewCacheWatcher) Stop()