utils

package
v0.0.0-...-4c477b2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DerefOr

func DerefOr[T any](p *T, defVal T) T

func DerefOrZero

func DerefOrZero[T any](p *T) T

DerefOrZero returns the value referenced by p, or the zero-value of the type

func GetConcreteType

func GetConcreteType[T client.Object](obj client.Object) (T, bool)

GetConcreteType returns the concrete type T from a client.Object if possible. Returns the concrete type and true if successful, zero value and false if not. Example usage:

if sub, ok := GetConcreteType[*v1alpha1.Subscription](obj); ok {
    // Use sub.Status, sub.Spec etc
}
if out, ok := GetConcreteType[*v1alpha1.Output](obj); ok {
    // Use out.Status, out.Spec etc
}

func GetConcreteTypeFromList

func GetConcreteTypeFromList[T client.Object](objects []client.Object) ([]T, error)

GetConcreteTypeFromList converts a slice of client.Object to a slice of concrete types. Returns an error if any conversion fails. Example usage:

subscriptions, err := GetConcreteTypeFromList[*v1alpha1.Subscription](objectList)
outputs, err := GetConcreteTypeFromList[*v1alpha1.Output](objectList)

func NormalizeStringSlice

func NormalizeStringSlice(inputList []string) []string

NormalizeStringSlice takes a slice of strings, removes duplicates, sorts it, and returns the unique sorted slice.

func ToObject

func ToObject[T client.Object](items []T) []client.Object

ToObject converts a slice of concrete types to a slice of client.Object.

func ToPtr

func ToPtr[T any](v T) *T

func ToValue

func ToValue[T any](v *T) T

Types

This section is empty.

Jump to

Keyboard shortcuts

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