schema

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrInvalidEvaluationTypes is returned when the evaluation types are not valid
	// for generating a schema.
	ErrInvalidEvaluationTypes = errors.New("invalid evaluation type")
)
View Source
var NamespacelessObjectMetaSchema spec.Schema

NamespacelessObjectMetaSchema is ObjectMeta without metadata.namespace. Cluster-scoped instance CRDs use this when building the typed CEL schema for the "schema" variable, so expressions cannot type-check against a field that does not exist at runtime.

View Source
var ObjectMetaSchema spec.Schema

ObjectMeta holds the k8s ObjectMeta schema, populated once at startup.

Functions

func ConvertJSONSchemaPropsToSpecSchema

func ConvertJSONSchemaPropsToSpecSchema(props *extv1.JSONSchemaProps) (*spec.Schema, error)

ConvertJSONSchemaPropsToSpecSchema converts an extv1.JSONSchemaProps to a spec.Schema.

NOTE(a-hilaly): there must be an upstream library that does this conversion, but life is too short to find it. So I'm just going to write this function here.

nolint:gocyclo // TODO(jakobmoellerdev): Revisit and kill this function

func DeepCopySchema

func DeepCopySchema(schema *spec.Schema) (*spec.Schema, error)

DeepCopySchema creates a deep copy of a spec.Schema by marshaling and unmarshaling through JSON. This ensures all nested structures are fully independent of the original.

func GenerateSchemaFromCELTypes

func GenerateSchemaFromCELTypes(typeMap map[string]*cel.Type, provider *krocel.DeclTypeProvider) (*extv1.JSONSchemaProps, error)

GenerateSchemaFromCELTypes generates a JSONSchemaProps from a map of CEL types. The provider is used to recursively introspect struct types and extract all fields.

func GenerateSchemaFromEvals

func GenerateSchemaFromEvals(evals map[string][]ref.Val) (*extv1.JSONSchemaProps, error)

Types

type Cache added in v0.2.0

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

Cache returns pointer-stable *spec.Schema values for child field lookups. OpenAPI Properties maps store schemas by value, so indexing copies the struct and produces a fresh pointer each time. Cache ensures the same (parent, field) pair always returns the same *spec.Schema pointer.

Not safe for concurrent use. Intended to be created per-build and discarded when the build completes.

func NewCache added in v0.2.0

func NewCache() *Cache

NewCache returns a new schema cache.

func (*Cache) LookupAdditionalProperties added in v0.2.0

func (c *Cache) LookupAdditionalProperties(parent *spec.Schema) *spec.Schema

LookupAdditionalProperties returns a pointer-stable schema for additionalProperties on parent. Returns nil if not present.

func (*Cache) LookupField added in v0.2.0

func (c *Cache) LookupField(parent *spec.Schema, field string) *spec.Schema

LookupField returns a pointer-stable schema for a named property of parent. Returns nil if the field doesn't exist in Properties.

func (*Cache) WrapAsList added in v0.2.0

func (c *Cache) WrapAsList(itemSchema *spec.Schema) *spec.Schema

WrapAsList returns a pointer-stable list schema wrapping itemSchema. Same input pointer always returns the same wrapper pointer.

Directories

Path Synopsis
Package resolver provides schema resolution strategies for function-kro.
Package resolver provides schema resolution strategies for function-kro.

Jump to

Keyboard shortcuts

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