util

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: GPL-3.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ProviderIDPrefix is the string data prefixed to a BIOS UUID in order
	// to build a provider ID.
	ProviderIDPrefix = "ics://"

	// ProviderIDPattern is a regex pattern and is used by ConvertProviderIDToUUID
	// to convert a providerID into a UUID string.
	ProviderIDPattern = `(?i)^` + ProviderIDPrefix + `([a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12})$`

	// UUIDPattern is a regex pattern and is used by ConvertUUIDToProviderID
	// to convert a UUID into a providerID string.
	UUIDPattern = `(?i)^[a-f\d]{8}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{4}-[a-f\d]{12}$`
)

Variables

View Source
var ErrNoMachineIPAddr = errors.New("no IP addresses found for machine")

ErrNoMachineIPAddr indicates that no valid IP addresses were found in a machine context.

Functions

func ConvertIPAddrsToPreAllocations

func ConvertIPAddrsToPreAllocations(ipAddrs []string) map[string]string

ConvertIPAddrsToIPs transforms a ipAddrs strings into PreAllocations IP.

func ConvertProviderIDToUUID

func ConvertProviderIDToUUID(providerID *string) string

ConvertProviderIDToUUID transforms a provider ID into a UUID string. If providerID is nil, empty, or invalid, then an empty string is returned. A valid providerID should adhere to the format specified by ProviderIDPattern.

func ConvertUUIDToProviderID

func ConvertUUIDToProviderID(uuid string) string

ConvertUUIDToProviderID transforms a UUID string into a provider ID. If the supplied UUID is empty or invalid then an empty string is returned. A valid UUID should adhere to the format specified by UUIDPattern.

func CreateOrUpdateIPAddress

func CreateOrUpdateIPAddress(ctx *context.VMContext, ipAddressName string, network basetypv1.Nic) (runtime.Object, error)

func FetchControlPlaneOwnerObject

func FetchControlPlaneOwnerObject(input FetchObjectInput) (ctrlclient.Object, error)

func FetchMachineDeploymentOwnerObject

func FetchMachineDeploymentOwnerObject(input FetchObjectInput) (ctrlclient.Object, error)

func GetControlPlaneICSMachinesInCluster added in v1.0.2

func GetControlPlaneICSMachinesInCluster(ctx context.Context, controllerClient client.Client,
	namespace, clusterName string) ([]*infrav1.ICSMachine, error)

GetControlPlaneICSMachinesInCluster gets a cluster's ICSMachine resources.

func GetICSClusterFromICSMachine

func GetICSClusterFromICSMachine(ctx context.Context, c client.Client, machine *infrav1.ICSMachine) (*infrav1.ICSCluster, error)

GetICSClusterFromICSMachine gets the infrastructure.cluster.x-k8s.io.ICSCluster resource for the given ICSMachine.

func GetICSMachineByName

func GetICSMachineByName(ctx context.Context, c client.Client, namespace, name string) (*infrav1.ICSMachine, error)

func GetICSMachinesInCluster

func GetICSMachinesInCluster(ctx context.Context, controllerClient client.Client,
	namespace, clusterName string) ([]*infrav1.ICSMachine, error)

GetICSMachinesInCluster gets a cluster's ICSMachine resources.

func GetIPAddressByCIDR

func GetIPAddressByCIDR(cidr string, filter map[string]string) (net.IP, error)

GetIPAddressByCIDR generate ip

func GetIPFromNetworkConfig

func GetIPFromNetworkConfig(
	ctx *context.VMContext,
	network *infrav1.NetworkDeviceSpec) (*string, *string, error)

GetIPFromPools from cluster template

func GetMachineByName added in v1.0.2

func GetMachineByName(ctx context.Context, c client.Client, namespace, name string) (*clusterv1.Machine, error)

func GetMachineMetadata

func GetMachineMetadata(hostname string, icsVM infrav1.ICSVM, networkStatuses ...infrav1.NetworkStatus) ([]byte, error)

GetMachineMetadata returns the cloud-init metadata as a base-64 encoded string for a given ICSMachine.

func GetMachinePreferredIPAddress

func GetMachinePreferredIPAddress(machine *infrav1.ICSMachine) (string, error)

GetMachinePreferredIPAddress returns the preferred IP address for a ICSMachine resource.

func GetMachinesInCluster

func GetMachinesInCluster(
	ctx context.Context,
	controllerClient client.Client,
	namespace, clusterName string) ([]*clusterv1.Machine, error)

GetMachinesInCluster gets a cluster's Machine resources. I6_spur!

func GetOwnerICSMachine

func GetOwnerICSMachine(ctx context.Context, c client.Client, obj metav1.ObjectMeta) (*infrav1.ICSMachine, error)

func GetOwnerMachine added in v1.0.2

func GetOwnerMachine(ctx context.Context, c client.Client, obj metav1.ObjectMeta) (*clusterv1.Machine, error)

func IsControlPlaneMachine

func IsControlPlaneMachine(machine metav1.Object) bool

IsControlPlaneMachine returns true if the provided resource is a member of the control plane.

func IsNotFoundError

func IsNotFoundError(err error) bool

func MachinesAsString

func MachinesAsString(machines []*clusterv1.Machine) string

MachinesAsString constructs a string (with correct punctuations) to be used in logging and error messages.

func NewKubeClient

func NewKubeClient(ctx context.Context, controllerClient client.Client, cluster *clusterv1.Cluster) (kubernetes.Interface, error)

NewKubeClient returns a new client for the target cluster using the KubeConfig secret stored in the management cluster.

func SanitizeHostInfoLabel

func SanitizeHostInfoLabel(info string) string

SanitizeHostInfoLabel ensures that the iNode host information passed as a parameter confirms to the label value constraints documented at https://k8s.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set

The expected inputs for the object are IP addresses of the iNode hosts.

func UpdateNetworkInfo

func UpdateNetworkInfo(ctx *context.VMContext, networkStatus []infrav1.NetworkStatus)

Types

type FetchObjectInput

type FetchObjectInput struct {
	context.Context
	ctrlclient.Client
	Object ctrlclient.Object
}

Jump to

Keyboard shortcuts

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