-
-
Notifications
You must be signed in to change notification settings - Fork 36
/
embed.go
52 lines (43 loc) · 1.15 KB
/
embed.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package os
import (
_ "embed"
"fmt"
"cuelang.org/go/cue"
)
//go:embed schema.cue
var task_schema string
var task_exec cue.Value
// var task_chan cue.Value
// var task_send cue.Value
// var task_recv cue.Value
var task_watch cue.Value
func init_schemas(ctx *cue.Context) {
if task_exec.Exists() {
return
}
val := ctx.CompileString(task_schema, cue.Filename("@embed:flow/tasks/csp/schema.cue"))
if val.Err() != nil {
fmt.Println(val.Err())
panic("should not have a schema error")
}
task_exec = val.LookupPath(cue.ParsePath("Exec"))
if !task_exec.Exists() {
panic("missing flow/tasks/os.Exec schema")
}
// task_chan = val.LookupPath(cue.ParsePath("Chan"))
// if !task_chan.Exists() {
// panic("missing flow/tasks/csp.Chan schema")
// }
// task_send = val.LookupPath(cue.ParsePath("Send"))
// if !task_send.Exists() {
// panic("missing flow/tasks/csp.Send schema")
// }
// task_recv = val.LookupPath(cue.ParsePath("Recv"))
// if !task_recv.Exists() {
// panic("missing flow/tasks/csp.Recv schema")
// }
task_watch = val.LookupPath(cue.ParsePath("Watch"))
if !task_watch.Exists() {
panic("missing flow/tasks/fs.Watch schema")
}
}