cuex

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: Apache-2.0 Imports: 20 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// EnableExternalPackageForDefaultCompiler .
	EnableExternalPackageForDefaultCompiler = true
	// EnableExternalPackageWatchForDefaultCompiler .
	EnableExternalPackageWatchForDefaultCompiler = false
)
View Source
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 AddFlags

func AddFlags(set *pflag.FlagSet)

AddFlags add flags for configuring cuex default compiler

func CompileString

func CompileString(ctx context.Context, src string) (cue.Value, error)

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)
}

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

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

func (in *Compiler) CompileString(ctx context.Context, src string) (cue.Value, error)

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

func (*Compiler) Resolve

func (in *Compiler) Resolve(ctx context.Context, value cue.Value) (cue.Value, error)

Resolve runs the resolve process by calling provider functions

type DisableResolveProviderFunctions

type DisableResolveProviderFunctions struct{}

DisableResolveProviderFunctions disable ResolveProviderFunctions

func (DisableResolveProviderFunctions) ApplyTo

ApplyTo .

type FunctionCallError

type FunctionCallError struct {
	Path  string
	Value string
	Err   error
}

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

func (FunctionCallError) Error

func (e FunctionCallError) Error() string

Error .

type ProviderFnNotFoundErr

type ProviderFnNotFoundErr struct {
	Provider, Fn string
}

ProviderFnNotFoundErr provider function not found error

func (ProviderFnNotFoundErr) Error

func (e ProviderFnNotFoundErr) Error() string

Error .

type ProviderNotFoundErr

type ProviderNotFoundErr string

ProviderNotFoundErr provider not found error

func (ProviderNotFoundErr) Error

func (e ProviderNotFoundErr) Error() string

Error .

type ResolveTimeoutErr

type ResolveTimeoutErr struct{}

ResolveTimeoutErr error when Resolve process timeout

func (ResolveTimeoutErr) Error

func (e ResolveTimeoutErr) Error() string

Error .

Directories

Path Synopsis
model
cue

Jump to

Keyboard shortcuts

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