utils

package
v0.0.0-...-ccac432 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2025 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConvertAutogenEventsToMessages

func ConvertAutogenEventsToMessages(taskId, contextId *string, events ...client.Event) []*protocol.Message

func ConvertMessagesToAutogenEvents

func ConvertMessagesToAutogenEvents(messages []protocol.Message) ([]autogen_client.Event, error)

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 GetGlobalUserID

func GetGlobalUserID() string

func GetModelConfig

func GetModelConfig(
	ctx context.Context,
	kube client.Client,
	resource ObjectWithModelConfig,
	defaultModelConfig types.NamespacedName,
) (*v1alpha1.ModelConfig, error)

GetModelConfig retrieves the ModelConfig for a resource. It uses the resource's specified model config name or falls back to the default.

func GetObject

func GetObject(ctx context.Context, kube client.Client, obj client.Object, objRef, defaultNamespace string) error

GetObject fetches the Kubernetes resource identified by objRef into obj. objRef may be given as "namespace/name" or just "name"; if the namespace is missing, defaultNamespace is applied

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 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