utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DeleteTagAnnotation = "kuadrant.io/delete"
	ClusterIDLength     = 6
)

Variables

This section is empty.

Functions

func CompareHostnamesSpecificity

func CompareHostnamesSpecificity(hostname1, hostname2 string) bool

CompareHostnamesSpecificity returns true if hostname1 is more specific than hostname2

func Filter

func Filter[T any](slice []T, f func(T) bool) []T

Filter filters the input slice using the given predicate function and returns a new slice with the results.

func Find

func Find[T any](slice []T, match func(T) bool) (*T, bool)

func GetClusterUID

func GetClusterUID(ctx context.Context, c dynamic.Interface) (string, error)

func GetEmptySliceIfNil

func GetEmptySliceIfNil[T any](val []T) []T

GetEmptySliceIfNil returns a provided slice, or an empty slice of the same type if the input slice is nil.

func Index

func Index[T any](slice []T, match func(T) bool) int

func IsCRDInstalled

func IsCRDInstalled(restMapper meta.RESTMapper, group, kind, version string) (bool, error)

func IsObjectTaggedToDelete

func IsObjectTaggedToDelete(obj client.Object) bool

IsObjectTaggedToDelete checks if the given object is tagged for deletion. It looks for the DeleteTagAnnotation in the object's annotations and returns true if the annotation value is set to "true", false otherwise.

func IsOwnedBy

func IsOwnedBy(owned, owner client.Object) bool

IsOwnedBy checks if the provided owned object is owned by the given owner object. Ownership is determined based on matching the owner reference's group, kind, and name. The version of the owner reference is not checked in this implementation. Returns true if the owned object is owned by the owner object, false otherwise.

func Map

func Map[T, U any](slice []T, f func(T) U) []U

Map applies the given mapper function to each element in the input slice and returns a new slice with the results.

func TagObjectToDelete

func TagObjectToDelete(obj client.Object)

TagObjectToDelete adds a special DeleteTagAnnotation to the object's annotations. If the object's annotations are nil, it first initializes the Annotations field with an empty map.

func ToBase36Hash

func ToBase36Hash(s string) string

func ToBase36HashLen

func ToBase36HashLen(s string, l int) string

Types

type Name

type Name string

Name describes a (possibly wildcarded) hostname

func (Name) IsWildCarded

func (n Name) IsWildCarded() bool

func (Name) String

func (n Name) String() string

func (Name) SubsetOf

func (n Name) SubsetOf(o Name) bool

SubsetOf returns true if this hostname is a valid subset of the other hostname. The semantics are the same as "Matches", but only in one direction (i.e., h is covered by o).

Jump to

Keyboard shortcuts

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