generic

package
v0.19.2-0...-3168bd4 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2017 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CalculateUsageStats

func CalculateUsageStats(options quota.UsageStatsOptions,
	listFunc ListFuncByNamespace,
	scopeFunc MatchesScopeFunc,
	usageFunc UsageFunc) (quota.UsageStats, error)

CalculateUsageStats is a utility function that knows how to calculate aggregate usage.

func Matches

func Matches(resourceQuota *api.ResourceQuota, item runtime.Object, matchFunc MatchingResourceNamesFunc, scopeFunc MatchesScopeFunc) (bool, error)

Matches returns true if the quota matches the specified item.

func MatchesNoScopeFunc

func MatchesNoScopeFunc(scope api.ResourceQuotaScope, object runtime.Object) (bool, error)

MatchesNoScopeFunc returns false on all match checks

Types

type GenericRegistry

type GenericRegistry struct {
	// internal evaluators by group kind
	InternalEvaluators map[schema.GroupKind]quota.Evaluator
}

GenericRegistry implements Registry

func (*GenericRegistry) Evaluators

func (r *GenericRegistry) Evaluators() map[schema.GroupKind]quota.Evaluator

Evaluators returns the map of evaluators by groupKind

type ListFuncByNamespace

type ListFuncByNamespace func(namespace string, options metav1.ListOptions) ([]runtime.Object, error)

ListFuncByNamespace knows how to list resources in a namespace

func ListResourceUsingInformerFunc

func ListResourceUsingInformerFunc(f informers.SharedInformerFactory, resource schema.GroupVersionResource) ListFuncByNamespace

ListResourceUsingInformerFunc returns a listing function based on the shared informer factory for the specified resource.

type MatchesScopeFunc

type MatchesScopeFunc func(scope api.ResourceQuotaScope, object runtime.Object) (bool, error)

MatchesScopeFunc knows how to evaluate if an object matches a scope

type MatchingResourceNamesFunc

type MatchingResourceNamesFunc func(input []api.ResourceName) []api.ResourceName

MatchingResourceNamesFunc is a function that returns the list of resources matched

type ObjectCountEvaluator

type ObjectCountEvaluator struct {
	// AllowCreateOnUpdate if true will ensure the evaluator tracks create
	// and update operations.
	AllowCreateOnUpdate bool
	// GroupKind that this evaluator tracks.
	InternalGroupKind schema.GroupKind
	// A function that knows how to list resources by namespace.
	// TODO move to dynamic client in future
	ListFuncByNamespace ListFuncByNamespace
	// Name associated with this resource in the quota.
	ResourceName api.ResourceName
}

ObjectCountEvaluator provides an implementation for quota.Evaluator that associates usage of the specified resource based on the number of items returned by the specified listing function.

func (*ObjectCountEvaluator) Constraints

func (o *ObjectCountEvaluator) Constraints(required []api.ResourceName, item runtime.Object) error

Constraints returns an error if the configured resource name is not in the required set.

func (*ObjectCountEvaluator) GroupKind

func (o *ObjectCountEvaluator) GroupKind() schema.GroupKind

GroupKind that this evaluator tracks

func (*ObjectCountEvaluator) Handles

Handles returns true if the object count evaluator needs to track this attributes.

func (*ObjectCountEvaluator) Matches

func (o *ObjectCountEvaluator) Matches(resourceQuota *api.ResourceQuota, item runtime.Object) (bool, error)

Matches returns true if the evaluator matches the specified quota with the provided input item

func (*ObjectCountEvaluator) MatchingResources

func (o *ObjectCountEvaluator) MatchingResources(input []api.ResourceName) []api.ResourceName

MatchingResources takes the input specified list of resources and returns the set of resources it matches.

func (*ObjectCountEvaluator) Usage

Usage returns the resource usage for the specified object

func (*ObjectCountEvaluator) UsageStats

UsageStats calculates aggregate usage for the object.

type UsageFunc

type UsageFunc func(object runtime.Object) (api.ResourceList, error)

UsageFunc knows how to measure usage associated with an object

Jump to

Keyboard shortcuts

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