collections

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package collections implements collection utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveMiners

func ActiveMiners(miner *v1beta1.Miner) bool

ActiveMiners returns a filter to find all active miners. Usage: GetFilteredMinersForCluster(ctx, client, cluster, ActiveMiners).

func HasControllerRef

func HasControllerRef(miner *v1beta1.Miner) bool

HasControllerRef is a filter that returns true if the miner has a controller ref.

func HasDeletionTimestamp

func HasDeletionTimestamp(miner *v1beta1.Miner) bool

HasDeletionTimestamp returns a filter to find all miners that have a deletion timestamp.

func HasUnhealthyCondition

func HasUnhealthyCondition(miner *v1beta1.Miner) bool

HasUnhealthyCondition returns a filter to find all miners that have a MinerHealthCheckSucceeded condition set to False, indicating a problem was detected on the miner, and the MinerOwnerRemediated condition set, indicating that KCP is responsible of performing remediation as owner of the miner.

func OwnedMiners

func OwnedMiners(owner client.Object) func(miner *v1beta1.Miner) bool

OwnedMiners returns a filter to find all miners owned by specified owner. Usage: GetFilteredMinersForCluster(ctx, client, cluster, OwnedMiners(controlPlane)).

func ToMinerList

func ToMinerList(miners Miners) v1beta1.MinerList

ToMinerList creates a MinerList from the given Miners.

Types

type Func

type Func func(miner *v1beta1.Miner) bool

Func is the functon definition for a filter.

func And

func And(filters ...Func) Func

And returns a filter that returns true if all of the given filters returns true.

func HasAnnotationKey

func HasAnnotationKey(key string) Func

HasAnnotationKey returns a filter to find all miners that have the specified Annotation key present.

func IsReady

func IsReady() Func

IsReady returns a filter to find all miners with the ReadyCondition equals to True.

func Not

func Not(mf Func) Func

Not returns a filter that returns the opposite of the given filter.

func Or

func Or(filters ...Func) Func

Or returns a filter that returns true if any of the given filters returns true.

func ShouldRolloutAfter

func ShouldRolloutAfter(reconciliationTime, rolloutAfter *metav1.Time) Func

ShouldRolloutAfter returns a filter to find all miners where CreationTimestamp < rolloutAfter < reconciliationTIme.

func WithVersion

func WithVersion() Func

WithVersion returns a filter to find miner that have a non empty and valid version.

type Miners

type Miners map[string]*v1beta1.Miner

Miners is a set of Miners.

func FromMinerList

func FromMinerList(minerList *v1beta1.MinerList) Miners

FromMinerList creates a Miners from the given MinerList.

func FromMiners

func FromMiners(miners ...*v1beta1.Miner) Miners

FromMiners creates a Miners from a list of values.

func GetFilteredMinersForMinerSet

func GetFilteredMinersForMinerSet(ctx context.Context, c client.Reader, ms *v1beta1.MinerSet, filters ...Func) (Miners, error)

GetFilteredMinersForMinerSet returns a list of miners that can be filtered or not. If no filter is supplied then all miners associated with the target minerset are returned.

func New

func New() Miners

New creates an empty Miners.

func (Miners) AnyFilter

func (s Miners) AnyFilter(filters ...Func) Miners

AnyFilter returns a Miners containing only the Miners that match any of the given MinerFilters.

func (Miners) ConditionGetters

func (s Miners) ConditionGetters() []conditions.Getter

ConditionGetters returns the slice with miners converted into conditions.Getter.

func (Miners) DeepCopy

func (s Miners) DeepCopy() Miners

DeepCopy returns a deep copy.

func (Miners) Difference

func (s Miners) Difference(miners Miners) Miners

Difference returns a copy without miners that are in the given collection.

func (Miners) Filter

func (s Miners) Filter(filters ...Func) Miners

Filter returns a Miners containing only the Miners that match all of the given MinerFilters.

func (Miners) Insert

func (s Miners) Insert(miners ...*v1beta1.Miner)

Insert adds items to the set.

func (Miners) Len

func (s Miners) Len() int

Len returns the size of the set.

func (Miners) LowestVersion

func (s Miners) LowestVersion() *string

LowestVersion returns the lowest version among all the miner with defined versions. If no miner has a defined version it returns an empty string.

func (Miners) Names

func (s Miners) Names() []string

Names returns a slice of the names of each miner in the collection. Useful for logging and test assertions.

func (Miners) Newest

func (s Miners) Newest() *v1beta1.Miner

Newest returns the Miner with the most recent CreationTimestamp.

func (Miners) Oldest

func (s Miners) Oldest() *v1beta1.Miner

Oldest returns the Miner with the oldest CreationTimestamp.

func (Miners) SortedByCreationTimestamp

func (s Miners) SortedByCreationTimestamp() []*v1beta1.Miner

SortedByCreationTimestamp returns the miners sorted by creation timestamp.

func (Miners) UnsortedList

func (s Miners) UnsortedList() []*v1beta1.Miner

UnsortedList returns the slice with contents in random order.

Jump to

Keyboard shortcuts

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