Documentation
¶
Index ¶
- func BackendObjectReferenceToKey(backendRef gatewayv1.BackendObjectReference) string
- func ClearMap[K comparable, V any](m map[K]V)
- func ComparePointers[T cmp.Ordered](a, b *T) int
- func KeyToBackendObjectReference(key string) (gatewayv1.BackendObjectReference, error)
- func KeyToParentRef(key string) (gatewayv1.ParentReference, error)
- func Keys[K comparable, V any](src map[K]V) map[K]struct{}
- func MapToSortedListByCreationTimestamp[T ObjectWithTimestamp](objects map[types.NamespacedName]T) []T
- func NamespaceAsString(ns *gatewayv1.Namespace) string
- func ObjectKeyFromNamespacedName(s string) (client.ObjectKey, error)
- func ParentRefToKey(parentRef gatewayv1.ParentReference) string
- func ParseNamespacedName(s string) (types.NamespacedName, error)
- func Ptr[V any](v V) *V
- func PtrInt64(value int64) *int64
- func RouteGroupKindsToString(routesGK []gatewayv1.RouteGroupKind) string
- func SetDifference[K comparable, V any](mapA, mapB map[K]V) map[K]struct{}
- func SetIntersection[K comparable, V any](mapA, mapB map[K]V) map[K]struct{}
- func SortByCreationTimestamp[T ObjectWithTimestamp](objects []T)
- func StrPtrToString[T stringer](p *T) string
- func StringToPtr[T stringer](s string) *T
- type Errors
- type ExtractGVK
- type KeyMap
- func (m *KeyMap[KEY, VALUE]) Clear()
- func (m *KeyMap[KEY, VALUE]) DeepCopy() KeyMap[KEY, VALUE]
- func (m *KeyMap[KEY, VALUE]) Delete(key KEY)
- func (m *KeyMap[KEY, VALUE]) Exists(key KEY) bool
- func (m *KeyMap[KEY, VALUE]) Get(key KEY) (VALUE, bool)
- func (m *KeyMap[KEY, VALUE]) Iterate(callback func(string, VALUE) bool)
- func (m *KeyMap[KEY, VALUE]) Len() int
- func (m *KeyMap[KEY, VALUE]) Set(key KEY, value VALUE)
- type ObjectWithTimestamp
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BackendObjectReferenceToKey ¶
func BackendObjectReferenceToKey(backendRef gatewayv1.BackendObjectReference) string
BackendObjectReferenceToKey converts a BackendObjectReferenceToKey to a unique string key. It handles nil pointers by using a consistent placeholder.
func ClearMap ¶
func ClearMap[K comparable, V any](m map[K]V)
Generic function to clear a map in place
func ComparePointers ¶
ComparePointers compares two pointers to any ordered type. It establishes a consistent sort order where nil values come before non-nil values.
It returns:
- -1 if a < b
- 0 if a == b (or both are nil)
- +1 if a > b
func KeyToBackendObjectReference ¶
func KeyToBackendObjectReference(key string) (gatewayv1.BackendObjectReference, error)
KeyToBackendObjectReference converts a string key back to a gatewayv1.BackendObjectReference. It is the inverse of BackendObjectReferenceToKey.
func KeyToParentRef ¶
func KeyToParentRef(key string) (gatewayv1.ParentReference, error)
KeyToParentRef converts a string key back to a gatewayv1.ParentReference. It is the inverse of ParentRefToKey.
func Keys ¶
func Keys[K comparable, V any](src map[K]V) map[K]struct{}
func MapToSortedListByCreationTimestamp ¶
func MapToSortedListByCreationTimestamp[T ObjectWithTimestamp](objects map[types.NamespacedName]T) []T
func NamespaceAsString ¶
func ParentRefToKey ¶
func ParentRefToKey(parentRef gatewayv1.ParentReference) string
ParentRefToKey converts a ParentReference to a unique string key. It handles nil pointers by using a consistent placeholder.
func ParseNamespacedName ¶
func ParseNamespacedName(s string) (types.NamespacedName, error)
ParseNamespacedName parses a "namespace/name" string into a NamespacedName.
func RouteGroupKindsToString ¶
func RouteGroupKindsToString(routesGK []gatewayv1.RouteGroupKind) string
func SetDifference ¶
func SetDifference[K comparable, V any](mapA, mapB map[K]V) map[K]struct{}
SetDifference finds the keys that are in mapA but not in mapB. It works for any map with a comparable key type K and any value type V.
func SetIntersection ¶
func SetIntersection[K comparable, V any](mapA, mapB map[K]V) map[K]struct{}
func SortByCreationTimestamp ¶
func SortByCreationTimestamp[T ObjectWithTimestamp](objects []T)
func StrPtrToString ¶
func StrPtrToString[T stringer](p *T) string
func StringToPtr ¶
func StringToPtr[T stringer](s string) *T
StringToPtr converts a string to a pointer of a string-based type. If the string is the placeholder "_", it returns nil.
Types ¶
type ExtractGVK ¶
type ExtractGVK func(object client.Object) schema.GroupVersionKind
ExtractGVK is a function that extracts the GroupVersionKind (GVK) of a client.object. It will log an error if the GKV cannot be extracted.
func NewExtractGKV ¶
func NewExtractGKV(scheme *runtime.Scheme, logger *slog.Logger) ExtractGVK
NewExtractGKV creates a new MustExtractGVK function using the scheme.
type KeyMap ¶
func (*KeyMap[KEY, VALUE]) DeepCopy ¶
DeepCopy creates a deep copy of the KeyMap. It requires the VALUE type to have a DeepCopy() method.