cache

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2024 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewKubeClientFromGlobalInformer

func NewKubeClientFromGlobalInformer(gi GlobalInformer, clusterID ClusterID) (client kube.Client, err error)

func WithNonTerminatedPods

func WithNonTerminatedPods[T runtime.Object](config *ListConfig[T])

Types

type Cluster

type Cluster interface {
	ID() ClusterID
	KubeClient() kube.Client
}

type ClusterID

type ClusterID string

func (ClusterID) String

func (cid ClusterID) String() string

type ClusterResourceEventHandler

type ClusterResourceEventHandler interface {
	OnAdd(cluster Cluster, obj any)
	OnUpdate(cluster Cluster, oldObj, newObj any)
	OnDelete(cluster Cluster, obj any)
}

type ClusterWatchErrorHandler

type ClusterWatchErrorHandler func(cluster Cluster, r *cache.Reflector, err error)

type FilterFunction

type FilterFunction[T runtime.Object] func(obj T) bool

type GlobalInformer

type GlobalInformer interface {
	// cluster cares
	GetCluster(id ClusterID) Cluster
	ListClusters() (clusters []Cluster)
	AddCluster(clusterID ClusterID, client kube.Client, defaultResync time.Duration, tweakListOptions dynamicinformer.TweakListOptionsFunc, watchUnits []ResourceUnitWithHandlers)
	RemoveCluster(clusterID ClusterID)
	HasSynced(clusterID ClusterID, resource schema.GroupVersionResource) bool
	ClusterHasSynced(clusterID ClusterID) bool
	ClusterSyncMap(clusterID ClusterID) map[ResourceUnit]bool
	AllSynced() bool
}

func NewGlobalInformer

func NewGlobalInformer(scheme *runtime.Scheme) GlobalInformer

type KubeClient

type KubeClient struct {
	*kube.ClientImpl
	// contains filtered or unexported fields
}

type ListConfig

type ListConfig[T runtime.Object] struct {
	// contains filtered or unexported fields
}

type ListOption

type ListOption[T runtime.Object] func(config *ListConfig[T])

func FromMetaListOptions

func FromMetaListOptions[T runtime.Object](opts metav1.ListOptions) (res []ListOption[T])

func InNamespaces

func InNamespaces[T runtime.Object](namespaces ...string) ListOption[T]

func WithCustomFilter

func WithCustomFilter[T runtime.Object](fn FilterFunction[T]) ListOption[T]

func WithCustomPreFilter

func WithCustomPreFilter[T runtime.Object](fn PreFilterFunction) ListOption[T]

func WithLabelSelector

func WithLabelSelector[T runtime.Object](selector labels.Selector) ListOption[T]

func WithLabelSelectorStr

func WithLabelSelectorStr[T runtime.Object](selector string) (opt ListOption[T], err error)

func WithLabelsMap

func WithLabelsMap[T runtime.Object](m map[string]string) ListOption[T]

func WithMetaLabelSelector

func WithMetaLabelSelector[T runtime.Object](selector *metav1.LabelSelector) (opt ListOption[T], err error)

func WithNames

func WithNames[T runtime.Object](names ...string) ListOption[T]

func WithOwnerReference

func WithOwnerReference[T runtime.Object](gvk schema.GroupVersionKind, name string) ListOption[T]

func WithPagination

func WithPagination[T runtime.Object](less func(a, b *unstructured.Unstructured) bool, offset, limit int, totalCount *int) ListOption[T]

type PreFilterFunction

type PreFilterFunction func(obj *unstructured.Unstructured) bool

type ResourceBuilder

type ResourceBuilder[T runtime.Object] interface {
	// resource type
	ForResource(gvr schema.GroupVersionResource) ResourceBuilder[T]
	ForKind(gvk schema.GroupVersionKind) ResourceBuilder[T]

	// include clusters
	Clusters(clusters ...ClusterID) ResourceBuilder[T]
	AllClusters() ResourceBuilder[T]

	// lister
	List(opts ...ListOption[T]) (list []T, err error)
	Get(namespace, name string) (obj T, err error)
}

func NewResourceBuilder

func NewResourceBuilder[T runtime.Object](gi GlobalInformer) ResourceBuilder[T]

type ResourceUnit

type ResourceUnit struct {
	Namespace string // leave empty to watch all namespaces
	Resource  schema.GroupVersionResource
}

type ResourceUnitWithHandlers

type ResourceUnitWithHandlers struct {
	ResourceUnit

	ResourceEventHandlers []ClusterResourceEventHandler
	WatchErrorHandlers    []ClusterWatchErrorHandler
}

func BuildResourceUnitWithHandlersSlice

func BuildResourceUnitWithHandlersSlice(units []ResourceUnit) (res []ResourceUnitWithHandlers)

Jump to

Keyboard shortcuts

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