@@ -4,6 +4,7 @@ apiVersion: core.oam.dev/v1beta1
4
4
kind : WorkflowStepDefinition
5
5
metadata :
6
6
annotations :
7
+ definition.oam.dev/alias : " "
7
8
definition.oam.dev/description : Enable a KubeVela addon
8
9
definition.oam.dev/example-url : https://raw.githubusercontent.com/kubevela/catalog/master/examples/vela-workflow/observability.yaml
9
10
labels :
@@ -15,79 +16,86 @@ spec:
15
16
cue :
16
17
template : |
17
18
import (
18
- "vela/op"
19
+ "vela/op"
19
20
)
20
21
21
22
job: op.#Apply & {
22
- value: {
23
- apiVersion: "batch/v1"
24
- kind: "Job"
25
- metadata: {
26
- name: context.name + "-" + context.stepSessionID
27
- namespace: "vela-system"
28
- labels: "enable-addon.oam.dev": context.name
29
- annotations: "workflow.oam.dev/step": context.stepName
30
- }
31
- spec: {
32
- backoffLimit: 3
33
- template: {
34
- metadata: {
35
- labels: {
36
- "workflow.oam.dev/name": context.name
37
- "workflow.oam.dev/session": context.stepSessionID
38
- }
39
- annotations: "workflow.oam.dev/step": context.stepName
40
- }
41
- spec: {
42
- containers: [
43
- {
44
- name: parameter.addonName + "-enable-job"
45
- image: parameter.image
23
+ value: {
24
+ apiVersion: "batch/v1"
25
+ kind: "Job"
26
+ metadata: {
27
+ name: context.name + "-" + context.stepSessionID
28
+ namespace: "vela-system"
29
+ labels: {
30
+ "enable-addon.oam.dev": context.name
31
+ "workflow.oam.dev/name": context.name
32
+ "workflow.oam.dev/session": context.stepSessionID
33
+ }
34
+ annotations: "workflowrun.oam.dev/step": context.stepName
35
+ }
36
+ spec: {
37
+ backoffLimit: 3
38
+ template: {
39
+ metadata: {
40
+ labels: {
41
+ "workflow.oam.dev/name": context.name
42
+ "workflow.oam.dev/session": context.stepSessionID
43
+ }
44
+ annotations: "workflow.oam.dev/step": context.stepName
45
+ }
46
+ spec: {
47
+ containers: [
48
+ {
49
+ name: parameter.addonName + "-enable-job"
50
+ image: parameter.image
46
51
47
- if parameter.args == _|_ {
48
- command: ["vela", "addon", parameter.operation, parameter.addonName]
49
- }
52
+ if parameter.args == _|_ {
53
+ args: ["addon", parameter.operation, parameter.addonName]
54
+ }
55
+
56
+ if parameter.args != _|_ {
57
+ args: ["addon", parameter.operation, parameter.addonName] + parameter.args
58
+ }
59
+ },
60
+ ]
61
+ restartPolicy: "Never"
62
+ serviceAccount: parameter.serviceAccountName
63
+ }
64
+ }
65
+ }
66
+ }
67
+ } @step(1)
50
68
51
- if parameter.args != _|_ {
52
- command: ["vela", "addon", parameter.operation, parameter.addonName] + parameter.args
53
- }
54
- },
55
- ]
56
- restartPolicy: "Never"
57
- serviceAccount: parameter.serviceAccountName
58
- }
59
- }
60
- }
61
- }
62
- }
63
69
log: op.#Log & {
64
- source: resources: [{labelSelector: {
65
- "workflow.oam.dev/name": context.name
66
- "workflow.oam.dev/session": context.stepSessionID
67
- }}]
68
- }
69
- fail: op.#Steps & {
70
- if job.value.status.failed != _|_ {
71
- if job.value.status.failed > 2 {
72
- breakWorkflow: op.#Fail & {
73
- message: "enable addon failed"
74
- }
75
- }
76
- }
77
- }
70
+ source: resources: [{labelSelector: {
71
+ "workflow.oam.dev/name": context.name
72
+ "workflow.oam.dev/session": context.stepSessionID
73
+ }}]
74
+ } @step(2)
75
+
78
76
wait: op.#ConditionalWait & {
79
- continue: job.value.status.succeeded != _|_ && job.value.status.succeeded > 0
80
- }
77
+ continue: job.value.status.succeeded != _|_ || job.value.status.failed != _|_
78
+ } @step(3)
79
+
80
+ fail: op.#Steps & {
81
+ if job.value.status.failed != _|_ {
82
+ if job.value.status.failed > 2 {
83
+ breakWorkflow: op.#Fail & {
84
+ message: "enable addon failed"
85
+ }
86
+ }
87
+ }
88
+ } @step(4)
89
+
81
90
parameter: {
82
- // +usage=Specify the name of the addon.
83
- addonName: string
84
- // +usage=Specify addon enable args.
85
- args?: [...string]
86
- // +usage=Specify the image
87
- image: *"oamdev/vela-cli:v1.6.4 " | string
88
- // +usage=operation for the addon
89
- operation: *"enable" | "upgrade" | "disable"
90
- // +usage=specify serviceAccountName want to use
91
- serviceAccountName: *"kubevela-vela-core" | string
91
+ // +usage=Specify the name of the addon.
92
+ addonName: string
93
+ // +usage=Specify addon enable args.
94
+ args?: [...string]
95
+ // +usage=Specify the image
96
+ image: *"oamdev/vela-cli:v1.10.3 " | string
97
+ // +usage=operation for the addon
98
+ operation: *"enable" | "upgrade" | "disable"
99
+ // +usage=specify serviceAccountName want to use
100
+ serviceAccountName: *"kubevela-vela-core" | string
92
101
}
93
-
0 commit comments