Skip to main content

ToK8sResourceList

Converts a list of generic resource entries into a Kubernetes-specific resource list (v1.ResourceList). It parses resource values and maps them to corresponding Kubernetes resource types like CPU, Memory, GPU, and Ephemeral Storage.

def ToK8sResourceList(
resources: []*core.Resources_ResourceEntry
) - > v1.ResourceList, error

Converts a slice of generic resource entries into a Kubernetes-specific resource list. This function is used to transform a list of resource requests or limits, such as CPU, memory, or GPU, into the format expected by Kubernetes for container specifications.

Parameters

NameTypeDescription
resources[]*core.Resources_ResourceEntryA slice of generic resource entries, where each entry specifies a resource name (e.g., CPU, MEMORY, GPU) and its string representation of quantity.

Returns

TypeDescription
v1.ResourceList, errorA Kubernetes ResourceList containing the parsed resource quantities, or an error if any resource value cannot be parsed as a valid quantity.