Documentation ¶
Index ¶
- func Add(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) corev1alpha1.ResourceList
- func AddAllToRegistry(registry Registry, evaluators []Evaluator) error
- func ContainsPrefix(prefixSet []string, item corev1alpha1.ResourceName) bool
- func Equals(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) bool
- func EvaluatorMatchesResourceList(evaluator Evaluator, list corev1alpha1.ResourceList) bool
- func EvaluatorMatchesResourceNames(evaluator Evaluator, names sets.Set[corev1alpha1.ResourceName]) bool
- func EvaluatorMatchesResourceScopeSelector(evaluator Evaluator, item client.Object, ...) (bool, error)
- func EvaluatorMatchingResourceNames(evaluator Evaluator, names sets.Set[corev1alpha1.ResourceName]) sets.Set[corev1alpha1.ResourceName]
- func GetResourceScopeSelectorRequirements(scopeSelector *corev1alpha1.ResourceScopeSelector) []corev1alpha1.ResourceScopeSelectorRequirement
- func IsNegative(a corev1alpha1.ResourceList) sets.Set[corev1alpha1.ResourceName]
- func IsZero(a corev1alpha1.ResourceList) bool
- func KubernetesResourceListToResourceList(k8sResourceList corev1.ResourceList) corev1alpha1.ResourceList
- func LessThanOrEqual(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) (bool, sets.Set[corev1alpha1.ResourceName])
- func Mask(resources corev1alpha1.ResourceList, names sets.Set[corev1alpha1.ResourceName]) corev1alpha1.ResourceList
- func Max(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) corev1alpha1.ResourceList
- func RemoveZeros(a corev1alpha1.ResourceList) corev1alpha1.ResourceList
- func ResourceNames(resources corev1alpha1.ResourceList) sets.Set[corev1alpha1.ResourceName]
- func Subtract(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) corev1alpha1.ResourceList
- func SubtractWithNonNegativeResult(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) corev1alpha1.ResourceList
- func ToSet(resourceNames []corev1alpha1.ResourceName) sets.Set[corev1alpha1.ResourceName]
- type Evaluator
- type Registry
- type UsageCalculator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) corev1alpha1.ResourceList
Add returns the result of a + b for each named resource
func AddAllToRegistry ¶
func ContainsPrefix ¶
func ContainsPrefix(prefixSet []string, item corev1alpha1.ResourceName) bool
ContainsPrefix returns true if the specified item has a prefix that contained in given prefix Set
func Equals ¶
func Equals(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) bool
Equals returns true if the two lists are equivalent
func EvaluatorMatchesResourceList ¶
func EvaluatorMatchesResourceList(evaluator Evaluator, list corev1alpha1.ResourceList) bool
func EvaluatorMatchesResourceNames ¶
func EvaluatorMatchesResourceNames(evaluator Evaluator, names sets.Set[corev1alpha1.ResourceName]) bool
func EvaluatorMatchesResourceScopeSelector ¶
func EvaluatorMatchesResourceScopeSelector( evaluator Evaluator, item client.Object, resourceScopeSelector *corev1alpha1.ResourceScopeSelector, ) (bool, error)
func EvaluatorMatchingResourceNames ¶
func EvaluatorMatchingResourceNames(evaluator Evaluator, names sets.Set[corev1alpha1.ResourceName]) sets.Set[corev1alpha1.ResourceName]
func GetResourceScopeSelectorRequirements ¶
func GetResourceScopeSelectorRequirements(scopeSelector *corev1alpha1.ResourceScopeSelector) []corev1alpha1.ResourceScopeSelectorRequirement
func IsNegative ¶
func IsNegative(a corev1alpha1.ResourceList) sets.Set[corev1alpha1.ResourceName]
IsNegative returns the set of resource names that have a negative value.
func IsZero ¶
func IsZero(a corev1alpha1.ResourceList) bool
IsZero returns true if each key maps to the quantity value 0
func KubernetesResourceListToResourceList ¶
func KubernetesResourceListToResourceList(k8sResourceList corev1.ResourceList) corev1alpha1.ResourceList
func LessThanOrEqual ¶
func LessThanOrEqual(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) (bool, sets.Set[corev1alpha1.ResourceName])
LessThanOrEqual returns true if a < b for each key in b If false, it returns the keys in a that exceeded b
func Mask ¶
func Mask(resources corev1alpha1.ResourceList, names sets.Set[corev1alpha1.ResourceName]) corev1alpha1.ResourceList
Mask returns a new resource list that only has the values with the specified names
func Max ¶
func Max(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) corev1alpha1.ResourceList
Max returns the result of Max(a, b) for each named resource
func RemoveZeros ¶
func RemoveZeros(a corev1alpha1.ResourceList) corev1alpha1.ResourceList
RemoveZeros returns a new resource list that only has no zero values
func ResourceNames ¶
func ResourceNames(resources corev1alpha1.ResourceList) sets.Set[corev1alpha1.ResourceName]
ResourceNames returns a list of all resource names in the ResourceList
func Subtract ¶
func Subtract(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) corev1alpha1.ResourceList
Subtract returns the result of a - b for each named resource
func SubtractWithNonNegativeResult ¶
func SubtractWithNonNegativeResult(a corev1alpha1.ResourceList, b corev1alpha1.ResourceList) corev1alpha1.ResourceList
SubtractWithNonNegativeResult - subtracts and returns result of a - b but makes sure we don't return negative values to prevent negative resource usage.
func ToSet ¶
func ToSet(resourceNames []corev1alpha1.ResourceName) sets.Set[corev1alpha1.ResourceName]
ToSet takes a list of resource names and converts to a string set
Types ¶
type Evaluator ¶
type Evaluator interface { Type() client.Object MatchesResourceName(resourceName corev1alpha1.ResourceName) bool MatchesResourceScopeSelectorRequirement(item client.Object, req corev1alpha1.ResourceScopeSelectorRequirement) (bool, error) Usage(ctx context.Context, item client.Object) (corev1alpha1.ResourceList, error) }
type Registry ¶
type Registry interface { // Add to registry Add(e Evaluator) error // Remove from registry Remove(obj client.Object) error // Get by group resource Get(obj client.Object) (Evaluator, error) // List from registry List() []Evaluator }
func NewRegistry ¶
type UsageCalculator ¶
type UsageCalculator interface {
CalculateUsage(ctx context.Context, quota *corev1alpha1.ResourceQuota) (corev1alpha1.ResourceList, error)
}