This repository was archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathworkflow.go
86 lines (72 loc) · 1.57 KB
/
workflow.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
86
package models
// Workflow contains a list of Stages. When it is applied to a Machine,
// that machine's Tasks list is populated with the contents of the Stages in the Workflow.
//
// swagger:model
type Workflow struct {
Validation
Access
Meta
Owned
Bundled
Name string `index:",key"`
Description string
Documentation string
Stages []string
}
func (w *Workflow) GetMeta() Meta {
return w.Meta
}
func (w *Workflow) SetMeta(d Meta) {
w.Meta = d
}
// GetDocumentaiton returns the object's Documentation
func (w *Workflow) GetDocumentation() string {
return w.Documentation
}
// GetDescription returns the object's Description
func (w *Workflow) GetDescription() string {
return w.Description
}
func (w *Workflow) Prefix() string {
return "workflows"
}
func (w *Workflow) Key() string {
return w.Name
}
func (w *Workflow) KeyName() string {
return "Name"
}
func (w *Workflow) Fill() {
w.Validation.fill(w)
if w.Meta == nil {
w.Meta = Meta{}
}
if w.Stages == nil {
w.Stages = []string{}
}
}
func (w *Workflow) AuthKey() string {
return w.Key()
}
func (w *Workflow) SliceOf() interface{} {
ws := []*Workflow{}
return &ws
}
func (w *Workflow) ToModels(obj interface{}) []Model {
items := obj.(*[]*Workflow)
res := make([]Model, len(*items))
for i, item := range *items {
res[i] = Model(item)
}
return res
}
func (w *Workflow) Validate() {
w.AddError(ValidName("Invalid Name", w.Name))
for _, stageName := range w.Stages {
w.AddError(ValidName("Invalid Stage Name", stageName))
}
}
func (w *Workflow) CanHaveActions() bool {
return true
}