utils

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NvidiaAnnotationHashKey indicates annotation name for last applied hash by the operator
	NvidiaAnnotationHashKey = "nvidia.com/last-applied-hash"
)

Variables

This section is empty.

Functions

func BoolPtr

func BoolPtr(v bool) *bool

BoolPtr returns a pointer to the bool value passed in.

func ContainsElement

func ContainsElement[T comparable](slice []T, element T) bool

ContainsElement checks if an element exists in a slice

func GetFilesWithSuffix

func GetFilesWithSuffix(baseDir string, suffixes ...string) ([]string, error)

GetFilesWithSuffix returns all files under a given base directory that have a specific suffix The operation is performed recursively on subdirectories as well

func GetResourceHash

func GetResourceHash(obj client.Object) string

GetResourceHash returns a consistent hash for the given object spec

func GetStringHash

func GetStringHash(s string) string

func IsEqual

func IsEqual[T client.Object](existing, desired T, fieldsToCompare ...string) bool

IsEqual compares two Kubernetes objects based on their relevant fields.

func IsSpecChanged

func IsSpecChanged(current client.Object, desired client.Object) bool

IsSpecChanged returns true if the spec has changed between the existing one and the new resource spec compared by hash.

func MergeEnvVars

func MergeEnvVars(env1, env2 []corev1.EnvVar) []corev1.EnvVar

MergeEnvVars merges two slices of environment variables, giving precedence to the second slice in case of duplicates

func MergeMaps

func MergeMaps(m1, m2 map[string]string) map[string]string

MergeMaps merges two maps and ensures no duplicate key-value pairs

func SortHPAMetricsSpec

func SortHPAMetricsSpec(metrics []autoscalingv2.MetricSpec) []autoscalingv2.MetricSpec

func SortKeys

func SortKeys(obj interface{}) interface{}

SortKeys recursively sorts the keys of a map to ensure consistent serialization

Types

This section is empty.

Jump to

Keyboard shortcuts

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