compiler cleanup
Now using the same pattern as Go's http package. - the `compiler.Compiler` struct can be used directly (and tests to do to avoid messing with the global version) - `compiler.DefaultCompiler` contains a public default Compiler instance - `compiler` exposes proxy functions (e.g. Compile) back to the DefaultCompiler Signed-off-by: Andrea Luzzardi <aluzzardi@gmail.com>
This commit is contained in:
22
dagger/compiler/utils.go
Normal file
22
dagger/compiler/utils.go
Normal file
@@ -0,0 +1,22 @@
|
||||
package compiler
|
||||
|
||||
import (
|
||||
"cuelang.org/go/cue"
|
||||
)
|
||||
|
||||
func cueStringsToCuePath(parts ...string) cue.Path {
|
||||
selectors := make([]cue.Selector, 0, len(parts))
|
||||
for _, part := range parts {
|
||||
selectors = append(selectors, cue.Str(part))
|
||||
}
|
||||
return cue.MakePath(selectors...)
|
||||
}
|
||||
|
||||
func cuePathToStrings(p cue.Path) []string {
|
||||
selectors := p.Selectors()
|
||||
out := make([]string, len(selectors))
|
||||
for i, sel := range selectors {
|
||||
out[i] = sel.String()
|
||||
}
|
||||
return out
|
||||
}
|
Reference in New Issue
Block a user