quota

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClampQuantityToZero

func ClampQuantityToZero(q *resource.Quantity)

func ConditionsMatch

func ConditionsMatch(u unstructured.Unstructured, conditions []*jsonpath.CompiledJSONPath) (bool, error)

func MakeCustomQuotaCacheKey

func MakeCustomQuotaCacheKey(namespace, name string) string

func MakeGlobalCustomQuotaCacheKey

func MakeGlobalCustomQuotaCacheKey(name string) string

func NegateQuantity

func NegateQuantity(in resource.Quantity) resource.Quantity

func ParseBoolFromUnstructured

func ParseBoolFromUnstructured(u unstructured.Unstructured, compiled *jsonpath.CompiledJSONPath) (bool, error)

func ParseQuantities

func ParseQuantities(value string) (resource.Quantity, error)

func ParseQuantityFromUnstructured

func ParseQuantityFromUnstructured(u unstructured.Unstructured, compiled *jsonpath.CompiledJSONPath) (resource.Quantity, error)

func ParseUsageFromUnstructured

func ParseUsageFromUnstructured(u unstructured.Unstructured, compiled *jsonpath.CompiledJSONPath) (string, error)

GetUsageFromUnstructured extracts a value from an unstructured object using a JSONPath source path. It is convenient for one-off calls. For repeated calls with the same sourcePath, prefer CompileUsageJSONPath(...) and then Execute(...) to avoid reparsing.

func QuantityEqual added in v0.13.5

func QuantityEqual(a, b resource.Quantity) bool

func ValidateHardLimit added in v0.14.0

func ValidateHardLimit(path string, hard, allocated corev1.ResourceList) error

ValidateHardLimit rejects removal or reduction of a hard resource below an already allocated quantity. Path identifies the hard-limit field in the returned validation error.

func ValidateHardLimitScopeChange added in v0.14.0

func ValidateHardLimitScopeChange(
	path string,
	hard corev1.ResourceList,
	previous corev1.ResourceList,
	scopeChanged bool,
) error

ValidateHardLimitScopeChange prevents a quota from reducing or removing a hard limit in the same update that changes its namespace selection. Usage from newly selected namespaces is not represented by the quota's previous status yet, so the scope must reconcile before a safe lower bound is known.

func ValidateQuantity

func ValidateQuantity(q resource.Quantity) error

Types

type MatchedQuota

type MatchedQuota struct {
	Key          string
	Name         string
	Namespace    string
	Path         string
	CompiledPath *jsonpath.CompiledJSONPath
	CEL          string
	CompiledCEL  *celruntime.CompiledExpression
	Operation    Operation
	Limit        resource.Quantity
	Used         resource.Quantity
	IsGlobal     bool
	SourceRank   int
}

Overlay for Global/Namespace CustomQuotas.

type Operation

type Operation string

+kubebuilder:validation:Enum=add;sub;count

const (
	OpAdd   Operation = "add"
	OpSub   Operation = "sub"
	OpCount Operation = "count"
)

Jump to

Keyboard shortcuts

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