collections

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2021 License: Apache-2.0 Imports: 13 Imported by: 29

Documentation

Overview

Package collections implements collection utilities.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveMachines

func ActiveMachines(machine *clusterv1.Machine) bool

ActiveMachines returns a filter to find all active machines. Usage: GetFilteredMachinesForCluster(ctx, client, cluster, ActiveMachines).

func AdoptableControlPlaneMachines

func AdoptableControlPlaneMachines(clusterName string) func(machine *clusterv1.Machine) bool

AdoptableControlPlaneMachines returns a filter to find all un-controlled control plane machines. Usage: GetFilteredMachinesForCluster(ctx, client, cluster, AdoptableControlPlaneMachines(cluster.Name, controlPlane)).

func ControlPlaneMachines

func ControlPlaneMachines(clusterName string) func(machine *clusterv1.Machine) bool

ControlPlaneMachines returns a filter to find all control plane machines for a cluster, regardless of ownership. Usage: GetFilteredMachinesForCluster(ctx, client, cluster, ControlPlaneMachines(cluster.Name)).

func ControlPlaneSelectorForCluster

func ControlPlaneSelectorForCluster(clusterName string) labels.Selector

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

func HasControllerRef

func HasControllerRef(machine *clusterv1.Machine) bool

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

func HasDeletionTimestamp

func HasDeletionTimestamp(machine *clusterv1.Machine) bool

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

func HasUnhealthyCondition

func HasUnhealthyCondition(machine *clusterv1.Machine) bool

HasUnhealthyCondition returns a filter to find all machines that have a MachineHealthCheckSucceeded condition set to False, indicating a problem was detected on the machine, and the MachineOwnerRemediated condition set, indicating that KCP is responsible of performing remediation as owner of the machine.

func OwnedMachines

func OwnedMachines(owner client.Object) func(machine *clusterv1.Machine) bool

OwnedMachines returns a filter to find all machines owned by specified owner. Usage: GetFilteredMachinesForCluster(ctx, client, cluster, OwnedMachines(controlPlane)).

func ToMachineList

func ToMachineList(machines Machines) clusterv1.MachineList

ToMachineList creates a MachineList from the given Machines.

Types

type Func

type Func func(machine *clusterv1.Machine) 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 machines that have the specified Annotation key present.

func HealthyAPIServer added in v0.4.1

func HealthyAPIServer() Func

HealthyAPIServer returns a filter to find all machines that have a MachineAPIServerPodHealthyCondition set to true.

func InFailureDomains

func InFailureDomains(failureDomains ...*string) Func

InFailureDomains returns a filter to find all machines in any of the given failure domains.

func IsReady

func IsReady() Func

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

func MatchesKubernetesVersion

func MatchesKubernetesVersion(kubernetesVersion string) Func

MatchesKubernetesVersion returns a filter to find all machines that match a given Kubernetes version.

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 machines where CreationTimestamp < rolloutAfter < reconciliationTIme.

func WithVersion added in v0.4.1

func WithVersion() Func

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

type Machines

type Machines map[string]*clusterv1.Machine

Machines is a set of Machines.

func FromMachineList

func FromMachineList(machineList *clusterv1.MachineList) Machines

FromMachineList creates a Machines from the given MachineList.

func FromMachines

func FromMachines(machines ...*clusterv1.Machine) Machines

FromMachines creates a Machines from a list of values.

func GetFilteredMachinesForCluster

func GetFilteredMachinesForCluster(ctx context.Context, c client.Reader, cluster *clusterv1.Cluster, filters ...Func) (Machines, error)

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

func New

func New() Machines

New creates an empty Machines.

func (Machines) AnyFilter

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

AnyFilter returns a Machines containing only the Machines that match any of the given MachineFilters.

func (Machines) ConditionGetters

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

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

func (Machines) DeepCopy

func (s Machines) DeepCopy() Machines

DeepCopy returns a deep copy.

func (Machines) Difference

func (s Machines) Difference(machines Machines) Machines

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

func (Machines) Filter

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

Filter returns a Machines containing only the Machines that match all of the given MachineFilters.

func (Machines) Insert

func (s Machines) Insert(machines ...*clusterv1.Machine)

Insert adds items to the set.

func (Machines) Len

func (s Machines) Len() int

Len returns the size of the set.

func (Machines) LowestVersion added in v0.4.1

func (s Machines) LowestVersion() *string

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

func (Machines) Names

func (s Machines) Names() []string

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

func (Machines) Newest

func (s Machines) Newest() *clusterv1.Machine

Newest returns the Machine with the most recent CreationTimestamp.

func (Machines) Oldest

func (s Machines) Oldest() *clusterv1.Machine

Oldest returns the Machine with the oldest CreationTimestamp.

func (Machines) SortedByCreationTimestamp

func (s Machines) SortedByCreationTimestamp() []*clusterv1.Machine

SortedByCreationTimestamp returns the machines sorted by creation timestamp.

func (Machines) UnsortedList

func (s Machines) UnsortedList() []*clusterv1.Machine

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