Documentation ¶
Index ¶
- Constants
- func Filter[T any](slice []T, f func(T) bool) []T
- func Find[T any](slice []T, match func(T) bool) (*T, bool)
- func FindDeploymentStatusCondition(conditions []appsv1.DeploymentCondition, conditionType string) *appsv1.DeploymentCondition
- func FindObjectKey(a []client.ObjectKey, x client.ObjectKey) int
- func GetClusterUID(ctx context.Context, c client.Client) (string, error)
- func GetEmptySliceIfNil[T any](val []T) []T
- func GetLabel(obj metav1.Object, key string) string
- func GetService(ctx context.Context, k8sClient client.Client, serviceKey client.ObjectKey) (*corev1.Service, error)
- func GetServicePortNumber(ctx context.Context, k8sClient client.Client, serviceKey client.ObjectKey, ...) (int32, error)
- func GetServiceWorkloadSelector(ctx context.Context, k8sClient client.Client, serviceKey client.ObjectKey) (map[string]string, error)
- func HasLabel(obj metav1.Object, key string) bool
- func HostnamesToStrings(hostnames []gatewayapiv1.Hostname) []string
- func Index[T any](slice []T, match func(T) bool) int
- func Intersect[T comparable](slice1, slice2 []T) bool
- func Intersection[T comparable](slice1, slice2 []T) []T
- func IsObjectTaggedToDelete(obj client.Object) bool
- func IsOwnedBy(owned, owner client.Object) bool
- func Map[T, U any](slice []T, f func(T) U) []U
- func NamespacedNameToObjectKey(namespacedName, defaultNamespace string) client.ObjectKey
- func ObjectInfo(obj client.Object) string
- func ObjectKeyListDifference(a, b []client.ObjectKey) []client.ObjectKey
- func ReadAnnotationsFromObject(obj client.Object) map[string]string
- func SameElements[T comparable](s1, s2 []T) bool
- func StatusConditionsMarshalJSON(input []metav1.Condition) ([]byte, error)
- func TagObjectToDelete(obj client.Object)
- func ValidSubdomains(domains, subdomains []string) (bool, string)
- type Name
Constants ¶
const ( DeleteTagAnnotation = "kuadrant.io/delete" ClusterIDLength = 6 )
Variables ¶
This section is empty.
Functions ¶
func Filter ¶
Filter filters the input slice using the given predicate function and returns a new slice with the results.
func FindDeploymentStatusCondition ¶
func FindDeploymentStatusCondition(conditions []appsv1.DeploymentCondition, conditionType string) *appsv1.DeploymentCondition
func FindObjectKey ¶
FindObjectKey returns the smallest index i at which x == a[i], or len(a) if there is no such index.
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 GetService ¶
func GetServicePortNumber ¶
func GetServicePortNumber(ctx context.Context, k8sClient client.Client, serviceKey client.ObjectKey, servicePort string) (int32, error)
GetServicePortNumber returns the port number from the referenced key and port info the port info can be named port or already a number.
func HostnamesToStrings ¶
func HostnamesToStrings(hostnames []gatewayapiv1.Hostname) []string
HostnamesToStrings converts []gatewayapiv1.Hostname to []string
func Intersect ¶
func Intersect[T comparable](slice1, slice2 []T) bool
func Intersection ¶
func Intersection[T comparable](slice1, slice2 []T) []T
func IsObjectTaggedToDelete ¶
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 ¶
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 NamespacedNameToObjectKey ¶
NamespacedNameToObjectKey converts <namespace/name> format string to k8s object key. It's common for K8s to reference an object using this format. For e.g. gateways in VirtualService.
func ObjectInfo ¶
ObjectInfo generates a string representation of the provided Kubernetes object, including its kind and name. The generated string follows the format: "kind/name".
func ObjectKeyListDifference ¶
ObjectKeyListDifference computest a - b
func ReadAnnotationsFromObject ¶
ReadAnnotationsFromObject reads the annotations from a Kubernetes object and returns them as a map. If the object has no annotations, it returns an empty map.
func SameElements ¶
func SameElements[T comparable](s1, s2 []T) bool
SameElements checks if the two slices contain the exact same elements. Order does not matter.
func StatusConditionsMarshalJSON ¶
StatusConditionsMarshalJSON marshals the list of conditions as a JSON array, sorted by condition type.
func TagObjectToDelete ¶
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 ValidSubdomains ¶
ValidSubdomains returns (true, "") when every single subdomains item is a subset of at least one of the domains. Domains and subdomains may be prefixed with a wildcard label (*.). The wildcard label must appear by itself as the first label. When one of the subdomains is not a subset of the domains, it returns false and the subdomain not being subset of the domains
Types ¶
type Name ¶
type Name string
Name describes a (possibly wildcarded) hostname