Documentation ¶
Index ¶
- func ScopedCacheBuilder(scOpts ...ScopedCacheOption) crcache.NewCacheFunc
- type ScopeInformerFactory
- type ScopedCache
- func (sc *ScopedCache) AddInformer(infOpts components.InformerOptions)
- func (sc *ScopedCache) Get(ctx context.Context, key client.ObjectKey, obj client.Object) error
- func (sc *ScopedCache) GetInformer(ctx context.Context, obj client.Object) (crcache.Informer, error)
- func (sc *ScopedCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind) (crcache.Informer, error)
- func (sc *ScopedCache) HasInformer(infOpts components.InformerOptions) bool
- func (sc *ScopedCache) IndexField(ctx context.Context, obj client.Object, field string, ...) error
- func (sc *ScopedCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
- func (sc *ScopedCache) PrintCache()
- func (sc *ScopedCache) RemoveInformer(infOpts components.InformerOptions, force bool)
- func (sc *ScopedCache) Start(ctx context.Context) error
- func (sc *ScopedCache) WaitForCacheSync(ctx context.Context) bool
- type ScopedCacheOption
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ScopedCacheBuilder ¶
func ScopedCacheBuilder(scOpts ...ScopedCacheOption) crcache.NewCacheFunc
ScopeCacheBuilder is a builder function that can be used to return a controller-runtime cache.NewCacheFunc. This function enables controller-runtime to properly create a new ScopedCache
Types ¶
type ScopeInformerFactory ¶
type ScopeInformerFactory func(gvr schema.GroupVersionResource, options ...informers.SharedInformerOption) (informers.GenericInformer, error)
ScopeInformerFactory is a function that is used to create a informers.GenericInformer for the provided GVR and SharedInformerOptions.
type ScopedCache ¶
type ScopedCache struct { // RESTMapper is used when determining // if an API is namespaced or not RESTMapper apimeta.RESTMapper // Scheme is used when determining // if an API is namespaced or not Scheme *runtime.Scheme // contains filtered or unexported fields }
ScopedCache is a wrapper around the NamespaceScopedCache and ClusterScopedCache that implements the controller-runtime cache.Cache interface. Wrapping both scoped caches enables this cache to dynamically handle informers that establish watches at both the cluster and namespace level
func (*ScopedCache) AddInformer ¶
func (sc *ScopedCache) AddInformer(infOpts components.InformerOptions)
AddInformer will add an informer to the appropriate cache based on the informer options provided.
func (*ScopedCache) Get ¶
Get will attempt to get the requested resource from the appropriate cache. The general flow for this function is: - Get the GVK for the provided object - Check if the proper permissions exist to perform this request - Get the requested resource from the appropriate cache, returning any errors -- If the request is not permitted: --- Any informers that meet the invalid permissions are forcefully removed from the cache --- A Forbidden error is returned TODO: Should we automatically create the informer if one is not found?
func (*ScopedCache) GetInformer ¶
func (sc *ScopedCache) GetInformer(ctx context.Context, obj client.Object) (crcache.Informer, error)
GetInformer will attempt to get an informer for the provided object and add it to the cache. The general flow for this function is: - Get the GVK - Create InformerOptions - If the provided object has a Namespace value != "": -- If an informer doesn't already exist in the namespace cache: --- Generate a new informer scoped to the namespace --- Add the informer to the cache --- Return the new ScopeInformer -- If the informer already exists in the namespace cache: --- Return the existing ScopeInformer - If the provided object has a Namespace value == "": -- If an informer doesn't already exist in the cluster cache: --- Generate a new informer scoped to the cluster --- Add the informer to the cache --- Return the new ScopeInformer -- If the informer already exists in the cluster cache: --- Return the existing ScopeInformer
func (*ScopedCache) GetInformerForKind ¶
func (sc *ScopedCache) GetInformerForKind(ctx context.Context, gvk schema.GroupVersionKind) (crcache.Informer, error)
GetInformerForKind will attempt to get an informer for the provided GVK and add it to the cache. The general flow for this function is: - Get the GVK - Create InformerOptions: - If an informer doesn't already exist in the cluster cache: -- Generate a new informer scoped to the cluster -- Add the informer to the cache -- Return the new ScopeInformer - If the informer already exists in the cluster cache: -- Return the existing ScopeInformer
func (*ScopedCache) HasInformer ¶
func (sc *ScopedCache) HasInformer(infOpts components.InformerOptions) bool
GvkHasInformer returns whether or not an informer exists in the cache for the provided InformerOptions
func (*ScopedCache) IndexField ¶
func (sc *ScopedCache) IndexField(ctx context.Context, obj client.Object, field string, extractValue client.IndexerFunc) error
IndexField will add an index field to the appropriate informers The general flow of this function is: - Get the GVK - Create an Indexer to add to the ScopeInformers - If the object has a Namespace value != "": -- Add the indexer to all informers in the namespace cache for the Namespace-GVK pair - If the object has a Namespace value == "": -- Add the indexer to all informers in the cluster cache for the GVK
func (*ScopedCache) List ¶
func (sc *ScopedCache) List(ctx context.Context, list client.ObjectList, opts ...client.ListOption) error
List will attempt to get the requested list of resources from the appropriate cache. The general flow for this function is: - Get the GVK - Check if the proper permissions exist to perform this request - Get the requested resource list from the appropriate cache, returning any errors -- If the request is not permitted: --- Any informers that meet the invalid permissions are forcefully removed from the cache --- A Forbidden error is returned
func (*ScopedCache) PrintCache ¶
func (sc *ScopedCache) PrintCache()
PrintCache is a temporary function to help show the state of the cache by printing it out.
func (*ScopedCache) RemoveInformer ¶
func (sc *ScopedCache) RemoveInformer(infOpts components.InformerOptions, force bool)
RemoveInformer will remove an informer from the appropriate cache based on the informer options provided.
func (*ScopedCache) Start ¶
func (sc *ScopedCache) Start(ctx context.Context) error
Start will start the ScopedCache. This involves starting both the ClusterScopedCache and NamespaceScopedCache and all their informers
func (*ScopedCache) WaitForCacheSync ¶
func (sc *ScopedCache) WaitForCacheSync(ctx context.Context) bool
WaitForCacheSync will block until all the caches have been synced
type ScopedCacheOption ¶
type ScopedCacheOption func(*ScopedCache)
ScopedCacheOption is a function to set values on the ScopedCache
func WithScopedInformerFactory ¶
func WithScopedInformerFactory(sif ScopeInformerFactory) ScopedCacheOption
WithScopedInformerFactory is an option that can be used to set the ScopedCache.scopedInformerFactory field when creating a new ScopedCache.