validation

package
v0.14.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var File_pkg_internal_approver_validation_certificaterequest_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Cache

type Cache interface {
	// Get returns a compiled validator for the supplied CEL expression.
	// Any compilation errors will be returned to the caller.
	//
	// The supplied CEL expression must output a bool.
	Get(expr string) (Validator, error)
}

Cache maintains a cache of compiled validators. The current implementation is a simple lazy cache meaning:

1. Whenever a validator is requested, it first checks the cache. 2. If a compiled validator exists for the supplied CEL expression, it is returned. 3. If the validator doesn't exist in the cache, a new validator is created, compiled, added to the cache, and returned.

func NewCache

func NewCache() Cache

NewCache is a constructor for cache of compiled CEL expression validators.

type CertificateRequest

type CertificateRequest struct {
	Name      string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
	Namespace string `protobuf:"bytes,2,opt,name=namespace,proto3" json:"namespace,omitempty"`
	// contains filtered or unexported fields
}

func (*CertificateRequest) Descriptor deprecated

func (*CertificateRequest) Descriptor() ([]byte, []int)

Deprecated: Use CertificateRequest.ProtoReflect.Descriptor instead.

func (*CertificateRequest) GetName

func (x *CertificateRequest) GetName() string

func (*CertificateRequest) GetNamespace

func (x *CertificateRequest) GetNamespace() string

func (*CertificateRequest) ProtoMessage

func (*CertificateRequest) ProtoMessage()

func (*CertificateRequest) ProtoReflect

func (x *CertificateRequest) ProtoReflect() protoreflect.Message

func (*CertificateRequest) Reset

func (x *CertificateRequest) Reset()

func (*CertificateRequest) String

func (x *CertificateRequest) String() string

type Validator

type Validator interface {
	// Validate validates the supplied value against the Validator CEL
	// expression in the context of the request.
	// Returns 'true' if the value is valid (passes validation).
	// Returned errors should be considered as internal/technical errors,
	// and should NOT be returned unprocessed to end-users of the API.
	// CEL program errors are usually not very human-readable and require
	// knowledge of how CEL works and is used.
	Validate(value string, request cmapi.CertificateRequest) (bool, error)
}

Validator knows how to validate CSR attribute values in CertificateRequests against CEL expressions declared in CertificateRequestPolicy. Validator is stateless, thread-safe, and cacheable.

Jump to

Keyboard shortcuts

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