-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
task_run.go
61 lines (46 loc) · 1.18 KB
/
task_run.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
package resolver
import (
"github.com/graph-gophers/graphql-go"
"github.com/smartcontractkit/chainlink/v2/core/services/pipeline"
)
type TaskRunResolver struct {
tr pipeline.TaskRun
}
func NewTaskRun(tr pipeline.TaskRun) *TaskRunResolver {
return &TaskRunResolver{tr: tr}
}
func NewTaskRuns(runs []pipeline.TaskRun) []*TaskRunResolver {
var resolvers []*TaskRunResolver
for _, run := range runs {
resolvers = append(resolvers, NewTaskRun(run))
}
return resolvers
}
func (r *TaskRunResolver) ID() graphql.ID {
return graphql.ID(r.tr.ID.String())
}
func (r *TaskRunResolver) Type() string {
return string(r.tr.Type)
}
func (r *TaskRunResolver) Output() string {
val, err := r.tr.Output.MarshalJSON()
if err != nil {
return "error: unable to retrieve output"
}
return string(val)
}
func (r *TaskRunResolver) Error() *string {
if r.tr.Error.Valid {
return r.tr.Error.Ptr()
}
return nil
}
func (r *TaskRunResolver) CreatedAt() graphql.Time {
return graphql.Time{Time: r.tr.CreatedAt}
}
func (r *TaskRunResolver) FinishedAt() *graphql.Time {
return &graphql.Time{Time: r.tr.FinishedAt.ValueOrZero()}
}
func (r *TaskRunResolver) DotID() string {
return r.tr.GetDotID()
}