...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package v1alpha1
17
18 import (
19 corev1 "k8s.io/api/core/v1"
20 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
21 "k8s.io/apimachinery/pkg/runtime"
22 )
23
24 const (
25 LabelControlledBy = "chaos-mesh.org/controlled-by"
26 LabelWorkflow = "chaos-mesh.org/workflow"
27 WorkflowAnnotationAbort = "workflow.chaos-mesh.org/abort"
28 )
29
30 const KindWorkflowNode = "WorkflowNode"
31
32
33
34
35 type WorkflowNode struct {
36 metav1.TypeMeta `json:",inline"`
37 metav1.ObjectMeta `json:"metadata,omitempty"`
38
39
40 Spec WorkflowNodeSpec `json:"spec"`
41
42
43
44 Status WorkflowNodeStatus `json:"status,omitempty"`
45 }
46
47 type WorkflowNodeSpec struct {
48 TemplateName string `json:"templateName"`
49 WorkflowName string `json:"workflowName"`
50 Type TemplateType `json:"type"`
51 StartTime *metav1.Time `json:"startTime"`
52
53 Deadline *metav1.Time `json:"deadline,omitempty"`
54
55 Task *Task `json:"task,omitempty"`
56
57 Children []string `json:"children,omitempty"`
58
59 ConditionalBranches []ConditionalBranch `json:"conditionalBranches,omitempty"`
60
61 *EmbedChaos `json:",inline,omitempty"`
62
63 Schedule *ScheduleSpec `json:"schedule,omitempty"`
64
65
66 StatusCheck *StatusCheckSpec `json:"statusCheck,omitempty"`
67
68
69
70 AbortWithStatusCheck bool `json:"abortWithStatusCheck,omitempty"`
71 }
72
73 type WorkflowNodeStatus struct {
74
75
76
77 ChaosResource *corev1.TypedLocalObjectReference `json:"chaosResource,omitempty"`
78
79
80
81 ConditionalBranchesStatus *ConditionalBranchesStatus `json:"conditionalBranchesStatus,omitempty"`
82
83
84
85 ActiveChildren []corev1.LocalObjectReference `json:"activeChildren,omitempty"`
86
87
88
89 FinishedChildren []corev1.LocalObjectReference `json:"finishedChildren,omitempty"`
90
91
92
93
94
95 Conditions []WorkflowNodeCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"`
96 }
97
98 type ConditionalBranch struct {
99
100 Target string `json:"target"`
101
102
103 Expression string `json:"expression,omitempty"`
104 }
105
106 type ConditionalBranchesStatus struct {
107
108 Branches []ConditionalBranchStatus `json:"branches"`
109
110 Context []string `json:"context"`
111 }
112
113 type ConditionalBranchStatus struct {
114 Target string `json:"target"`
115 EvaluationResult corev1.ConditionStatus `json:"evaluationResult"`
116 }
117
118 type WorkflowNodeConditionType string
119
120 const (
121 ConditionAccomplished WorkflowNodeConditionType = "Accomplished"
122 ConditionDeadlineExceed WorkflowNodeConditionType = "DeadlineExceed"
123 ConditionChaosInjected WorkflowNodeConditionType = "ChaosInjected"
124 ConditionAborted WorkflowNodeConditionType = "Aborted"
125 )
126
127 type WorkflowNodeCondition struct {
128 Type WorkflowNodeConditionType `json:"type"`
129 Status corev1.ConditionStatus `json:"status"`
130 Reason string `json:"reason"`
131 }
132
133
134 type WorkflowNodeList struct {
135 metav1.TypeMeta `json:",inline"`
136 metav1.ListMeta `json:"metadata,omitempty"`
137 Items []WorkflowNode `json:"items"`
138 }
139
140 func init() {
141 SchemeBuilder.Register(&WorkflowNode{}, &WorkflowNodeList{})
142 }
143
144
145 const (
146 EntryCreated string = "EntryCreated"
147 InvalidEntry string = "InvalidEntry"
148 WorkflowAccomplished string = "WorkflowAccomplished"
149 NodeAccomplished string = "NodeAccomplished"
150 NodesCreated string = "NodesCreated"
151 NodeDeadlineExceed string = "NodeDeadlineExceed"
152 NodeDeadlineNotExceed string = "NodeDeadlineNotExceed"
153 NodeDeadlineOmitted string = "NodeDeadlineOmitted"
154 ParentNodeDeadlineExceed string = "ParentNodeDeadlineExceed"
155 ChaosCRCreated string = "ChaosCRCreated"
156 ChaosCRCreateFailed string = "ChaosCRCreateFailed"
157 ChaosCRDeleted string = "ChaosCRDeleted"
158 ChaosCRDeleteFailed string = "ChaosCRDeleteFailed"
159 ChaosCRNotExists string = "ChaosCRNotExists"
160 TaskPodSpawned string = "TaskPodSpawned"
161 TaskPodSpawnFailed string = "TaskPodSpawnFailed"
162 TaskPodPodCompleted string = "TaskPodPodCompleted"
163 ConditionalBranchesSelected string = "ConditionalBranchesSelected"
164 RerunBySpecChanged string = "RerunBySpecChanged"
165 StatusCheckCreated string = "StatusCheckCreated"
166 StatusCheckCreatedFailed string = "StatusCheckCreatedFailed"
167 StatusCheckDeleted string = "StatusCheckDeleted"
168 StatusCheckDeletedFailed string = "StatusCheckDeletedFailed"
169 StatusCheckCompleted string = "StatusCheckCompleted"
170 StatusCheckNotExceedSuccessThreshold string = "StatusCheckNotExceedSuccessThreshold"
171 ParentNodeAborted string = "ParentNodeAborted"
172 WorkflowAborted string = "WorkflowAborted"
173 )
174
175
176
177 type GenericChaosList interface {
178 runtime.Object
179 metav1.ListInterface
180 GetItems() []GenericChaos
181 DeepCopyList() GenericChaosList
182 }
183
184
185
186 type GenericChaos interface {
187 runtime.Object
188 metav1.Object
189 }
190