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 ContainsPrefix(prefixSet []string, 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 Configuration
- type Evaluator
- type ListerForResourceFunc
- type Registry
- 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.0
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 ContainsPrefix ¶ added in v1.9.1
func ContainsPrefix(prefixSet []string, item api.ResourceName) bool
ContainsPrefix returns true if the specified item has a prefix that contained in given prefix Set
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.0
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.0
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.1
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.1
func V1Equals(a v1.ResourceList, b v1.ResourceList) bool
V1Equals returns true if the two lists are equivalent
Types ¶
type Configuration ¶ added in v1.9.1
type Configuration interface { // IgnoredResources are ignored by quota. IgnoredResources() map[schema.GroupResource]struct{} // Evaluators for quota evaluation. Evaluators() []Evaluator }
Configuration defines how the quota system is configured.
type Evaluator ¶
type Evaluator interface { // Constraints ensures that each required resource is present on item Constraints(required []api.ResourceName, item runtime.Object) error // GroupResource returns the groupResource that this object knows how to evaluate GroupResource() schema.GroupResource // 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 resource
type ListerForResourceFunc ¶ added in v1.9.1
type ListerForResourceFunc func(schema.GroupVersionResource) (cache.GenericLister, error)
ListerForResourceFunc knows how to get a lister for a specific resource
type Registry ¶
type Registry interface { // Add to registry Add(e Evaluator) // Remove from registry Remove(e Evaluator) // Get by group resource Get(gr schema.GroupResource) Evaluator // List from registry List() []Evaluator }
Registry maintains a list of evaluators
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