@@ -17,27 +17,10 @@ limitations under the License.
1717package v1alpha1
1818
1919import (
20+ v1 "k8s.io/api/core/v1"
2021 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2122)
2223
23- // EDIT THIS FILE! THIS IS SCAFFOLDING FOR YOU TO OWN!
24- // NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized.
25-
26- // TaskQueueSpec defines the desired state of TaskQueue.
27- type TaskQueueSpec struct {
28- // INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
29- // Important: Run "make" to regenerate code after modifying this file
30-
31- // Foo is an example field of TaskQueue. Edit taskqueue_types.go to remove/update
32- Foo string `json:"foo,omitempty"`
33- }
34-
35- // TaskQueueStatus defines the observed state of TaskQueue.
36- type TaskQueueStatus struct {
37- // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
38- // Important: Run "make" to regenerate code after modifying this file
39- }
40-
4124// +kubebuilder:object:root=true
4225// +kubebuilder:subresource:status
4326// +kubebuilder:resource:scope=Cluster
@@ -51,8 +34,83 @@ type TaskQueue struct {
5134 Status TaskQueueStatus `json:"status,omitempty"`
5235}
5336
54- // +kubebuilder:object:root=true
37+ // TaskQueueSpec defines the desired state of TaskQueue.
38+ type TaskQueueSpec struct {
39+ // NumberOfConcurrentTasks specifies how many tasks can run concurrently.
40+ // Defaults to 20 if not set.
41+ // +kubebuilder:default=20
42+ // +optional
43+ NumberOfConcurrentTasks int `json:"numberOfConcurrentTasks,omitempty"`
44+
45+ // Tasks represents the lists of tasks that this queue is responsible for processing.
46+ Tasks []UnitTask `json:"tasks,omitempty"`
47+
48+ // Rules defines ObjectPhaseRules. It contains three identification rules of successful phase of the object,
49+ // progressing phase of the object & failed phase of the object.
50+ // Example:
51+ // rules:
52+ // success: `has(self.status.phase) && self.status.phase == 'Successful'`
53+ // inProgress: `has(self.status.phase) && self.status.phase == 'Progressing'`
54+ // failed: `has(self.status.phase) && self.status.phase == 'Failed'`
55+ Rules ObjectPhaseRules `json:"rules"`
5556
57+ // LastTriggeredTasksHistory specifies how many history of triggeredTask will display in the status section.
58+ // Defaults to 20 if not set.
59+ // +kubebuilder:default=20
60+ // +optional
61+ LastTriggeredTasksHistory int `json:"lastTriggeredTasksHistory,omitempty"`
62+ }
63+
64+ // ObjectPhaseRules defines three identification rules of successful phase of the object,
65+ // progressing phase of the object & failed execution of the object.
66+ // To specifies any field of the Operation object, the rule must start with the word `self`.
67+ // Example:
68+ //
69+ // .status.phase -> self.status.phase
70+ // .status.observedGeneration -> self.status.observedGeneration
71+ //
72+ // The rules can be any valid expression supported by CEL(Common Expression Language).
73+ // Ref: https://github.com/google/cel-spec
74+ type ObjectPhaseRules struct {
75+ // Success defines a rule to identify the successful execution of the operation.
76+ // Example:
77+ // success: `has(self.status.phase) && self.status.phase == 'Successful'`
78+ // Here self.status.phase is pointing to .status.phase field of the Operation object.
79+ // When .status.phase field presents and becomes `Successful`, the Success rule will satisfy.
80+ Success string `json:"success"`
81+
82+ // InProgress defines a rule to identify that applied operation is progressing.
83+ // Example:
84+ // inProgress: `has(self.status.phase) && self.status.phase == 'Progressing'`
85+ // Here self.status.phase is pointing to .status.phase field of the Operation object.
86+ // When .status.phase field presents and becomes `Progressing`, the InProgress rule will satisfy.
87+ InProgress string `json:"inProgress"`
88+
89+ // Failed defines a rule to identify that applied operation is failed.
90+ // Example:
91+ // inProgress: `has(self.status.phase) && self.status.phase == 'Failed'`
92+ // Here self.status.phase is pointing to .status.phase field of the Operation object.
93+ // When .status.phase field presents and becomes `Failed`, the Failed rule will satisfy.
94+ Failed string `json:"failed"`
95+ }
96+
97+ // TaskQueueStatus defines the observed state of TaskQueue.
98+ type TaskQueueStatus struct {
99+ // LastExecutionTime indicates when the last task was executed.
100+ // +optional
101+ LastExecutionTime * metav1.Time `json:"lastExecutionTime,omitempty"`
102+
103+ // LastTriggeredTasks contains references to the most recently triggered tasks.
104+ // +optional
105+ LastTriggeredTasks []v1.TypedObjectReference `json:"lastTriggeredTasks,omitempty"`
106+ }
107+
108+ type UnitTask struct {
109+ Kind string `json:"kind,omitempty"`
110+ APIGroup string `json:"apiGroup,omitempty"`
111+ }
112+
113+ // +kubebuilder:object:root=true
56114// TaskQueueList contains a list of TaskQueue.
57115type TaskQueueList struct {
58116 metav1.TypeMeta `json:",inline"`
0 commit comments