github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/vela-cli.yaml (about) 1 # Code generated by KubeVela templates. DO NOT EDIT. Please edit the original cue file. 2 # Definition source cue file: vela-templates/definitions/internal/vela-cli.cue 3 apiVersion: core.oam.dev/v1beta1 4 kind: WorkflowStepDefinition 5 metadata: 6 annotations: 7 custom.definition.oam.dev/category: Scripts & Commands 8 definition.oam.dev/description: Run a vela command 9 name: vela-cli 10 namespace: {{ include "systemDefinitionNamespace" . }} 11 spec: 12 schematic: 13 cue: 14 template: | 15 import ( 16 "vela/op" 17 ) 18 19 mountsArray: [ 20 if parameter.storage != _|_ && parameter.storage.secret != _|_ for v in parameter.storage.secret { 21 { 22 name: "secret-" + v.name 23 mountPath: v.mountPath 24 if v.subPath != _|_ { 25 subPath: v.subPath 26 } 27 } 28 }, 29 if parameter.storage != _|_ && parameter.storage.hostPath != _|_ for v in parameter.storage.hostPath { 30 { 31 name: "hostpath-" + v.name 32 mountPath: v.mountPath 33 } 34 }, 35 ] 36 37 volumesList: [ 38 if parameter.storage != _|_ && parameter.storage.secret != _|_ for v in parameter.storage.secret { 39 { 40 name: "secret-" + v.name 41 secret: { 42 defaultMode: v.defaultMode 43 secretName: v.secretName 44 if v.items != _|_ { 45 items: v.items 46 } 47 } 48 } 49 if parameter.storage != _|_ && parameter.storage.hostPath != _|_ for v in parameter.storage.hostPath { 50 { 51 name: "hostpath-" + v.name 52 path: v.path 53 } 54 } 55 }, 56 ] 57 58 deDupVolumesArray: [ 59 for val in [ 60 for i, vi in volumesList { 61 for j, vj in volumesList if j < i && vi.name == vj.name { 62 _ignore: true 63 } 64 vi 65 }, 66 ] if val._ignore == _|_ { 67 val 68 }, 69 ] 70 71 job: op.#Apply & { 72 value: { 73 apiVersion: "batch/v1" 74 kind: "Job" 75 metadata: { 76 name: "\(context.name)-\(context.stepName)-\(context.stepSessionID)" 77 if parameter.serviceAccountName == "kubevela-vela-core" { 78 namespace: "vela-system" 79 } 80 if parameter.serviceAccountName != "kubevela-vela-core" { 81 namespace: context.namespace 82 } 83 } 84 spec: { 85 backoffLimit: 3 86 template: { 87 metadata: labels: "workflow.oam.dev/step-name": "\(context.name)-\(context.stepName)" 88 spec: { 89 containers: [ 90 { 91 name: "\(context.name)-\(context.stepName)-\(context.stepSessionID)-job" 92 image: parameter.image 93 command: parameter.command 94 volumeMounts: mountsArray 95 }, 96 ] 97 restartPolicy: "Never" 98 serviceAccount: parameter.serviceAccountName 99 volumes: deDupVolumesArray 100 } 101 } 102 } 103 } 104 } 105 106 log: op.#Log & { 107 source: resources: [{labelSelector: "workflow.oam.dev/step-name": "\(context.name)-\(context.stepName)"}] 108 } 109 110 fail: op.#Steps & { 111 if job.value.status.failed != _|_ { 112 if job.value.status.failed > 2 { 113 breakWorkflow: op.#Fail & { 114 message: "failed to execute vela command" 115 } 116 } 117 } 118 } 119 120 wait: op.#ConditionalWait & { 121 continue: job.value.status.succeeded != _|_ && job.value.status.succeeded > 0 122 } 123 124 parameter: { 125 // +usage=Specify the name of the addon. 126 addonName: string 127 // +usage=Specify the vela command 128 command: [...string] 129 // +usage=Specify the image 130 image: *"oamdev/vela-cli:v1.6.4" | string 131 // +usage=specify serviceAccountName want to use 132 serviceAccountName: *"kubevela-vela-core" | string 133 storage?: { 134 // +usage=Mount Secret type storage 135 secret?: [...{ 136 name: string 137 mountPath: string 138 subPath?: string 139 defaultMode: *420 | int 140 secretName: string 141 items?: [...{ 142 key: string 143 path: string 144 mode: *511 | int 145 }] 146 }] 147 // +usage=Declare host path type storage 148 hostPath?: [...{ 149 name: string 150 path: string 151 mountPath: string 152 type: *"Directory" | "DirectoryOrCreate" | "FileOrCreate" | "File" | "Socket" | "CharDevice" | "BlockDevice" 153 }] 154 } 155 } 156