utils

package
v1.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ContextRegex = `^.+:\sreference\s\"context\"\snot\sfound$`

ContextRegex to match '**: reference "context" not found'

Functions

func CompileCuexTemplate added in v1.11.1

func CompileCuexTemplate(ctx context.Context, cueTemplate string) (cue.Value, error)

CompileCuexTemplate compiles cueTemplate exactly as ValidateCuexTemplate does, against the workload compiler with provider functions left unresolved, and returns the value instead of a verdict. A caller that runs more than one check against a template compiles it once here, then hands the value to ValidateCompiledCuexTemplate and to its own checks.

func CompileOpenPolicyTemplate added in v1.11.1

func CompileOpenPolicyTemplate(ctx context.Context, scope v1beta1.PolicyScope, cueTemplate string) (cue.Value, error)

CompileOpenPolicyTemplate is CompilePolicyTemplate with the fields a render supplies, context and parameter, opened. A template that reads context does not compile on its own, so this is what its parameter declaration is read from.

func CompilePolicyTemplate added in v1.11.1

func CompilePolicyTemplate(ctx context.Context, scope v1beta1.PolicyScope, cueTemplate string) (cue.Value, error)

CompilePolicyTemplate compiles a PolicyDefinition template the way CompileCuexTemplate compiles a component's, with provider functions left unresolved, but against the compiler that renders a policy of the given scope. It returns the value instead of a verdict: a caller that runs more than one check against a template compiles it once here, then hands the value to ValidateCompiledCuexTemplate and to its own checks.

func IsAddonDefinition added in v1.10.4

func IsAddonDefinition(obj client.Object) bool

IsAddonDefinition checks if the object is part of an addon installation This is a generic solution that works for ALL addons by checking owner references

func ValidateCompiledCuexTemplate added in v1.11.1

func ValidateCompiledCuexTemplate(val cue.Value) error

ValidateCompiledCuexTemplate is ValidateCuexTemplate for a value already produced by CompileCuexTemplate or CompilePolicyTemplate.

func ValidateCueTemplate added in v1.9.7

func ValidateCueTemplate(cueTemplate string) error

ValidateCueTemplate validate cueTemplate

func ValidateCuexTemplate added in v1.10.4

func ValidateCuexTemplate(ctx context.Context, cueTemplate string) error

ValidateCuexTemplate validate cueTemplate with CueX for types utilising it. Uses WorkloadCompiler so that templates referencing internal provider packages (e.g. "vela/helm") parse during admission validation.

The compile runs under helm.WithDryRun so that any provider package that honors the dry-run signal short-circuits to a side-effect-free path. Without this, a ComponentDefinition whose CUE supplies fully concrete arguments to helm.#Render could trigger a real chart fetch and helm install during admission.

func ValidateDefinitionRevision

func ValidateDefinitionRevision(ctx context.Context, cli client.Client, def runtime.Object, defRevNamespacedName types.NamespacedName) error

ValidateDefinitionRevision validate whether definition will modify the immutable object definitionRevision

func ValidateMultipleDefVersionsNotPresent added in v1.10.0

func ValidateMultipleDefVersionsNotPresent(version, revisionName, objectType string) error

ValidateMultipleDefVersionsNotPresent validates that both Name Annotation Revision and Spec.Version are not present

func ValidateOutputResourcesExist added in v1.10.4

func ValidateOutputResourcesExist(cueTemplate string, mapper meta.RESTMapper, obj client.Object) error

ValidateOutputResourcesExist validates that resources referenced in output/outputs fields exist on the cluster

func ValidateSemanticVersion added in v1.10.0

func ValidateSemanticVersion(version string) error

ValidateSemanticVersion validates if a Definition's version includes all of major,minor & patch version values.

Types

type ResourceInfo added in v1.10.4

type ResourceInfo struct {
	APIVersion string
	Kind       string
	Name       string // optional, for better error messages
}

func ExtractResourceInfo added in v1.10.4

func ExtractResourceInfo(cueTemplate string) ([]ResourceInfo, error)

ExtractResourceInfo extracts apiVersion and kind from CUE template without evaluation

Jump to

Keyboard shortcuts

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