Documentation
¶
Index ¶
- func IsWorkloadResourceKind(kind string) bool
- func ValidateAllowedTraits(compTraits []v1alpha1.ComponentTrait, allowedTraits []v1alpha1.TraitRef) error
- func ValidateClusterComponentTypeResourcesWithSchema(cct *v1alpha1.ClusterComponentType, parametersSchema *apiextschema.Structural, ...) field.ErrorList
- func ValidateClusterTraitCreatesAndPatchesWithSchema(ct *v1alpha1.ClusterTrait, parametersSchema *apiextschema.Structural, ...) field.ErrorList
- func ValidateComponentTypeResourcesWithSchema(ct *v1alpha1.ComponentType, parametersSchema *apiextschema.Structural, ...) field.ErrorList
- func ValidateResourceTemplateStructure(template runtime.RawExtension, fieldPath *field.Path) (*metav1.PartialObjectMetadata, field.ErrorList)
- func ValidateResourcesWithSchema(resources []v1alpha1.ResourceTemplate, validations []v1alpha1.ValidationRule, ...) field.ErrorList
- func ValidateTraitCreateTemplates(creates []v1alpha1.TraitCreate, basePath *field.Path) field.ErrorList
- func ValidateTraitCreatesAndPatchesWithSchema(trait *v1alpha1.Trait, parametersSchema *apiextschema.Structural, ...) field.ErrorList
- func ValidateTraitInstanceNameUniqueness(compTraits []v1alpha1.ComponentTrait, ...) error
- func ValidateTraitSpec(spec v1alpha1.TraitSpec, parametersSchema *apiextschema.Structural, ...) field.ErrorList
- func ValidateWorkloadResources(workloadType string, resources []v1alpha1.ResourceTemplate, ...) field.ErrorList
- type CELValidator
- func (v *CELValidator) GetBaseEnv() *cel.Env
- func (v *CELValidator) GetTypeProvider() *apiservercel.DeclTypeProvider
- func (v *CELValidator) ValidateBooleanExpression(expr string, env *cel.Env) error
- func (v *CELValidator) ValidateExpression(expr string) error
- func (v *CELValidator) ValidateIterableExpression(expr string, env *cel.Env) error
- func (v *CELValidator) ValidateWithEnv(expr string, env *cel.Env) error
- type ResourceType
- type SchemaOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsWorkloadResourceKind ¶ added in v1.1.0
IsWorkloadResourceKind returns true if the given kind (case-insensitive) is a workload resource kind.
func ValidateAllowedTraits ¶ added in v1.0.0
func ValidateAllowedTraits(compTraits []v1alpha1.ComponentTrait, allowedTraits []v1alpha1.TraitRef) error
ValidateAllowedTraits checks that all component-level traits are permitted by the ComponentType's allowedTraits list. If allowedTraits is empty, no component-level traits are allowed.
func ValidateClusterComponentTypeResourcesWithSchema ¶ added in v0.16.0
func ValidateClusterComponentTypeResourcesWithSchema( cct *v1alpha1.ClusterComponentType, parametersSchema *apiextschema.Structural, environmentConfigsSchema *apiextschema.Structural, ) field.ErrorList
ValidateClusterComponentTypeResourcesWithSchema validates all resources in a ClusterComponentType with schema-aware type checking.
func ValidateClusterTraitCreatesAndPatchesWithSchema ¶ added in v0.16.0
func ValidateClusterTraitCreatesAndPatchesWithSchema( ct *v1alpha1.ClusterTrait, parametersSchema *apiextschema.Structural, environmentConfigsSchema *apiextschema.Structural, ) field.ErrorList
ValidateClusterTraitCreatesAndPatchesWithSchema validates all creates, patches, and validations in a ClusterTrait with schema-aware type checking.
func ValidateComponentTypeResourcesWithSchema ¶ added in v0.9.0
func ValidateComponentTypeResourcesWithSchema( ct *v1alpha1.ComponentType, parametersSchema *apiextschema.Structural, environmentConfigsSchema *apiextschema.Structural, ) field.ErrorList
ValidateComponentTypeResourcesWithSchema validates all resources in a ComponentType with schema-aware type checking.
func ValidateResourceTemplateStructure ¶
func ValidateResourceTemplateStructure(template runtime.RawExtension, fieldPath *field.Path) (*metav1.PartialObjectMetadata, field.ErrorList)
ValidateResourceTemplateStructure validates that a resource template has required Kubernetes fields and returns the parsed metadata for reuse by callers
func ValidateResourcesWithSchema ¶ added in v1.1.0
func ValidateResourcesWithSchema( resources []v1alpha1.ResourceTemplate, validations []v1alpha1.ValidationRule, parametersSchema *apiextschema.Structural, environmentConfigsSchema *apiextschema.Structural, basePath *field.Path, ) field.ErrorList
ValidateResourcesWithSchema validates resource templates and validation rules with schema-aware CEL type checking. basePath is the field path prefix for error reporting (e.g., field.NewPath("spec") for top-level CRDs, or field.NewPath("spec", "componentType", "spec") for embedded resources in ComponentRelease).
func ValidateTraitCreateTemplates ¶ added in v1.1.0
func ValidateTraitCreateTemplates(creates []v1alpha1.TraitCreate, basePath *field.Path) field.ErrorList
ValidateTraitCreateTemplates validates that trait create templates have required K8s resource fields (apiVersion, kind, metadata.name) and do not create workload resources.
func ValidateTraitCreatesAndPatchesWithSchema ¶ added in v0.9.0
func ValidateTraitCreatesAndPatchesWithSchema( trait *v1alpha1.Trait, parametersSchema *apiextschema.Structural, environmentConfigsSchema *apiextschema.Structural, ) field.ErrorList
ValidateTraitCreatesAndPatchesWithSchema validates all creates and patches in a Trait with schema-aware type checking.
func ValidateTraitInstanceNameUniqueness ¶ added in v1.0.0
func ValidateTraitInstanceNameUniqueness(compTraits []v1alpha1.ComponentTrait, embeddedTraits []v1alpha1.ComponentTypeTrait) error
ValidateTraitInstanceNameUniqueness checks that: - embedded trait instance names are unique among themselves - component-level trait instance names are unique among themselves - component-level trait instance names do not collide with embedded trait instance names
func ValidateTraitSpec ¶ added in v1.1.0
func ValidateTraitSpec( spec v1alpha1.TraitSpec, parametersSchema *apiextschema.Structural, environmentConfigsSchema *apiextschema.Structural, basePath *field.Path, ) field.ErrorList
ValidateTraitSpec validates all creates, patches, and validations in a TraitSpec with schema-aware type checking. basePath is the field path prefix for error reporting (e.g., field.NewPath("spec") for top-level CRDs, or a nested path for embedded trait specs in ComponentRelease).
If schemas are nil, DynType will be used for those variables (no static type checking).
func ValidateWorkloadResources ¶
func ValidateWorkloadResources(workloadType string, resources []v1alpha1.ResourceTemplate, basePath *field.Path) field.ErrorList
ValidateWorkloadResources validates resource templates and ensures workloadType matches a resource kind
Types ¶
type CELValidator ¶
type CELValidator struct {
// contains filtered or unexported fields
}
CELValidator provides comprehensive CEL expression validation with AST analysis
func NewCELValidator ¶
func NewCELValidator(resourceType ResourceType, opts SchemaOptions) (*CELValidator, error)
NewCELValidator creates a validator for the specified resource type. The validator uses different environments for ComponentType vs Trait resources to enforce proper variable access (e.g., traits have access to trait context variable). Provides schema-aware type checking when schemas are provided in opts.
func (*CELValidator) GetBaseEnv ¶
func (v *CELValidator) GetBaseEnv() *cel.Env
GetBaseEnv returns the base CEL environment for this validator
func (*CELValidator) GetTypeProvider ¶ added in v1.0.0
func (v *CELValidator) GetTypeProvider() *apiservercel.DeclTypeProvider
GetTypeProvider returns the DeclTypeProvider for this validator. Used by forEach analysis to resolve map value types for field validation.
func (*CELValidator) ValidateBooleanExpression ¶
func (v *CELValidator) ValidateBooleanExpression(expr string, env *cel.Env) error
ValidateBooleanExpression ensures the expression returns a boolean value. Used for includeWhen conditions and where filters.
func (*CELValidator) ValidateExpression ¶
func (v *CELValidator) ValidateExpression(expr string) error
ValidateExpression validates a CEL expression with the base environment
func (*CELValidator) ValidateIterableExpression ¶
func (v *CELValidator) ValidateIterableExpression(expr string, env *cel.Env) error
ValidateIterableExpression ensures the expression returns a list or map (for forEach).
func (*CELValidator) ValidateWithEnv ¶
func (v *CELValidator) ValidateWithEnv(expr string, env *cel.Env) error
ValidateWithEnv validates a CEL expression with a specific environment. This is used when the environment has been extended with forEach variables.
type ResourceType ¶
type ResourceType int
ResourceType indicates which type of resource is being validated
const ( // ComponentTypeResource indicates validation for ComponentType resources ComponentTypeResource ResourceType = iota // TraitResource indicates validation for Trait resources TraitResource )
type SchemaOptions ¶ added in v0.9.0
type SchemaOptions struct {
// ParametersSchema is the structural schema for parameters.
// If nil, an empty object type will be used.
ParametersSchema *apiextschema.Structural
// EnvironmentConfigsSchema is the structural schema for environmentConfigs.
// If nil, an empty object type will be used.
EnvironmentConfigsSchema *apiextschema.Structural
}
SchemaOptions provides schema configuration for CEL environment and validation. Used by both component and trait CEL environments.