generic

package
v0.0.0-...-53c5426 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2016 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MatchesNoScopeFunc

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

MatchesNoScopeFunc returns false on all match checks

Types

type ConstraintsFunc

type ConstraintsFunc func(required []api.ResourceName, item runtime.Object) error

ConstraintsFunc takes a list of required resources that must match on the input item

func ObjectCountConstraintsFunc

func ObjectCountConstraintsFunc(resourceName api.ResourceName) ConstraintsFunc

ObjectCountConstraintsFunc returns true if the specified resource name is in the required set of resource names

type GenericEvaluator

type GenericEvaluator struct {
	// Name used for logging
	Name string
	// The GroupKind that this evaluator tracks
	InternalGroupKind unversioned.GroupKind
	// The set of resources that are pertinent to the mapped operation
	InternalOperationResources map[admission.Operation][]api.ResourceName
	// The set of resource names this evaluator matches
	MatchedResourceNames []api.ResourceName
	// A function that knows how to evaluate a matches scope request
	MatchesScopeFunc MatchesScopeFunc
	// A function that knows how to return usage for an object
	UsageFunc UsageFunc
	// A function that knows how to list resources by namespace
	ListFuncByNamespace ListFuncByNamespace
	// A function that knows how to get resource in a namespace
	// This function must be specified if the evaluator needs to handle UPDATE
	GetFuncByNamespace GetFuncByNamespace
	// A function that checks required constraints are satisfied
	ConstraintsFunc ConstraintsFunc
}

GenericEvaluator provides an implementation for quota.Evaluator

func (*GenericEvaluator) Constraints

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

Constraints checks required constraints are satisfied on the input object

func (*GenericEvaluator) Get

func (g *GenericEvaluator) Get(namespace, name string) (runtime.Object, error)

Get returns the object by namespace and name

func (*GenericEvaluator) GroupKind

func (g *GenericEvaluator) GroupKind() unversioned.GroupKind

GroupKind that this evaluator tracks

func (*GenericEvaluator) Matches

func (g *GenericEvaluator) Matches(resourceQuota *api.ResourceQuota, item runtime.Object) bool

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

func (*GenericEvaluator) MatchesResource

func (g *GenericEvaluator) MatchesResource(resourceName api.ResourceName) bool

MatchesResource returns true if this evaluator can match on the specified resource

func (*GenericEvaluator) MatchesResources

func (g *GenericEvaluator) MatchesResources() []api.ResourceName

MatchesResources is the list of resources that this evaluator matches

func (*GenericEvaluator) MatchesScope

func (g *GenericEvaluator) MatchesScope(scope api.ResourceQuotaScope, object runtime.Object) bool

MatchesScope returns true if the input object matches the specified scope

func (*GenericEvaluator) OperationResources

func (g *GenericEvaluator) OperationResources(operation admission.Operation) []api.ResourceName

OperationResources returns the set of resources that could be updated for the specified operation for this kind. If empty, admission control will ignore quota processing for the operation.

func (*GenericEvaluator) Usage

func (g *GenericEvaluator) Usage(object runtime.Object) api.ResourceList

Usage returns the resource usage for the specified object

func (*GenericEvaluator) UsageStats

func (g *GenericEvaluator) UsageStats(options quota.UsageStatsOptions) (quota.UsageStats, error)

UsageStats calculates latest observed usage stats for all objects

type GenericRegistry

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

GenericRegistry implements Registry

func (*GenericRegistry) Evaluators

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

Evaluators returns the map of evaluators by groupKind

type GetFuncByNamespace

type GetFuncByNamespace func(namespace, name string) (runtime.Object, error)

GetFuncByNamespace knows how to get a resource with specified namespace and name

type ListFuncByNamespace

type ListFuncByNamespace func(namespace string, options api.ListOptions) (runtime.Object, error)

ListFuncByNamespace knows how to list resources in a namespace

type MatchesScopeFunc

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

MatchesScopeFunc knows how to evaluate if an object matches a scope

type UsageFunc

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

UsageFunc knows how to measure usage associated with an object

func ObjectCountUsageFunc

func ObjectCountUsageFunc(resourceName api.ResourceName) UsageFunc

ObjectCountUsageFunc is useful if you are only counting your object It always returns 1 as the usage for the named resource

Jump to

Keyboard shortcuts

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