Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ResourceDelta ¶
type ResourceDelta[T client.Object] struct {
// the resources inserted into the set
Inserted ResourceSet[T]
// the resources removed from the set
Removed ResourceSet[T]
}
ResourceDelta represents the set of changes between two ResourceSets.
type ResourceSet ¶
type ResourceSet[T client.Object] interface {
// Get the set stored keys
Keys() sets.Set[string]
// Filter returns an iterator that will iterate over the set of elements
// that match the provided filter. If the filter returns true, the resource will be included in the iteration.
// The index and resource are passed to the provided function for every element in the *filtered set*.
// The index is the index of the resource in the *filtered* set.
// The iteration can be stopped by returning false from the function. This can be thought of as a "break" statement in a loop.
// Returning true will continue the iteration. This can be thought of as a "continue" statement in a loop.
// For iteration that does not need to be filtered, use Iter.
Filter(filterResource func(T) bool) func(yield func(int, T) bool)
// Iter iterates over the set, passing the index and resource to the provided function for every element in the set.
// The iteration can be stopped by returning false from the function. This can be thought of as a "break" statement in a loop.
// Returning true will continue the iteration. This can be thought of as a "continue" statement in a loop.
Iter(func(int, T) bool)
// FilterOutAndCreateList constructs a list of resource that do not match any of the provided filters.
// Use of this function should be limited to only when a filtered list is needed.
// For iteration that does not require creating a new list, use Iter.
// For iteration that requires typical filtering semantics (i.e. filters that return true for resources that should be included),
// use
FilterOutAndCreateList(filterResource ...func(T) bool) []T
// Return the Set as a map of key to resource.
Map() map[string]T
// Insert a resource into the set.
Insert(resource ...T)
// Compare the equality of the keys in two sets (not the resources themselves)
Equal(set ResourceSet[T]) bool
// Check if the set contains the resource.
Has(resource T) bool
// Delete the matching resource.
Delete(resource ezkube.ResourceId)
// Return the union with the provided set
Union(set ResourceSet[T]) ResourceSet[T]
// Return the difference with the provided set
Difference(set ResourceSet[T]) ResourceSet[T]
// Return the intersection with the provided set
Intersection(set ResourceSet[T]) ResourceSet[T]
// Find the resource with the given ID.
// Returns a NotFoundErr error if the resource is not found.
Find(resource ezkube.ResourceId) (T, error)
// Find the resource with the given ID.
// Returns nil if the resource is not found.
Get(resource ezkube.ResourceId) T
// Get the length of the set
Len() int
Length() int
// returns the generic implementation of the set
Generic() sk_sets.ResourceSet
// Clone returns a deep copy of the set
Clone() ResourceSet[T]
// ShallowCopy returns a shallow copy of the set
ShallowCopy() ResourceSet[T]
}
ResourceSet is a thread-safe container for a set of resources. It provides a set of operations for working with the set of resources, typically used for managing Kubernetes resources. The ResourceSet is a generic interface that can be used with any type that satisfies the client.Object interface.
func NewResourceSet ¶
func NewResourceSet[T client.Object](
resources ...T,
) ResourceSet[T]
Click to show internal directories.
Click to hide internal directories.