Documentation
¶
Index ¶
- Variables
- func AddFlags(set *pflag.FlagSet)
- func CompileString(ctx context.Context, src string) (cue.Value, error)
- func CompileStringWithOptions(ctx context.Context, src string, opts ...CompileOption) (cue.Value, error)
- type CompileConfig
- type CompileOption
- type Compiler
- type DisableResolveProviderFunctions
- type FunctionCallError
- type ProviderFnNotFoundErr
- type ProviderNotFoundErr
- type ResolveTimeoutErr
Constants ¶
This section is empty.
Variables ¶
var ( // EnableExternalPackageForDefaultCompiler . EnableExternalPackageForDefaultCompiler = true // EnableExternalPackageWatchForDefaultCompiler . EnableExternalPackageWatchForDefaultCompiler = false )
var DefaultCompiler = singleton.NewSingleton[*Compiler](func() *Compiler { compiler := NewCompilerWithDefaultInternalPackages() if EnableExternalPackageForDefaultCompiler { if err := compiler.LoadExternalPackages(context.Background()); err != nil && !kerrors.IsNotFound(err) { klog.Errorf("failed to load external packages for cuex default compiler: %s", err.Error()) } } if EnableExternalPackageWatchForDefaultCompiler { go compiler.ListenExternalPackages(nil) } return compiler })
DefaultCompiler compiler for cuex to compile
Functions ¶
func CompileString ¶
CompileString use cuex default compiler to compile cue string
func CompileStringWithOptions ¶
func CompileStringWithOptions(ctx context.Context, src string, opts ...CompileOption) (cue.Value, error)
CompileStringWithOptions use cuex default compiler to compile cue string with options
Types ¶
type CompileConfig ¶
type CompileConfig struct {
ResolveProviderFunctions bool
PreResolveMutators []func(context.Context, string) (string, error)
IntraResolveMutators []*withIntraResolveMutation
}
CompileConfig config for running compile process
func NewCompileConfig ¶
func NewCompileConfig(opts ...CompileOption) *CompileConfig
NewCompileConfig create new CompileConfig
type CompileOption ¶
type CompileOption interface {
ApplyTo(*CompileConfig)
}
CompileOption options for compile cue string
func WithExtraData ¶
func WithExtraData(key string, data interface{}) CompileOption
WithExtraData fill the cue.Value before resolve
func WithIntraResolveMutation ¶ added in v1.10.0
func WithIntraResolveMutation(name string, fn func(ctx context.Context, value cue.Value) (cue.Value, error)) CompileOption
WithIntraResolveMutation - Allows to add a mutation function to the compile process. This runs after the initial parsing and before the resolution of provider functions (CueX). This is required when provider function resolution needs access to dynamically read values, such as from Config.
type Compiler ¶
type Compiler struct {
*cuexruntime.PackageManager
}
Compiler for compile cue strings into cue.Value
func NewCompilerWithDefaultInternalPackages ¶
func NewCompilerWithDefaultInternalPackages() *Compiler
NewCompilerWithDefaultInternalPackages create compiler with default internal packages
func NewCompilerWithInternalPackages ¶
func NewCompilerWithInternalPackages(packages ...cuexruntime.Package) *Compiler
NewCompilerWithInternalPackages create compiler with internal packages
func (*Compiler) CompileString ¶
CompileString compile given cue string into cue.Value
func (*Compiler) CompileStringWithOptions ¶
func (in *Compiler) CompileStringWithOptions(ctx context.Context, src string, opts ...CompileOption) (cue.Value, error)
CompileStringWithOptions compile given cue string with extra options
type DisableResolveProviderFunctions ¶
type DisableResolveProviderFunctions struct{}
DisableResolveProviderFunctions disable ResolveProviderFunctions
func (DisableResolveProviderFunctions) ApplyTo ¶
func (in DisableResolveProviderFunctions) ApplyTo(cfg *CompileConfig)
ApplyTo .
type FunctionCallError ¶
FunctionCallError error for executing provider function
func NewFunctionCallError ¶
func NewFunctionCallError(v cue.Value, err error) FunctionCallError
NewFunctionCallError create a new error for executing resolved function call
type ProviderFnNotFoundErr ¶
type ProviderFnNotFoundErr struct {
Provider, Fn string
}
ProviderFnNotFoundErr provider function not found error
type ProviderNotFoundErr ¶
type ProviderNotFoundErr string
ProviderNotFoundErr provider not found error
type ResolveTimeoutErr ¶
type ResolveTimeoutErr struct{}
ResolveTimeoutErr error when Resolve process timeout

