CueContext
A CUE evaluation context for loading, compiling, and validating CUE configurations.
CueContext wraps the CUE compiler and provides methods to compile CUE from strings, load from files or directories (with cue.mod/ module support), validate data against schemas, and inject hidden fields for workflow step compilation.
"Compile CUE from a string"
| ctx <CueContext> result <Result> |
ctx := CueContext new.
result := ctx compileString: 'name: "Alice", age: 30'.
result value toMaggie
"Validate data against a schema"
| ctx <CueContext> |
ctx := CueContext new.
ctx validate: 'name: "Alice", age: 30'
against: 'name: string, age: int & >0'
"Load CUE from a directory with module support"
| ctx <CueContext> result <Result> |
ctx := CueContext new.
result := ctx loadDir: './config'.
result value
Class Methods
primitives
Instance Methods
primitives
uncategorized
Compile a CUE source string into a CueValue. Returns a Result wrapping the CueValue on success, or an error message on failure.
| ctx <CueContext> result <Result> |
ctx := CueContext new.
result := ctx compileString: 'x: 42, y: x + 1'.
result value lookup: 'y'
Inject hidden fields from a Dictionary into a CUE source string. Dictionary keys starting with _ become hidden CUE fields. Returns a Result wrapping the new CueValue.
| ctx <CueContext> fields <Dictionary> result <Result> |
ctx := CueContext new.
fields := Dictionary new.
fields at: '_input' put: 'hello'.
result := ctx inject: fields into: '_input: _, output: _input'.
result value lookup: 'output'
Load CUE from a directory, with cue.mod/ module traversal support. Returns a Result wrapping the CueValue.
| ctx <CueContext> result <Result> |
ctx := CueContext new.
result := ctx loadDir: './myproject'.
result isSuccess ifTrue: [result value fields]
Load CUE from a file path. Returns a Result wrapping the CueValue.
| ctx <CueContext> result <Result> |
ctx := CueContext new.
result := ctx loadFile: '/path/to/config.cue'.
result isSuccess ifTrue: [result value toMaggie]
Return a string representation of this context.
Validate a CUE data string against a CUE schema string. Returns a Success Result if valid, Failure with error details if not.
| ctx <CueContext> result <Result> |
ctx := CueContext new.
result := ctx validate: 'name: "Alice", age: 30'
against: 'name: string, age: int & >0'.
result isSuccess >>> true