util

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2021 License: Apache-2.0 Imports: 17 Imported by: 1

Documentation

Index

Constants

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

	// 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 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 GetMachineMetadata

func GetMachineMetadata(hostname string, vsphereVM infrav1.VSphereVM, networkStatuses ...infrav1.NetworkStatus) ([]byte, error)

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

func GetMachinePreferredIPAddress

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

GetMachinePreferredIPAddress returns the preferred IP address for a VSphereMachine resource.

func GetMachinesInCluster

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

GetMachinesInCluster gets a cluster's Machine resources.

func GetOwnerVSphereMachine added in v0.7.9

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

func GetVSphereMachine

func GetVSphereMachine(
	ctx context.Context,
	controllerClient client.Client,
	namespace, machineName string) (*infrav1.VSphereMachine, error)

GetVSphereMachine gets a VSphereMachine resource for the given CAPI Machine.

func GetVSphereMachinesInCluster

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

GetVSphereMachinesInCluster gets a cluster's VSphereMachine resources.

func IsControlPlaneMachine

func IsControlPlaneMachine(machine metav1.Object) bool

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

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.

Types

This section is empty.

Jump to

Keyboard shortcuts

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