quota

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

Add returns the result of a + b for each named resource

func AddAllToRegistry

func AddAllToRegistry(registry Registry, evaluators []Evaluator) error

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

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 IsNegative

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

LessThanOrEqual returns true if a < b for each key in b If false, it returns the keys in a that exceeded b

func Mask

Mask returns a new resource list that only has the values with the specified names

func Max

Max returns the result of Max(a, b) for each named resource

func RemoveZeros

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

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

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

func NewRegistry(scheme *runtime.Scheme) Registry

type UsageCalculator

type UsageCalculator interface {
	CalculateUsage(ctx context.Context, quota *corev1alpha1.ResourceQuota) (corev1alpha1.ResourceList, error)
}

func NewUsageCalculator

func NewUsageCalculator(c client.Client, scheme *runtime.Scheme, registry Registry) UsageCalculator

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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