Documentation
¶
Index ¶
- Variables
- func ConvertJSONSchemaPropsToSpecSchema(props *extv1.JSONSchemaProps) (*spec.Schema, error)
- func DeepCopySchema(schema *spec.Schema) (*spec.Schema, error)
- func GenerateSchemaFromCELTypes(typeMap map[string]*cel.Type, provider *krocel.DeclTypeProvider) (*extv1.JSONSchemaProps, error)
- func GenerateSchemaFromEvals(evals map[string][]ref.Val) (*extv1.JSONSchemaProps, error)
- type Cache
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidEvaluationTypes is returned when the evaluation types are not valid // for generating a schema. ErrInvalidEvaluationTypes = errors.New("invalid evaluation type") )
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.
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 ¶
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 ¶
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 (*Cache) LookupAdditionalProperties ¶ added in v0.2.0
LookupAdditionalProperties returns a pointer-stable schema for additionalProperties on parent. Returns nil if not present.
func (*Cache) LookupField ¶ added in v0.2.0
LookupField returns a pointer-stable schema for a named property of parent. Returns nil if the field doesn't exist in Properties.