File tree Expand file tree Collapse file tree 4 files changed +102
-5
lines changed Expand file tree Collapse file tree 4 files changed +102
-5
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,9 @@ type Config struct {
135
135
// concrete and cannot change.
136
136
IgnoreConcrete bool
137
137
138
+ // FindHiddenTasks allows tasks to be defined in hidden fields.
139
+ FindHiddenTasks bool
140
+
138
141
// UpdateFunc is called whenever the information in the controller is
139
142
// updated. This includes directly after initialization. The task may be
140
143
// nil if this call is not the result of a task completing.
Original file line number Diff line number Diff line change @@ -72,10 +72,11 @@ func TestFlow(t *testing.T) {
72
72
}
73
73
74
74
cfg := & flow.Config {
75
- Root : cue .ParsePath ("root" ),
76
- InferTasks : t .Bool ("InferTasks" ),
77
- IgnoreConcrete : t .Bool ("IgnoreConcrete" ),
78
- UpdateFunc : updateFunc ,
75
+ Root : cue .ParsePath ("root" ),
76
+ InferTasks : t .Bool ("InferTasks" ),
77
+ IgnoreConcrete : t .Bool ("IgnoreConcrete" ),
78
+ FindHiddenTasks : t .Bool ("FindHiddenTasks" ),
79
+ UpdateFunc : updateFunc ,
79
80
}
80
81
81
82
c := flow .New (cfg , v , taskFunc )
Original file line number Diff line number Diff line change @@ -68,7 +68,13 @@ func (c *Controller) findRootTasks(v cue.Value) {
68
68
return
69
69
}
70
70
71
- for iter , _ := v .Fields (); iter .Next (); {
71
+ opts := []cue.Option {}
72
+
73
+ if c .cfg .FindHiddenTasks {
74
+ opts = append (opts , cue .Hidden (true ), cue .Definitions (false ))
75
+ }
76
+
77
+ for iter , _ := v .Fields (opts ... ); iter .Next (); {
72
78
c .findRootTasks (iter .Value ())
73
79
}
74
80
}
Original file line number Diff line number Diff line change
1
+ #FindHiddenTasks: true
2
+ -- in.cue --
3
+ root: {
4
+ a: {
5
+ $id: "valToOut"
6
+ val: "foo"
7
+ out: string
8
+ }
9
+ _b: {
10
+ $id: "valToOut"
11
+ $after: a
12
+ val: "bar"
13
+ out: string
14
+ }
15
+ c: {
16
+ $id: "valToOut"
17
+ out: a.out + _b.out
18
+ }
19
+ // These tasks should _not_ run, because they are definitions.
20
+ _#c: {
21
+ $id: "valToOut"
22
+ out: c.out + "baz"
23
+ }
24
+ #d: {
25
+ $id: "valToOut"
26
+ out: c.out + "baz"
27
+ }
28
+ }
29
+ -- out/run/errors --
30
+ -- out/run/t0 --
31
+ graph TD
32
+ t0("root.a [Ready]")
33
+ t1("root._b [Waiting]")
34
+ t1-->t0
35
+ t2("root.c [Waiting]")
36
+ t2-->t0
37
+ t2-->t1
38
+
39
+ -- out/run/t1 --
40
+ graph TD
41
+ t0("root.a [Terminated]")
42
+ t1("root._b [Ready]")
43
+ t1-->t0
44
+ t2("root.c [Waiting]")
45
+ t2-->t0
46
+ t2-->t1
47
+
48
+ -- out/run/t1/value --
49
+ {
50
+ $id: "valToOut"
51
+ val: "foo"
52
+ out: "foo"
53
+ }
54
+ -- out/run/t2 --
55
+ graph TD
56
+ t0("root.a [Terminated]")
57
+ t1("root._b [Terminated]")
58
+ t1-->t0
59
+ t2("root.c [Ready]")
60
+ t2-->t0
61
+ t2-->t1
62
+
63
+ -- out/run/t2/value --
64
+ {
65
+ $id: "valToOut"
66
+ $after: {
67
+ $id: "valToOut"
68
+ val: "foo"
69
+ out: "foo"
70
+ }
71
+ val: "bar"
72
+ out: "bar"
73
+ }
74
+ -- out/run/t3 --
75
+ graph TD
76
+ t0("root.a [Terminated]")
77
+ t1("root._b [Terminated]")
78
+ t1-->t0
79
+ t2("root.c [Terminated]")
80
+ t2-->t0
81
+ t2-->t1
82
+
83
+ -- out/run/t3/value --
84
+ {
85
+ $id: "valToOut"
86
+ out: "foobar"
87
+ }
You can’t perform that action at this time.
0 commit comments