util

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// RKE2_CIS_VERSION_CHANGE is the version where the CIS benchmark changed in RKE2 (because of PSPs).
	RKE2_CIS_VERSION_CHANGE = "v1.25.0"
)

Variables

View Source
var ErrControlPlaneNotFound = errors.New("control plane not found")

ErrControlPlaneNotFound is returned when a control plane is not found.

Functions

func AppendIfNotPresent

func AppendIfNotPresent(origSlice []string, strItem string) (resultSlice []string)

AppendIfNotPresent appends a string to a slice only if the value does not already exist.

func AtLeastv125

func AtLeastv125(rke2version string) (bool, error)

AtLeastv125 returns true if the RKE2 version is at least v1.25.0.

func CompareVersions

func CompareVersions(v1 string, v2 string) bool

CompareVersions compares two string version supposing those would begin with 'v' or not.

func GetClusterByName

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

GetClusterByName finds and return a Cluster object using the specified params.

func GetControlPlaneByName

func GetControlPlaneByName(ctx context.Context, c client.Client, namespace, name string) (*controlplanev1.RKE2ControlPlane, error)

GetControlPlaneByName finds and return a ControlPlane object using the specified params.

func GetMapKeysAsString

func GetMapKeysAsString(m map[string][]byte) (keys string)

GetMapKeysAsString returns a comma separated string of keys from a map.

func GetOwnerControlPlane

func GetOwnerControlPlane(ctx context.Context, c client.Client, obj metav1.ObjectMeta) (*controlplanev1.RKE2ControlPlane, error)

GetOwnerControlPlane returns the RKE2ControlPlane object that owns the object passed as parameter.

func IsRKE2Version added in v0.5.0

func IsRKE2Version(rke2Version string) bool

IsRKE2Version checks if a string is an RKE2 version.

func ProfileCompliant

func ProfileCompliant(profile bootstrapv1.CISProfile, version string) bool

ProfileCompliant returns true if the CIS profile is compliant.

func Random

func Random(size int) (string, error)

Random generates a random string with length size.

func Rke2ToKubeVersion

func Rke2ToKubeVersion(rk2Version string) (kubeVersion string, err error)

Rke2ToKubeVersion converts an RKE2 version to a Kubernetes version.

func SafeInt32 added in v0.13.0

func SafeInt32(n int) int32

SafeInt32 returns the int32 value of an int, ensuring it does not exceed the maximum int32 value.

func TokenName

func TokenName(clusterName string) string

TokenName returns a token name from the cluster name.

Types

This section is empty.

Jump to

Keyboard shortcuts

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