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