utils

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultIfZero

func DefaultIfZero[T comparable](v, def T) T

DefaultIfZero returns def when v equals the zero value for T, otherwise returns v. Useful for numeric fields where 0 means "unset".

func EnsureVPAResource

func EnsureVPAResource(restCfg *rest.Config) error

EnsureVPAResource verifies the VerticalPodAutoscaler CRD is installed.

func FormatKeys

func FormatKeys(entries map[string]string) string

FormatKeys returns a sorted, comma-separated string representation of the key/value map.

func MergeMaps

func MergeMaps(a map[string]string, b map[string]string) map[string]string

MergeMaps returns a new map with the a map merged with the b map.

func RenderNameTemplate

func RenderNameTemplate(tmpl string, data NameTemplateData) (string, error)

RenderNameTemplate renders and validates the provided template as a DNS-1123 subdomain.

func ToCacheOptions

func ToCacheOptions(watchNamespaces []string) cache.Options

ToCacheOptions returns cache.Options configured to watch the given namespaces. If no namespaces are provided, it returns an empty Options which watches all namespaces.

func ValidateUniqueKeys

func ValidateUniqueKeys(keys map[string]string) error

ValidateUniqueKeys ensures all provided annotation/label values are unique. Returns an error if the map is empty or if any duplicate values are found.

Types

type NameTemplateData

type NameTemplateData struct {
	WorkloadName string
	Namespace    string
	Kind         string
	Profile      string
}

NameTemplateData describes fields available when rendering name templates. These map to template variables (.WorkloadName, .Namespace, .Kind, .Profile).

Jump to

Keyboard shortcuts

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