validation

package
v1.26.2 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: Apache-2.0 Imports: 20 Imported by: 3 modules, 5 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyDefaults

func ApplyDefaults(obj interface{}, s *spec.Schema) bool

ApplyDefaults traverses an object and apply default values from OpenAPI schema. It returns true if obj is changed.

See https://github.com/kubernetes/kubernetes/blob/cea1d4e20b4a7886d8ff65f34c6d4f95efcb4742/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/schema/defaulting/algorithm.go

Note: check only Properties for object type and List validation for array type.

func LoadSchemaFromBytes

func LoadSchemaFromBytes(openApiContent []byte) (*spec.Schema, error)

LoadSchemaFromBytes returns spec.Schema object loaded from YAML bytes.

func PrepareSchemas

func PrepareSchemas(configBytes, valuesBytes []byte) (map[SchemaType]*spec.Schema, error)

PrepareSchemas loads schemas for config values, values and helm values.

func YAMLBytesToJSONDoc added in v1.1.0

func YAMLBytesToJSONDoc(data []byte) (json.RawMessage, error)

YAMLBytesToJSONDoc is a replacement of swag.YAMLData and YAMLDoc to Unmarshal into interface{}. swag.BytesToYAML uses yaml.MapSlice to unmarshal YAML. This type doesn't support map merge of YAML anchors.

func YAMLDocLoader added in v1.1.0

func YAMLDocLoader(path string, opts ...loading.Option) (json.RawMessage, error)

YAMLDocLoader loads a yaml document from either http or a file and converts it to json.

Types

type SchemaStorage

type SchemaStorage struct {
	Schemas map[SchemaType]*spec.Schema
}

func NewSchemaStorage

func NewSchemaStorage(configBytes, valuesBytes []byte) (*SchemaStorage, error)

func (*SchemaStorage) GlobalSchemasDescription added in v1.0.6

func (st *SchemaStorage) GlobalSchemasDescription() string

GlobalSchemasDescription describes which global schemas are present in storage.

func (*SchemaStorage) InjectRegistrySpec added in v1.12.1

func (st *SchemaStorage) InjectRegistrySpec(schemaType SchemaType)

InjectRegistrySpec mutates the module schema to add a strict-typed "registry" field

func (*SchemaStorage) ModuleSchemasDescription added in v1.0.6

func (st *SchemaStorage) ModuleSchemasDescription() string

ModuleSchemasDescription describes which schemas are present in storage for the module.

func (*SchemaStorage) Validate added in v1.3.13

func (st *SchemaStorage) Validate(valuesType SchemaType, moduleName string, values utils.Values) error

func (*SchemaStorage) ValidateConfigValues added in v1.3.13

func (st *SchemaStorage) ValidateConfigValues(moduleName string, values utils.Values) error

func (*SchemaStorage) ValidateConfigValuesTransition added in v1.20.10

func (st *SchemaStorage) ValidateConfigValuesTransition(moduleName string, values, oldValues utils.Values) error

ValidateConfigValuesTransition is like ValidateConfigValues, but additionally accepts the previously stored config values so that x-deckhouse-validations transition rules (rules that reference oldSelf) can fire on updates. Pass oldValues=nil for the initial create / when previous values are not available.

func (*SchemaStorage) ValidateModuleHelmValues added in v1.3.13

func (st *SchemaStorage) ValidateModuleHelmValues(moduleName string, values utils.Values) error

func (*SchemaStorage) ValidateModuleHelmValuesTransition added in v1.20.10

func (st *SchemaStorage) ValidateModuleHelmValuesTransition(moduleName string, values, oldValues utils.Values) error

ValidateModuleHelmValuesTransition is like ValidateModuleHelmValues, but additionally accepts the previously rendered helm values so that x-deckhouse-validations transition rules (rules that reference oldSelf) can fire on updates.

func (*SchemaStorage) ValidateTransition added in v1.20.10

func (st *SchemaStorage) ValidateTransition(valuesType SchemaType, moduleName string, values, oldValues utils.Values) error

ValidateTransition is like Validate but additionally accepts the previously stored values, enabling x-deckhouse-validations transition rules (rules that reference oldSelf) to fire on updates. Pass oldValues=nil for the initial create / when previous values are not available.

func (*SchemaStorage) ValidateValues added in v1.3.13

func (st *SchemaStorage) ValidateValues(moduleName string, values utils.Values) error

func (*SchemaStorage) ValidateValuesTransition added in v1.20.10

func (st *SchemaStorage) ValidateValuesTransition(moduleName string, values, oldValues utils.Values) error

ValidateValuesTransition is like ValidateValues, but additionally accepts the previously merged result values so that x-deckhouse-validations transition rules (rules that reference oldSelf) can catch attempts to mutate immutable fields via values patches. Pass oldValues=nil for the initial create / when previous values are not available.

type SchemaType

type SchemaType string
const (
	GlobalSchema       SchemaType = "global"
	ModuleSchema       SchemaType = "module"
	ConfigValuesSchema SchemaType = "config"
	ValuesSchema       SchemaType = "values"
	HelmValuesSchema   SchemaType = "helm"
)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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