github.com/oam-dev/kubevela@v1.9.11/charts/vela-core/templates/defwithtemplate/notification.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/notification.cue 3 apiVersion: core.oam.dev/v1beta1 4 kind: WorkflowStepDefinition 5 metadata: 6 annotations: 7 custom.definition.oam.dev/category: External Integration 8 definition.oam.dev/description: Send notifications to Email, DingTalk, Slack, Lark or webhook in your workflow. 9 name: notification 10 namespace: {{ include "systemDefinitionNamespace" . }} 11 spec: 12 schematic: 13 cue: 14 template: | 15 import ( 16 "vela/op" 17 "encoding/base64" 18 ) 19 20 parameter: { 21 // +usage=Please fulfill its url and message if you want to send Lark messages 22 lark?: { 23 // +usage=Specify the the lark url, you can either sepcify it in value or use secretRef 24 url: close({ 25 // +usage=the url address content in string 26 value: string 27 }) | close({ 28 secretRef: { 29 // +usage=name is the name of the secret 30 name: string 31 // +usage=key is the key in the secret 32 key: string 33 } 34 }) 35 // +usage=Specify the message that you want to sent, refer to [Lark messaging](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN#8b0f2a1b). 36 message: { 37 // +usage=msg_type can be text, post, image, interactive, share_chat, share_user, audio, media, file, sticker 38 msg_type: string 39 // +usage=content should be json encode string 40 content: string 41 } 42 } 43 // +usage=Please fulfill its url and message if you want to send DingTalk messages 44 dingding?: { 45 // +usage=Specify the the dingding url, you can either sepcify it in value or use secretRef 46 url: close({ 47 // +usage=the url address content in string 48 value: string 49 }) | close({ 50 secretRef: { 51 // +usage=name is the name of the secret 52 name: string 53 // +usage=key is the key in the secret 54 key: string 55 } 56 }) 57 // +usage=Specify the message that you want to sent, refer to [dingtalk messaging](https://developers.dingtalk.com/document/robots/custom-robot-access/title-72m-8ag-pqw) 58 message: { 59 // +usage=Specify the message content of dingtalk notification 60 text?: close({ 61 content: string 62 }) 63 // +usage=msgType can be text, link, mardown, actionCard, feedCard 64 msgtype: *"text" | "link" | "markdown" | "actionCard" | "feedCard" 65 #link: { 66 text?: string 67 title?: string 68 messageUrl?: string 69 picUrl?: string 70 } 71 72 link?: #link 73 markdown?: close({ 74 text: string 75 title: string 76 }) 77 at?: close({ 78 atMobiles?: [...string] 79 isAtAll?: bool 80 }) 81 actionCard?: close({ 82 text: string 83 title: string 84 hideAvatar: string 85 btnOrientation: string 86 singleTitle: string 87 singleURL: string 88 btns?: [...close({ 89 title: string 90 actionURL: string 91 })] 92 }) 93 feedCard?: close({ 94 links: [...#link] 95 }) 96 } 97 } 98 // +usage=Please fulfill its url and message if you want to send Slack messages 99 slack?: { 100 // +usage=Specify the the slack url, you can either sepcify it in value or use secretRef 101 url: close({ 102 // +usage=the url address content in string 103 value: string 104 }) | close({ 105 secretRef: { 106 // +usage=name is the name of the secret 107 name: string 108 // +usage=key is the key in the secret 109 key: string 110 } 111 }) 112 // +usage=Specify the message that you want to sent, refer to [slack messaging](https://api.slack.com/reference/messaging/payload) 113 message: { 114 // +usage=Specify the message text for slack notification 115 text: string 116 blocks?: [...block] 117 attachments?: close({ 118 blocks?: [...block] 119 color?: string 120 }) 121 thread_ts?: string 122 // +usage=Specify the message text format in markdown for slack notification 123 mrkdwn?: *true | bool 124 } 125 } 126 // +usage=Please fulfill its from, to and content if you want to send email 127 email?: { 128 // +usage=Specify the email info that you want to send from 129 from: { 130 // +usage=Specify the email address that you want to send from 131 address: string 132 // +usage=The alias is the email alias to show after sending the email 133 alias?: string 134 // +usage=Specify the password of the email, you can either sepcify it in value or use secretRef 135 password: close({ 136 // +usage=the password content in string 137 value: string 138 }) | close({ 139 secretRef: { 140 // +usage=name is the name of the secret 141 name: string 142 // +usage=key is the key in the secret 143 key: string 144 } 145 }) 146 // +usage=Specify the host of your email 147 host: string 148 // +usage=Specify the port of the email host, default to 587 149 port: *587 | int 150 } 151 // +usage=Specify the email address that you want to send to 152 to: [...string] 153 // +usage=Specify the content of the email 154 content: { 155 // +usage=Specify the subject of the email 156 subject: string 157 // +usage=Specify the context body of the email 158 body: string 159 } 160 } 161 } 162 163 block: { 164 type: string 165 block_id?: string 166 elements?: [...{ 167 type: string 168 action_id?: string 169 url?: string 170 value?: string 171 style?: string 172 text?: textType 173 confirm?: { 174 title: textType 175 text: textType 176 confirm: textType 177 deny: textType 178 style?: string 179 } 180 options?: [...option] 181 initial_options?: [...option] 182 placeholder?: textType 183 initial_date?: string 184 image_url?: string 185 alt_text?: string 186 option_groups?: [...option] 187 max_selected_items?: int 188 initial_value?: string 189 multiline?: bool 190 min_length?: int 191 max_length?: int 192 dispatch_action_config?: trigger_actions_on?: [...string] 193 initial_time?: string 194 }] 195 } 196 197 textType: { 198 type: string 199 text: string 200 emoji?: bool 201 verbatim?: bool 202 } 203 204 option: { 205 text: textType 206 value: string 207 description?: textType 208 url?: string 209 } 210 211 // send webhook notification 212 ding: op.#Steps & { 213 if parameter.dingding != _|_ { 214 if parameter.dingding.url.value != _|_ { 215 ding1: op.#DingTalk & { 216 message: parameter.dingding.message 217 dingUrl: parameter.dingding.url.value 218 } 219 } 220 if parameter.dingding.url.secretRef != _|_ && parameter.dingding.url.value == _|_ { 221 read: op.#Read & { 222 value: { 223 apiVersion: "v1" 224 kind: "Secret" 225 metadata: { 226 name: parameter.dingding.url.secretRef.name 227 namespace: context.namespace 228 } 229 } 230 } 231 232 stringValue: op.#ConvertString & {bt: base64.Decode(null, read.value.data[parameter.dingding.url.secretRef.key])} 233 ding2: op.#DingTalk & { 234 message: parameter.dingding.message 235 dingUrl: stringValue.str 236 } 237 } 238 } 239 } 240 241 lark: op.#Steps & { 242 if parameter.lark != _|_ { 243 if parameter.lark.url.value != _|_ { 244 lark1: op.#Lark & { 245 message: parameter.lark.message 246 larkUrl: parameter.lark.url.value 247 } 248 } 249 if parameter.lark.url.secretRef != _|_ && parameter.lark.url.value == _|_ { 250 read: op.#Read & { 251 value: { 252 apiVersion: "v1" 253 kind: "Secret" 254 metadata: { 255 name: parameter.lark.url.secretRef.name 256 namespace: context.namespace 257 } 258 } 259 } 260 261 stringValue: op.#ConvertString & {bt: base64.Decode(null, read.value.data[parameter.lark.url.secretRef.key])} 262 lark2: op.#Lark & { 263 message: parameter.lark.message 264 larkUrl: stringValue.str 265 } 266 } 267 } 268 } 269 270 slack: op.#Steps & { 271 if parameter.slack != _|_ { 272 if parameter.slack.url.value != _|_ { 273 slack1: op.#Slack & { 274 message: parameter.slack.message 275 slackUrl: parameter.slack.url.value 276 } 277 } 278 if parameter.slack.url.secretRef != _|_ && parameter.slack.url.value == _|_ { 279 read: op.#Read & { 280 value: { 281 kind: "Secret" 282 apiVersion: "v1" 283 metadata: { 284 name: parameter.slack.url.secretRef.name 285 namespace: context.namespace 286 } 287 } 288 } 289 290 stringValue: op.#ConvertString & {bt: base64.Decode(null, read.value.data[parameter.slack.url.secretRef.key])} 291 slack2: op.#Slack & { 292 message: parameter.slack.message 293 slackUrl: stringValue.str 294 } 295 } 296 } 297 } 298 299 email: op.#Steps & { 300 if parameter.email != _|_ { 301 if parameter.email.from.password.value != _|_ { 302 email1: op.#SendEmail & { 303 from: { 304 address: parameter.email.from.address 305 if parameter.email.from.alias != _|_ { 306 alias: parameter.email.from.alias 307 } 308 password: parameter.email.from.password.value 309 host: parameter.email.from.host 310 port: parameter.email.from.port 311 } 312 to: parameter.email.to 313 content: parameter.email.content 314 } 315 } 316 317 if parameter.email.from.password.secretRef != _|_ && parameter.email.from.password.value == _|_ { 318 read: op.#Read & { 319 value: { 320 kind: "Secret" 321 apiVersion: "v1" 322 metadata: { 323 name: parameter.email.from.password.secretRef.name 324 namespace: context.namespace 325 } 326 } 327 } 328 329 stringValue: op.#ConvertString & {bt: base64.Decode(null, read.value.data[parameter.email.from.password.secretRef.key])} 330 email2: op.#SendEmail & { 331 from: { 332 address: parameter.email.from.address 333 if parameter.email.from.alias != _|_ { 334 alias: parameter.email.from.alias 335 } 336 password: stringValue.str 337 host: parameter.email.from.host 338 port: parameter.email.from.port 339 } 340 to: parameter.email.to 341 content: parameter.email.content 342 } 343 } 344 } 345 } 346