utils

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendEnvVarIfNotExists

func AppendEnvVarIfNotExists(slice []v1.EnvVar, elems ...v1.EnvVar) []v1.EnvVar

func AppendPortIfNotExists

func AppendPortIfNotExists(slice []v1.ContainerPort, elems ...v1.ContainerPort) []v1.ContainerPort

func AppendVolumeIfNotExists

func AppendVolumeIfNotExists(slice []v1.Volume, volume v1.Volume) []v1.Volume

func Bool

func Bool(b bool) *bool

func Filter

func Filter(origin map[string]string, predicate func(string) bool) map[string]string

func FirstNonNilError

func FirstNonNilError(objects []error) error

FirstNonNilError returns the first non nil interface in the slice

func GetAvailableResourcesForApi

func GetAvailableResourcesForApi(config *rest.Config, groupVersion string) (*metav1.APIResourceList, error)

GetAvailableResourcesForApi returns the list of discovered resources that belong to the API specified in groupVersion. The first query to a specifig groupVersion will query the cluster API server to discover the available resources and the discovered resources will be cached and returned to subsequent invocations to prevent additional queries to the API server.

func GetInstanceTypeShortName added in v0.1.3

func GetInstanceTypeShortName(currentInstanceType string) (string, error)

func GetNodeInstanceType added in v0.1.3

func GetNodeInstanceType(logger logging.Interface) (string, error)

GetNodeInstanceType retrieves the instance type of the node. NOTE: This implementation is currently specific to Oracle Cloud Infrastructure (OCI) and uses the OCI IMDS client. A future refactor is needed to support other cloud providers' metadata services.

func Includes

func Includes(slice []string, value string) bool

func IncludesArg

func IncludesArg(slice []string, arg string) bool

func IsCrdAvailable

func IsCrdAvailable(config *rest.Config, groupVersion, kind string) (bool, error)

IsCrdAvailable checks if a given CRD is present in the cluster by verifying the existence of its API.

func IsGPUEnabled

func IsGPUEnabled(requirements v1.ResourceRequirements) bool

func IsPrefixSupported

func IsPrefixSupported(input string, prefixes []string) bool

IsPrefixSupported Check if a given string contains one of the prefixes in the provided list.

func IsStringEmptyOrWithWhitespaces

func IsStringEmptyOrWithWhitespaces(input string) bool

func MergeEnvs

func MergeEnvs(baseEnvs []v1.EnvVar, overrideEnvs []v1.EnvVar) []v1.EnvVar

MergeEnvs Merge a slice of EnvVars (`O`) into another slice of EnvVars (`B`), which does the following: 1. If an EnvVar is present in B but not in O, value remains unchanged in the result 2. If an EnvVar is present in `O` but not in `B`, appends to the result 3. If an EnvVar is present in both O and B, uses the value from O in the result

func RemoveString

func RemoveString(slice []string, s string) (result []string)

RemoveString Helper functions to remove string from a slice of strings.

func Retry

func Retry(attempts int, sleep time.Duration, f func() error) (err error)

func SetAvailableResourcesForApi

func SetAvailableResourcesForApi(groupVersion string, resources *metav1.APIResourceList)

SetAvailableResourcesForApi stores the value fo resources argument in the global cache of discovered API resources. This function should never be called directly. It is exported for usage in tests.

func UInt64

func UInt64(u uint64) *uint64

func Union

func Union(maps ...map[string]string) map[string]string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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