Documentation ¶
Index ¶
- func Add(a api.ResourceList, b api.ResourceList) api.ResourceList
- func CalculateUsage(namespaceName string, scopes []api.ResourceQuotaScope, ...) (api.ResourceList, error)
- func Contains(items []api.ResourceName, item api.ResourceName) bool
- func Equals(a api.ResourceList, b api.ResourceList) bool
- func Intersection(a []api.ResourceName, b []api.ResourceName) []api.ResourceName
- func IsNegative(a api.ResourceList) []api.ResourceName
- func IsZero(a api.ResourceList) bool
- func LessThanOrEqual(a api.ResourceList, b api.ResourceList) (bool, []api.ResourceName)
- func Mask(resources api.ResourceList, names []api.ResourceName) api.ResourceList
- func Max(a api.ResourceList, b api.ResourceList) api.ResourceList
- func ResourceNames(resources api.ResourceList) []api.ResourceName
- func Subtract(a api.ResourceList, b api.ResourceList) api.ResourceList
- func SubtractWithNonNegativeResult(a api.ResourceList, b api.ResourceList) api.ResourceList
- func ToSet(resourceNames []api.ResourceName) sets.String
- func V1Equals(a v1.ResourceList, b v1.ResourceList) bool
- type Evaluator
- type Registry
- type UnionRegistry
- type UsageStats
- type UsageStatsOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Add ¶
func Add(a api.ResourceList, b api.ResourceList) api.ResourceList
Add returns the result of a + b for each named resource
func CalculateUsage ¶ added in v1.4.1
func CalculateUsage(namespaceName string, scopes []api.ResourceQuotaScope, hardLimits api.ResourceList, registry Registry) (api.ResourceList, error)
CalculateUsage calculates and returns the requested ResourceList usage
func Contains ¶
func Contains(items []api.ResourceName, item api.ResourceName) bool
Contains returns true if the specified item is in the list of items
func Equals ¶
func Equals(a api.ResourceList, b api.ResourceList) bool
Equals returns true if the two lists are equivalent
func Intersection ¶
func Intersection(a []api.ResourceName, b []api.ResourceName) []api.ResourceName
Intersection returns the intersection of both list of resources
func IsNegative ¶ added in v1.4.1
func IsNegative(a api.ResourceList) []api.ResourceName
IsNegative returns the set of resource names that have a negative value.
func IsZero ¶
func IsZero(a api.ResourceList) bool
IsZero returns true if each key maps to the quantity value 0
func LessThanOrEqual ¶
func LessThanOrEqual(a api.ResourceList, b api.ResourceList) (bool, []api.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 api.ResourceList, names []api.ResourceName) api.ResourceList
Mask returns a new resource list that only has the values with the specified names
func Max ¶ added in v1.4.1
func Max(a api.ResourceList, b api.ResourceList) api.ResourceList
Max returns the result of Max(a, b) for each named resource
func ResourceNames ¶
func ResourceNames(resources api.ResourceList) []api.ResourceName
ResourceNames returns a list of all resource names in the ResourceList
func Subtract ¶
func Subtract(a api.ResourceList, b api.ResourceList) api.ResourceList
Subtract returns the result of a - b for each named resource
func SubtractWithNonNegativeResult ¶ added in v1.8.0
func SubtractWithNonNegativeResult(a api.ResourceList, b api.ResourceList) api.ResourceList
SubtractWithNonNegativeResult - substracts 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 []api.ResourceName) sets.String
ToSet takes a list of resource names and converts to a string set
func V1Equals ¶ added in v1.6.0
func V1Equals(a v1.ResourceList, b v1.ResourceList) bool
V1Equals returns true if the two lists are equivalent
Types ¶
type Evaluator ¶
type Evaluator interface { // Constraints ensures that each required resource is present on item Constraints(required []api.ResourceName, item runtime.Object) error // GroupKind returns the groupKind that this object knows how to evaluate GroupKind() schema.GroupKind // Handles determines if quota could be impacted by the specified attribute. // If true, admission control must perform quota processing for the operation, otherwise it is safe to ignore quota. Handles(operation admission.Attributes) bool // Matches returns true if the specified quota matches the input item Matches(resourceQuota *api.ResourceQuota, item runtime.Object) (bool, error) // MatchingResources takes the input specified list of resources and returns the set of resources evaluator matches. MatchingResources(input []api.ResourceName) []api.ResourceName // Usage returns the resource usage for the specified object Usage(item runtime.Object) (api.ResourceList, error) // UsageStats calculates latest observed usage stats for all objects UsageStats(options UsageStatsOptions) (UsageStats, error) }
Evaluator knows how to evaluate quota usage for a particular group kind
type Registry ¶
type Registry interface { // Evaluators returns the set Evaluator objects registered to a groupKind Evaluators() map[schema.GroupKind]Evaluator }
Registry holds the list of evaluators associated to a particular group kind
type UnionRegistry ¶ added in v1.4.1
type UnionRegistry []Registry
UnionRegistry combines multiple registries. Order matters because first registry to claim a GroupKind is the "winner"
func (UnionRegistry) Evaluators ¶ added in v1.4.1
func (r UnionRegistry) Evaluators() map[schema.GroupKind]Evaluator
Evaluators returns a mapping of evaluators by group kind.
type UsageStats ¶
type UsageStats struct { // Used maps resource to quantity used Used api.ResourceList }
UsageStats is result of measuring observed resource use in the system
type UsageStatsOptions ¶
type UsageStatsOptions struct { // Namespace where stats should be calculate Namespace string // Scopes that must match counted objects Scopes []api.ResourceQuotaScope // Resources are the set of resources to include in the measurement Resources []api.ResourceName }
UsageStatsOptions is an options structs that describes how stats should be calculated