validation

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2021 License: Apache-2.0 Imports: 11 Imported by: 4

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)

loadSchema returns spec.Schema object loaded from yaml bytes.

func PrepareSchemas

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

Types

type SchemaStorage

type SchemaStorage struct {
	GlobalSchemas map[SchemaType]*spec.Schema
	ModuleSchemas map[string]map[SchemaType]*spec.Schema
}

func NewSchemaStorage

func NewSchemaStorage() *SchemaStorage

func (*SchemaStorage) AddGlobalValuesSchemas

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

AddGlobalValuesSchemas prepares and stores three schemas: config, config+values, config+values+required.

func (*SchemaStorage) AddModuleValuesSchemas

func (st *SchemaStorage) AddModuleValuesSchemas(moduleName string, configBytes, valuesBytes []byte) error

schemaType is "config" of "memory"

func (*SchemaStorage) GlobalValuesSchema

func (st *SchemaStorage) GlobalValuesSchema(schemaType SchemaType) *spec.Schema

GetGlobalValuesSchema returns ready-to-use schema for global values. schemaType is "config", "values" or "helm"

func (*SchemaStorage) ModuleValuesSchema

func (st *SchemaStorage) ModuleValuesSchema(moduleName string, schemaType SchemaType) *spec.Schema

GetModuleValuesSchema returns ready-to-use schema for module values. schemaType is "config" of "values"

type SchemaType

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

type ValuesValidator

type ValuesValidator struct {
	SchemaStorage *SchemaStorage
}

func NewValuesValidator

func NewValuesValidator() *ValuesValidator

func (*ValuesValidator) ValidateGlobalConfigValues

func (v *ValuesValidator) ValidateGlobalConfigValues(values utils.Values) error

func (*ValuesValidator) ValidateGlobalValues

func (v *ValuesValidator) ValidateGlobalValues(values utils.Values) error

func (*ValuesValidator) ValidateModuleConfigValues

func (v *ValuesValidator) ValidateModuleConfigValues(moduleName string, values utils.Values) error

func (*ValuesValidator) ValidateModuleHelmValues

func (v *ValuesValidator) ValidateModuleHelmValues(moduleName string, values utils.Values) (multiErr error)

func (*ValuesValidator) ValidateModuleValues

func (v *ValuesValidator) ValidateModuleValues(moduleName string, values utils.Values) (multiErr error)

func (*ValuesValidator) ValidateValues

func (v *ValuesValidator) ValidateValues(schemaType SchemaType, valuesType SchemaType, moduleName string, values utils.Values) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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