schema

package
v0.35.1 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Directory = "_schemas"
	URLScheme = "cerbos"
)

Variables

This section is empty.

Functions

func ReadSchema added in v0.14.0

func ReadSchema(src io.Reader, id string) (*schemav1.Schema, error)

ReadSchema reads a schema from the given reader.

func ReadSchemaFromFile added in v0.14.0

func ReadSchemaFromFile(fsys fs.FS, path string) (*schemav1.Schema, error)

Types

type Conf

type Conf struct {
	// Enforcement defines level of the validations. Possible values are none, warn, reject.
	Enforcement Enforcement `yaml:"enforcement" conf:",example=reject"`
	// CacheSize defines the number of schemas to cache in memory.
	CacheSize uint `yaml:"cacheSize" conf:",example=1024"`
}

Conf is optional configuration for schema validation.

func GetConf added in v0.15.0

func GetConf() (*Conf, error)

func NewConf added in v0.14.0

func NewConf(enforcement Enforcement) *Conf

func (*Conf) Key

func (c *Conf) Key() string

func (*Conf) SetDefaults

func (c *Conf) SetDefaults()

type Enforcement

type Enforcement string

Enforcement level for schema validation.

const (
	EnforcementNone   Enforcement = "none"   // No enforcement made.
	EnforcementWarn   Enforcement = "warn"   // In case schema is not validated, display a warning.
	EnforcementReject Enforcement = "reject" // In case schema is not validated, reject.
)

type ErrSource

type ErrSource string
const (
	ErrSourcePrincipal ErrSource = "P.attr"
	ErrSourceResource  ErrSource = "R.attr"
)

type Loader

type Loader interface {
	LoadSchema(context.Context, string) (io.ReadCloser, error)
}

type Manager

type Manager interface {
	ValidateCheckInput(context.Context, *policyv1.Schemas, *enginev1.CheckInput) (*ValidationResult, error)
	ValidatePlanResourcesInput(context.Context, *policyv1.Schemas, *enginev1.PlanResourcesInput) (*ValidationResult, error)
	CheckSchema(context.Context, string) error
}

func New

func New(ctx context.Context, loader Loader) (Manager, error)

func NewFromConf added in v0.15.0

func NewFromConf(_ context.Context, loader Loader, conf *Conf) Manager

type NopManager

type NopManager struct{}

func NewNopManager

func NewNopManager() NopManager

func (NopManager) CheckSchema

func (NopManager) CheckSchema(_ context.Context, _ string) error

func (NopManager) ValidateCheckInput added in v0.19.0

func (NopManager) ValidatePlanResourcesInput added in v0.19.0

func (NopManager) ValidatePlanResourcesInput(_ context.Context, _ *policyv1.Schemas, _ *enginev1.PlanResourcesInput) (*ValidationResult, error)

type ValidationError

type ValidationError struct {
	Path    string
	Message string
	Source  ErrSource
}

func (ValidationError) Error

func (e ValidationError) Error() string

type ValidationErrorList

type ValidationErrorList []ValidationError

func (ValidationErrorList) ErrOrNil

func (e ValidationErrorList) ErrOrNil() error

func (ValidationErrorList) Error

func (e ValidationErrorList) Error() string

func (ValidationErrorList) ErrorMessages

func (e ValidationErrorList) ErrorMessages() []string

func (ValidationErrorList) SchemaErrors

func (e ValidationErrorList) SchemaErrors() []*schemav1.ValidationError

type ValidationResult

type ValidationResult struct {
	Errors ValidationErrorList
	Reject bool
}

Jump to

Keyboard shortcuts

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