collections

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package collections implements collection utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveKKInstances

func ActiveKKInstances(kkInstance *infrav1.KKInstance) bool

ActiveKKInstances returns a filter to find all active kkinstances. Usage: GetFilteredKKInstancesForKKCluster(ctx, client, cluster, ActiveKKInstances).

func ControlPlaneKKInstances

func ControlPlaneKKInstances(clusterName string) func(kkInstance *infrav1.KKInstance) bool

ControlPlaneKKInstances returns a filter to find all control plane KKInstance for a cluster, regardless of ownership. Usage: GetFilteredKKInstancesForKKCluster(ctx, client, cluster, ControlPlaneKKInstances(cluster.Name)).

func ControlPlaneSelectorForCluster

func ControlPlaneSelectorForCluster(clusterName string) labels.Selector

ControlPlaneSelectorForCluster returns the label selector necessary to get control plane KKInstance for a given cluster.

func OwnedKKInstances

func OwnedKKInstances(owner client.Object) func(kkInstance *infrav1.KKInstance) bool

OwnedKKInstances returns a filter to find all kkInstances owned by specified owner. Usage: GetFilteredKKInstancesForKKCluster(ctx, client, cluster, OwnedKKInstances(controlPlane)).

func ToKKInstanceList

func ToKKInstanceList(kkInstances KKInstances) infrav1.KKInstanceList

ToKKInstanceList creates a KKInstanceList from the given KKInstances.

Types

type Func

type Func func(kkInstance *infrav1.KKInstance) 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 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.

type KKInstances

type KKInstances map[string]*infrav1.KKInstance

KKInstances is a set of KKInstances.

func FromKKInstanceList

func FromKKInstanceList(kkInstanceList *infrav1.KKInstanceList) KKInstances

FromKKInstanceList creates a KKInstances from the given KKInstanceList.

func FromKKInstances

func FromKKInstances(kkInstances ...*infrav1.KKInstance) KKInstances

FromKKInstances creates a KKInstance from a list of values.

func GetFilteredKKInstancesForKKCluster

func GetFilteredKKInstancesForKKCluster(ctx context.Context, c client.Reader, kkCluster *infrav1.KKCluster, filters ...Func) (KKInstances, error)

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

func New

func New() KKInstances

New creates an empty KKInstances.

func (KKInstances) AnyFilter

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

AnyFilter returns a KKInstances containing only the KKInstances that match any of the given KKInstanceFilters.

func (KKInstances) ConditionGetters

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

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

func (KKInstances) DeepCopy

func (s KKInstances) DeepCopy() KKInstances

DeepCopy returns a deep copy.

func (KKInstances) Difference

func (s KKInstances) Difference(kkInstances KKInstances) KKInstances

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

func (KKInstances) Filter

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

Filter returns a KKInstances containing only the KKInstances that match all of the given KKInstanceFilters.

func (KKInstances) Insert

func (s KKInstances) Insert(kkInstances ...*infrav1.KKInstance)

Insert adds items to the set.

func (KKInstances) Len

func (s KKInstances) Len() int

Len returns the size of the set.

func (KKInstances) Names

func (s KKInstances) Names() []string

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

func (KKInstances) Newest

func (s KKInstances) Newest() *infrav1.KKInstance

Newest returns the KKInstance with the most recent CreationTimestamp.

func (KKInstances) Oldest

func (s KKInstances) Oldest() *infrav1.KKInstance

Oldest returns the KKInstances with the oldest CreationTimestamp.

func (KKInstances) SortedByCreationTimestamp

func (s KKInstances) SortedByCreationTimestamp() []*infrav1.KKInstance

SortedByCreationTimestamp returns the KKInstances sorted by creation timestamp.

func (KKInstances) UnsortedList

func (s KKInstances) UnsortedList() []*infrav1.KKInstance

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