discovery

package
v2.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Overview

Package discovery provides a discovery and resolution logic for GVKs.

Index

Constants

View Source
const Interval = 3 * time.Second

Interval is the time interval between two cache sync checks.

Variables

This section is empty.

Functions

This section is empty.

Types

type CRDiscoverer

type CRDiscoverer struct {

	// Map is a cache of the collected GVKs.
	Map map[string]map[string][]kindPlural
	// ShouldUpdate is a flag that indicates whether the cache was updated.
	WasUpdated bool
	// CRDsAddEventsCounter tracks the number of times that the CRD informer triggered the "add" event.
	CRDsAddEventsCounter prometheus.Counter
	// CRDsDeleteEventsCounter tracks the number of times that the CRD informer triggered the "remove" event.
	CRDsDeleteEventsCounter prometheus.Counter
	// CRDsCacheCountGauge tracks the net amount of CRDs affecting the cache at this point.
	CRDsCacheCountGauge prometheus.Gauge
	// contains filtered or unexported fields
}

CRDiscoverer provides a cache of the collected GVKs, along with helper utilities.

func (*CRDiscoverer) AppendToMap

func (r *CRDiscoverer) AppendToMap(gvkps ...groupVersionKindPlural)

AppendToMap appends the given GVKs to the cache.

func (*CRDiscoverer) PollForCacheUpdates

func (r *CRDiscoverer) PollForCacheUpdates(
	ctx context.Context,
	opts *options.Options,
	storeBuilder *store.Builder,
	m *metricshandler.MetricsHandler,
	factoryGenerator func() ([]customresource.RegistryFactory, error),
)

PollForCacheUpdates polls the cache for updates and updates the stores accordingly.

func (*CRDiscoverer) RemoveFromMap

func (r *CRDiscoverer) RemoveFromMap(gvkps ...groupVersionKindPlural)

RemoveFromMap removes the given GVKs from the cache.

func (*CRDiscoverer) ResolveGVKToGVKPs

func (r *CRDiscoverer) ResolveGVKToGVKPs(gvk schema.GroupVersionKind) (resolvedGVKPs []groupVersionKindPlural, err error)

ResolveGVKToGVKPs resolves the variable VKs to a GVK list, based on the current cache.

func (*CRDiscoverer) SafeRead

func (r *CRDiscoverer) SafeRead(f func())

SafeRead executes the given function while holding a read lock.

func (*CRDiscoverer) SafeWrite

func (r *CRDiscoverer) SafeWrite(f func())

SafeWrite executes the given function while holding a write lock.

func (*CRDiscoverer) StartDiscovery

func (r *CRDiscoverer) StartDiscovery(ctx context.Context, config *rest.Config) error

StartDiscovery starts the discovery process, fetching all the objects that can be listed from the apiserver, every `Interval` seconds. resolveGVK needs to be called after StartDiscovery to generate factories.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL