Documentation ¶
Index ¶
- func EvaluateRule(value resource.Quantity, rule telempol.TASPolicyRule) bool
- type AddStrategyInvocation
- type Enforceable
- type Enforcer
- type Interface
- type MetricEnforcer
- func (e *MetricEnforcer) AddStrategy(str Interface, strategyType string)
- func (e *MetricEnforcer) EnforceRegisteredStrategies(cache cache.Reader, timer time.Ticker)
- func (e *MetricEnforcer) IsRegistered(str string) bool
- func (e *MetricEnforcer) RegisterStrategyType(str Interface)
- func (e *MetricEnforcer) RegisteredStrategyTypes() []string
- func (e *MetricEnforcer) RemoveStrategy(str Interface, strategyType string)
- func (e *MetricEnforcer) UnregisterStrategyType(str Interface)
- type MockStrategy
- func (v *MockStrategy) AddStrategy(i Interface, s string)
- func (v *MockStrategy) Clean(*MetricEnforcer, string) error
- func (v *MockStrategy) Enforce(_ *MetricEnforcer, _ cache.Reader) (int, error)
- func (v *MockStrategy) EnforceRegisteredStrategies(cache.Reader, time.Ticker)
- func (v *MockStrategy) Equals(o Interface) bool
- func (v *MockStrategy) GetPolicyName() string
- func (v *MockStrategy) IsRegistered(strategy string) bool
- func (v *MockStrategy) RegisterStrategyType(strategy Interface)
- func (v *MockStrategy) RemoveStrategy(_ Interface, _ string)
- func (v *MockStrategy) SetPolicyName(string)
- func (v *MockStrategy) StrategyType() string
- func (v *MockStrategy) UnregisterStrategyType(Interface)
- func (v *MockStrategy) Violated(_ cache.Reader) map[string]interface{}
- type NodeSortableMetric
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvaluateRule ¶
func EvaluateRule(value resource.Quantity, rule telempol.TASPolicyRule) bool
EvaluateRule returns a boolean after implementing the function described in the TASPolicyRule. The rule is transformed into a function inside of the method.
Types ¶
type AddStrategyInvocation ¶ added in v0.3.0
type AddStrategyInvocation struct { I interface{} // contains filtered or unexported fields }
AddStrategyInvocation is used to test the times that AddStrategy is called.
type Enforceable ¶
type Enforceable interface { Enforce(enforcer *MetricEnforcer, cache cache.Reader) (int, error) Cleanup(enforcer *MetricEnforcer, policyName string) error }
Enforceable enforce strategies and clean up after strategies are removed.
type Enforcer ¶
type Enforcer interface { RegisterStrategyType(strategy Interface) UnregisterStrategyType(strategy Interface) IsRegistered(strategy string) bool AddStrategy(strategy Interface, strategyType string) RemoveStrategy(strategy Interface, strategyType string) EnforceRegisteredStrategies(cache cache.Reader, ticker time.Ticker) }
Enforcer registers strategies by type, adds specific strategies to a registry, and Enforces those strategies.
type Interface ¶
type Interface interface { Violated(cache cache.Reader) map[string]interface{} StrategyType() string Equals(obj Interface) bool GetPolicyName() string SetPolicyName(policyName string) }
Interface describes expected behavior of a specific strategy.
type MetricEnforcer ¶
type MetricEnforcer struct { RegisteredStrategies map[string]map[Interface]interface{} KubeClient kubernetes.Interface sync.RWMutex }
MetricEnforcer instruments behavior to register strategies and trigger their enforcement actions.
func NewEnforcer ¶
func NewEnforcer(kubeClient kubernetes.Interface) *MetricEnforcer
NewEnforcer returns an enforcer with the passed arguments and an empty strategy store.
func (*MetricEnforcer) AddStrategy ¶
func (e *MetricEnforcer) AddStrategy(str Interface, strategyType string)
AddStrategy includes the specific strategy under its type in the strategy registry.
func (*MetricEnforcer) EnforceRegisteredStrategies ¶
func (e *MetricEnforcer) EnforceRegisteredStrategies(cache cache.Reader, timer time.Ticker)
EnforceRegisteredStrategies runs periodically, enforcing each of the registered strategy types in the registry.
func (*MetricEnforcer) IsRegistered ¶
func (e *MetricEnforcer) IsRegistered(str string) bool
IsRegistered checks to see if a passed strategy is already being enforced.
func (*MetricEnforcer) RegisterStrategyType ¶
func (e *MetricEnforcer) RegisterStrategyType(str Interface)
RegisterStrategyType adds the type of strategy as top level entry in the registry.
func (*MetricEnforcer) RegisteredStrategyTypes ¶
func (e *MetricEnforcer) RegisteredStrategyTypes() []string
RegisteredStrategyTypes returns a slice of the names of strategy types currently registered with the enforcer.
func (*MetricEnforcer) RemoveStrategy ¶
func (e *MetricEnforcer) RemoveStrategy(str Interface, strategyType string)
RemoveStrategy will take a strategy out of the enforcer if it's currently registered.
func (*MetricEnforcer) UnregisterStrategyType ¶
func (e *MetricEnforcer) UnregisterStrategyType(str Interface)
UnregisterStrategyType removes the passed strategy from the registry if it exists there. If it doesn't exist it fails silently.
type MockStrategy ¶
type MockStrategy struct { StrategyTypeMock string RegisteredStrategies map[string]map[Interface]interface{} AddedStrategies AddStrategyInvocation RemovedStrategies interface{} }
MockStrategy is used in the tests for the core and other packages.
func (*MockStrategy) AddStrategy ¶ added in v0.3.0
func (v *MockStrategy) AddStrategy(i Interface, s string)
AddStrategy is a method in Mock strategy.
func (*MockStrategy) Clean ¶ added in v0.3.0
func (v *MockStrategy) Clean(*MetricEnforcer, string) error
Clean returns nil error.
func (*MockStrategy) Enforce ¶
func (v *MockStrategy) Enforce(_ *MetricEnforcer, _ cache.Reader) (int, error)
Enforce returns 0 value and nil error.
func (*MockStrategy) EnforceRegisteredStrategies ¶ added in v0.3.0
func (v *MockStrategy) EnforceRegisteredStrategies(cache.Reader, time.Ticker)
EnforceRegisteredStrategies is a method in Mock strategy.
func (*MockStrategy) Equals ¶
func (v *MockStrategy) Equals(o Interface) bool
Equals returns the value of checking if the strategy types are the same.
func (*MockStrategy) GetPolicyName ¶
func (v *MockStrategy) GetPolicyName() string
GetPolicyName gets the mock strategy policy name.
func (*MockStrategy) IsRegistered ¶ added in v0.3.0
func (v *MockStrategy) IsRegistered(strategy string) bool
IsRegistered is a method in Mock strategy.
func (*MockStrategy) RegisterStrategyType ¶ added in v0.3.0
func (v *MockStrategy) RegisterStrategyType(strategy Interface)
RegisterStrategyType is a method in Mock strategy.
func (*MockStrategy) RemoveStrategy ¶ added in v0.3.0
func (v *MockStrategy) RemoveStrategy(_ Interface, _ string)
RemoveStrategy is a method in Mock strategy.
func (*MockStrategy) SetPolicyName ¶
func (v *MockStrategy) SetPolicyName(string)
SetPolicyName sets the policy name of the mock strategy.
func (*MockStrategy) StrategyType ¶
func (v *MockStrategy) StrategyType() string
StrategyType returns the Strategy type of the mock.
func (*MockStrategy) UnregisterStrategyType ¶ added in v0.3.0
func (v *MockStrategy) UnregisterStrategyType(Interface)
UnregisterStrategyType is a method in Mock strategy.
type NodeSortableMetric ¶
NodeSortableMetric type is necessary in order to call the sort.Slice method. Note lack of usage of time windows or stamps.
func OrderedList ¶
func OrderedList(metricsInfo metrics.NodeMetricsInfo, operator string) []NodeSortableMetric
OrderedList will return a list of nodes ordered by their linked metric and operator. TODO: Make this method more generic so it can use objects other than nodes.