validator

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2022 License: Apache-2.0 Imports: 16 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewValidator

func NewValidator(opts Options) rules.Validator

NewValidator creates a new validator.

Types

type Configuration

type Configuration struct {
	Namespace                        namespaceValidatorConfiguration    `yaml:"namespace"`
	RequiredRollupTags               []string                           `yaml:"requiredRollupTags"`
	MaxTransformationDerivativeOrder *int                               `yaml:"maxTransformationDerivativeOrder"`
	MaxRollupLevels                  *int                               `yaml:"maxRollupLevels"`
	MetricTypes                      metricTypesValidationConfiguration `yaml:"metricTypes"`
	Policies                         policiesValidationConfiguration    `yaml:"policies"`
	TagNameInvalidChars              string                             `yaml:"tagNameInvalidChars"`
	FilterInvalidTagNames            []string                           `yaml:"filterInvalidTagNames"`
	MetricNameInvalidChars           string                             `yaml:"metricNameInvalidChars"`
}

Configuration is the configuration for rules validation.

func (Configuration) NewValidator

func (c Configuration) NewValidator(
	kvClient client.Client,
) (rules.Validator, error)

NewValidator creates a new rules validator based on the given configuration.

type MetricTypesFn

type MetricTypesFn func(tagFilters filters.TagFilterValueMap) ([]metric.Type, error)

MetricTypesFn determines the possible metric types based on a set of tag based filters.

type Options

type Options interface {
	// SetNamespaceValidator sets the namespace validator.
	SetNamespaceValidator(value namespace.Validator) Options

	// NamespaceValidator returns the namespace validator.
	NamespaceValidator() namespace.Validator

	// SetDefaultAllowedStoragePolicies sets the default list of allowed storage policies.
	SetDefaultAllowedStoragePolicies(value []policy.StoragePolicy) Options

	// SetDefaultAllowedFirstLevelAggregationTypes sets the default list of allowed first-level
	// aggregation types.
	SetDefaultAllowedFirstLevelAggregationTypes(value aggregation.Types) Options

	// SetDefaultAllowedNonFirstLevelAggregationTypes sets the default list of allowed
	// non-first-level aggregation types.
	SetDefaultAllowedNonFirstLevelAggregationTypes(value aggregation.Types) Options

	// SetAllowedStoragePoliciesFor sets the list of allowed storage policies for a given metric type.
	SetAllowedStoragePoliciesFor(t metric.Type, policies []policy.StoragePolicy) Options

	// SetAllowedFirstLevelAggregationTypesFor sets the list of allowed first-level aggregation
	// types for a given metric type.
	SetAllowedFirstLevelAggregationTypesFor(t metric.Type, aggTypes aggregation.Types) Options

	// SetAllowedNonFirstLevelAggregationTypesFor sets the list of allowed non-first-level
	// aggregation types for a given metric type.
	SetAllowedNonFirstLevelAggregationTypesFor(t metric.Type, aggTypes aggregation.Types) Options

	// SetMetricTypesFn sets the metric types function.
	SetMetricTypesFn(value MetricTypesFn) Options

	// MetricTypesFn returns the metric types function.
	MetricTypesFn() MetricTypesFn

	// SetMultiAggregationTypesEnabledFor sets the list of metric types that support
	// multiple aggregation types.
	SetMultiAggregationTypesEnabledFor(value []metric.Type) Options

	// SetRequiredRollupTags sets the list of required rollup tags.
	SetRequiredRollupTags(value []string) Options

	// RequiredRollupTags returns the list of required rollup tags.
	RequiredRollupTags() []string

	// SetMaxTransformationDerivativeOrder sets the maximum supported transformation
	// derivative order between rollup operations in pipelines.
	SetMaxTransformationDerivativeOrder(value int) Options

	// MaxTransformationDerivativeOrder returns the maximum supported transformation
	// derivative order between rollup operations in pipelines..
	MaxTransformationDerivativeOrder() int

	// SetMaxRollupLevels sets the maximum number of rollup operations supported in pipelines.
	SetMaxRollupLevels(value int) Options

	// MaxRollupLevels returns the maximum number of rollup operations supported in pipelines.
	MaxRollupLevels() int

	// SetTagNameInvalidChars sets the list of invalid chars for a tag name.
	SetTagNameInvalidChars(value []rune) Options

	// CheckInvalidCharactersForTagName checks if the given tag name contains invalid characters
	// returning an error if invalid character(s) present.
	CheckInvalidCharactersForTagName(tagName string) error

	// SetFiltersInvalidTagNames sets a list of case-insensitive tags that will
	// cause metric filters to be rejected.
	SetFilterInvalidTagNames(tagNames []string) Options

	// CheckFilterTagNameValid returns an error if the given tag name is in the list of
	// invalid tags.
	CheckFilterTagNameValid(tagName string) error

	// SetMetricNameInvalidChars sets the list of invalid chars for a metric name.
	SetMetricNameInvalidChars(value []rune) Options

	// CheckInvalidCharactersForMetricName checks if the given metric name contains invalid characters
	// returning an error if invalid character(s) present.
	CheckInvalidCharactersForMetricName(metricName string) error

	// IsAllowedStoragePolicyFor determines whether a given storage policy is allowed for the
	// given metric type.
	IsAllowedStoragePolicyFor(t metric.Type, p policy.StoragePolicy) bool

	// IsMultiAggregationTypesEnabledFor checks if a metric type supports multiple aggregation types.
	IsMultiAggregationTypesEnabledFor(t metric.Type) bool

	// IsAllowedFirstLevelAggregationTypeFor determines whether a given aggregation type is allowed
	// as the first-level aggregation for the given metric type.
	IsAllowedFirstLevelAggregationTypeFor(t metric.Type, aggType aggregation.Type) bool

	// IsAllowedNonFirstLevelAggregationTypeFor determines whether a given aggregation type is
	// allowed as the non-first-level aggregation for the given metric type.
	IsAllowedNonFirstLevelAggregationTypeFor(t metric.Type, aggType aggregation.Type) bool
}

Options provide a set of options for the validator.

func NewOptions

func NewOptions() Options

NewOptions create a new set of validator options.

Directories

Path Synopsis
kv

Jump to

Keyboard shortcuts

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