Open
Description
Originally opened by @mikelnrd in cuelang/cue#423
Hi. Just throwing a slightly crazy idea out there in case it sticks... how about pkg/encoding/cue
?
I believe cue (used as a pkg inside of cue) would fit the requirement of being hermetic:
All packages except those defined in the tool subdirectory are hermetic, that is depending only on a known set of inputs, and therefore can guarantee reproducible results. That is:
- no reading of files contents
- no querying of the file system of any kind
- no communication on the network
- no information about the type of environment
- only reproducible random generators
Use cases I can think of:
- testing cue code in cue (eg cue.Validate that works like yaml.Validate)
- cue examples in cue
- specifying cue constraints at runtime (small example below)
- ...
package idea
import (
"encoding/cue"
)
#Example {
cueConstraintFromUserAtRuntime: *'!= ""' | string
name: string
name: cue.UnMarshal(cueConstraintFromUserAtRuntime)
}
example: #Example & {
name: "michael"
}
example2: #Example & {
cueConstraintFromUserAtRuntime: "^[a-z]{4}$" // any string with lowercase ASCII of length 4
name: "mike"
}
// Note that this in the same vein as google's cel common expression language which I guess could also fit into cue's stdlib somehow too...
//
//package idea
//
//import (
// "encoding/cel" //https://github.com/google/cel-go
//)
//
//#Example {
// celExpression: string
// ...
//}