-
Notifications
You must be signed in to change notification settings - Fork 0
/
task.go
85 lines (61 loc) · 1.25 KB
/
task.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
package task
import (
"context"
"github.com/octohelm/piper/pkg/cueflow"
"github.com/octohelm/x/ptr"
)
type Task struct {
// task hook to make task could run after some others
Dep any `json:"$dep,omitempty"`
// task result
Ok *bool `json:"-" output:"$ok,omitempty"`
cueflow.TaskImpl
}
var _ cueflow.Successor = &Task{}
func (t *Task) Success() bool {
return t.Ok != nil && *t.Ok
}
var _ cueflow.TaskFeedback = &Task{}
func (t *Task) Done(err error) {
if t.Ok == nil {
t.Ok = ptr.Ptr(err == nil)
}
}
type SetupTask struct {
Task
}
var _ cueflow.TaskSetup = &SetupTask{}
func (SetupTask) Setup() bool {
return true
}
type Group struct {
Task
t cueflow.Task
}
func (v *Group) T() cueflow.Task {
return v.t
}
var _ cueflow.TaskUnmarshaler = &Group{}
func (v *Group) UnmarshalTask(t cueflow.Task) error {
v.t = t
return nil
}
var _ cueflow.CacheDisabler = &Group{}
func (Group) CacheDisabled() bool {
return true
}
type Checkpoint struct {
// no need the ok
Task `json:"-"`
}
var _ cueflow.CacheDisabler = &Checkpoint{}
func (Checkpoint) CacheDisabled() bool {
return true
}
var _ cueflow.Checkpoint = &Checkpoint{}
func (Checkpoint) AsCheckpoint() bool {
return true
}
func (Checkpoint) Do(ctx context.Context) error {
return nil
}