-
Notifications
You must be signed in to change notification settings - Fork 5
/
job.go
81 lines (66 loc) · 1.76 KB
/
job.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
package golang
import (
"github.com/gaia-pipeline/protobuf"
)
// InputType represents the available input types.
type InputType string
const (
// TextFieldInp text field input
TextFieldInp InputType = "textfield"
// TextAreaInp text area input
TextAreaInp InputType = "textarea"
// BoolInp boolean input
BoolInp InputType = "boolean"
// VaultInp vault automatic input
VaultInp InputType = "vault"
)
// Jobs is a collection of job
type Jobs []Job
// Job represents a single job which should be executed during pipeline run.
// Handler is the function pointer to the function which will be executed.
type Job struct {
Handler func(Arguments) error
Title string
Description string
DependsOn []string
Args Arguments
Interaction *ManualInteraction
}
// Arguments is a collection of argument
type Arguments []Argument
// Argument represents a single argument.
type Argument struct {
Description string
Type InputType
Key string
Value string
}
// ManualInteraction represents a manual interaction which can be set per job.
// Before the related job is executed, the manual interaction is displayed to
// the Gaia user.
type ManualInteraction struct {
Description string
Type InputType
Value string
}
// jobsWrapper wraps a function pointer around the
// proto.Job struct.
// The given function corresponds to the job.
type jobsWrapper struct {
funcPointer func(Arguments) error
job proto.Job
}
// Get looks up a job by the given id.
// Returns the job otherwise nil.
func getJob(hash uint32) *jobsWrapper {
for _, job := range cachedJobs {
if job.job.UniqueId == hash {
return &job
}
}
return nil
}
// String returns a input type string back
func (i InputType) String() string {
return string(i)
}