utils

package
v0.0.0-...-1a16d43 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertToKubernetesIdentifier

func ConvertToKubernetesIdentifier(name string) string

ConvertToKubernetesIdentifier converts Python identifiers back to Kubernetes format by replacing "__NS__" with slashes and underscores with hyphens.

func ConvertToPythonIdentifier

func ConvertToPythonIdentifier(name string) string

ConvertToPythonIdentifier converts Kubernetes identifiers to Python-compatible format by replacing hyphens with underscores and slashes with "__NS__".

func Filter

func Filter[E any](s iter.Seq[E], f func(E) bool) iter.Seq[E]

func GetConfigMapValue

func GetConfigMapValue(ctx context.Context, c client.Client, ref client.ObjectKey, key string) (string, error)

GetConfigMapValue fetches a value from a ConfigMap

func GetGlobalUserID

func GetGlobalUserID() string

func GetObjectRef

func GetObjectRef(obj client.Object) string

GetObjectRef formats a Kubernetes object reference as "namespace/name" string.

func GetResourceNamespace

func GetResourceNamespace() string

GetResourceNamespace returns the namespace for resources, using the KAGENT_NAMESPACE environment variable or defaulting to "kagent".

func GetSecretValue

func GetSecretValue(ctx context.Context, c client.Client, ref client.ObjectKey, key string) (string, error)

GetSecretValue fetches a value from a Secret

func Map

func Map[E any, F any](s iter.Seq[E], f func(E) F) iter.Seq[F]

Map returns an iterator over the slice, applying the function f to each element.

func ParseRefString

func ParseRefString(ref string, parentNamespace string) (types.NamespacedName, error)

ParseRefString parses a string reference (either "namespace/name" or just "name") into a NamespacedName object, using parentNamespace when namespace is not specified.

func ResourceRefString

func ResourceRefString(namespace, name string) string

ResourceRefString formats namespace and name as a string reference in "namespace/name" format.

Types

type EmptyReferenceError

type EmptyReferenceError struct{}

func (*EmptyReferenceError) Error

func (e *EmptyReferenceError) Error() string

type KubeClientWrapper

type KubeClientWrapper interface {
	client.Client
	AddInMemory(obj client.Object) error
}

func NewKubeClientWrapper

func NewKubeClientWrapper(kube client.Client) KubeClientWrapper

type ObjectWithModelConfig

type ObjectWithModelConfig interface {
	client.Object
	GetModelConfigName() string
}

ObjectWithModelConfig represents a Kubernetes resource that can be associated with a ModelConfig. It extends client.Object to provide access to standard Kubernetes object metadata while adding the ability to specify which ModelConfig should be used for the resource. Implementers must provide a GetModelConfigName() method that returns either: - An empty string: indicating the default ModelConfig should be used - A name: indicating a ModelConfig in the same namespace as the resource - A namespace/name reference: indicating a specific ModelConfig in a specific namespace

Jump to

Keyboard shortcuts

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