validate

package
v1.18.0-rc.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2026 License: Apache-2.0 Imports: 21 Imported by: 0

Documentation

Overview

Package validate provides CRD-based validation for Dapr resources in standalone mode. It parses the embedded CRD YAML, builds a structural schema, and validates resources against both OpenAPI schema constraints (enum, minLength, minItems, required, etc.) and CEL XValidation rules. This gives standalone mode the same validation the Kubernetes API server provides via CRD admission.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MCPServer

func MCPServer(ctx context.Context, server *mcpserverapi.MCPServer) error

MCPServer validates an MCPServer against the CEL rules and schema constraints embedded in the CRD. This provides the same validation in standalone mode that the Kubernetes API server provides via CRD admission.

func MCPServerSecurity

func MCPServerSecurity(server *mcpserverapi.MCPServer, kubernetesMode bool) error

MCPServerSecurity validates security-sensitive fields on an MCPServer. Called after CEL validation. Rejects unsafe configurations that the schema alone cannot catch.

func WorkflowAccessPolicy

func WorkflowAccessPolicy(ctx context.Context, policy *wfaclapi.WorkflowAccessPolicy) error

WorkflowAccessPolicy validates a WorkflowAccessPolicy against the OpenAPI schema and CEL rules embedded in the CRD. This provides the same validation in standalone mode that the Kubernetes API server provides via CRD admission.

Types

type Validator

type Validator struct {
	// contains filtered or unexported fields
}

Validator validates resources against the OpenAPI schema and CEL rules embedded in a CRD YAML. It is safe for concurrent use.

func NewValidator

func NewValidator(name string, crdYAML []byte) *Validator

NewValidator creates a Validator that will lazily parse the given CRD YAML on first use. The name is used for log messages.

func (*Validator) Validate

func (v *Validator) Validate(ctx context.Context, resource any) error

Validate checks the given resource against both the CRD's OpenAPI schema constraints (enum, minLength, minItems, required, etc.) and any CEL XValidation rules. The resource must be JSON-serializable. Returns nil if valid. The context is passed to CEL validation so callers can cancel long-running validation work (e.g. during shutdown or hot-reload storms).

Jump to

Keyboard shortcuts

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