Fix: fix notification workflow step (#4656)

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>

Signed-off-by: FogDong <dongtianxin.tx@alibaba-inc.com>
This commit is contained in:
Tianxin Dong
2022-08-25 11:47:02 +08:00
committed by GitHub
parent 514ef4cc42
commit 20bd1eeec5
14 changed files with 159 additions and 196 deletions

View File

@@ -23,14 +23,14 @@ spec:
url: {
// +usage=the url address content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the message that you want to sent, refer to [Lark messaging](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN#8b0f2a1b).
message: {
// +usage=msg_type can be text, post, image, interactive, share_chat, share_user, audio, media, file, sticker
@@ -45,56 +45,56 @@ spec:
url: {
// +usage=the url address content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +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)
message: {
// +usage=Specify the message content of dingtalk notification
text?: *null | {
text?: *null | close({
content: string
}
})
// +usage=msgType can be text, link, mardown, actionCard, feedCard
msgtype: *"text" | "link" | "markdown" | "actionCard" | "feedCard"
link?: *null | {
link?: *null | close({
text?: string
title?: string
messageUrl?: string
picUrl?: string
}
markdown?: *null | {
})
markdown?: *null | close({
text: string
title: string
}
at?: *null | {
})
at?: *null | close({
atMobiles?: *null | [...string]
isAtAll?: bool
}
actionCard?: *null | {
})
actionCard?: *null | close({
text: string
title: string
hideAvatar: string
btnOrientation: string
singleTitle: string
singleURL: string
btns: *null | [...*null | {
btns: *null | close([...*null | close({
title: string
actionURL: string
}]
}
feedCard?: *null | {
links: *null | [...*null | {
})])
})
feedCard?: *null | close({
links: *null | close([...*null | close({
text?: string
title?: string
messageUrl?: string
picUrl?: string
}]
}
})])
})
}
}
// +usage=Please fulfill its url and message if you want to send Slack messages
@@ -103,23 +103,23 @@ spec:
url: {
// +usage=the url address content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the message that you want to sent, refer to [slack messaging](https://api.slack.com/reference/messaging/payload)
message: {
// +usage=Specify the message text for slack notification
text: string
blocks?: *null | [...block]
attachments?: *null | {
blocks?: *null | close([...block])
attachments?: *null | close({
blocks?: *null | [...block]
color?: string
}
})
thread_ts?: string
// +usage=Specify the message text format in markdown for slack notification
mrkdwn?: *true | bool
@@ -137,14 +137,14 @@ spec:
password: {
// +usage=the password content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the host of your email
host: string
// +usage=Specify the port of the email host, default to 587

View File

@@ -72,14 +72,14 @@ spec:
// +usage=Specify the webhook url
url: {
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the data you want to send
data?: {...}
}

View File

@@ -23,14 +23,14 @@ spec:
url: {
// +usage=the url address content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the message that you want to sent, refer to [Lark messaging](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN#8b0f2a1b).
message: {
// +usage=msg_type can be text, post, image, interactive, share_chat, share_user, audio, media, file, sticker
@@ -45,56 +45,56 @@ spec:
url: {
// +usage=the url address content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +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)
message: {
// +usage=Specify the message content of dingtalk notification
text?: *null | {
text?: *null | close({
content: string
}
})
// +usage=msgType can be text, link, mardown, actionCard, feedCard
msgtype: *"text" | "link" | "markdown" | "actionCard" | "feedCard"
link?: *null | {
link?: *null | close({
text?: string
title?: string
messageUrl?: string
picUrl?: string
}
markdown?: *null | {
})
markdown?: *null | close({
text: string
title: string
}
at?: *null | {
})
at?: *null | close({
atMobiles?: *null | [...string]
isAtAll?: bool
}
actionCard?: *null | {
})
actionCard?: *null | close({
text: string
title: string
hideAvatar: string
btnOrientation: string
singleTitle: string
singleURL: string
btns: *null | [...*null | {
btns: *null | close([...*null | close({
title: string
actionURL: string
}]
}
feedCard?: *null | {
links: *null | [...*null | {
})])
})
feedCard?: *null | close({
links: *null | close([...*null | close({
text?: string
title?: string
messageUrl?: string
picUrl?: string
}]
}
})])
})
}
}
// +usage=Please fulfill its url and message if you want to send Slack messages
@@ -103,23 +103,23 @@ spec:
url: {
// +usage=the url address content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the message that you want to sent, refer to [slack messaging](https://api.slack.com/reference/messaging/payload)
message: {
// +usage=Specify the message text for slack notification
text: string
blocks?: *null | [...block]
attachments?: *null | {
blocks?: *null | close([...block])
attachments?: *null | close({
blocks?: *null | [...block]
color?: string
}
})
thread_ts?: string
// +usage=Specify the message text format in markdown for slack notification
mrkdwn?: *true | bool
@@ -137,14 +137,14 @@ spec:
password: {
// +usage=the password content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the host of your email
host: string
// +usage=Specify the port of the email host, default to 587

View File

@@ -72,14 +72,14 @@ spec:
// +usage=Specify the webhook url
url: {
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the data you want to send
data?: {...}
}

View File

@@ -575,6 +575,9 @@ func (iter *stepsIterator) assemble() {
}
var addFields []*field
for i := 0; i < st.Len(); i++ {
if st.Field(i).Value.IncompleteKind() == cue.TopKind {
continue
}
name := st.Field(i).Name
attr := st.Field(i).Value.Attribute("step")
no, err := attr.Int(0)

View File

@@ -107,7 +107,7 @@ import (
}
#DingTalk: #Steps & {
message: dingDing.#DingMessage
message: {...}
dingUrl: string
do: http.#Do & {
method: "POST"
@@ -120,7 +120,7 @@ import (
}
#Lark: #Steps & {
message: lark.#LarkMessage
message: {...}
larkUrl: string
do: http.#Do & {
method: "POST"
@@ -133,7 +133,7 @@ import (
}
#Slack: #Steps & {
message: slack.#SlackMessage
message: {...}
slackUrl: string
do: http.#Do & {
method: "POST"

View File

@@ -1,40 +0,0 @@
#DingMessage: {
text?: *null | {
content: string
}
msgtype: string
link?: *null | {
text?: string
title?: string
messageUrl?: string
picUrl?: string
}
markdown?: *null | {
text: string
title: string
}
at?: *null | {
atMobiles?: *null | [...string]
isAtAll?: bool
}
actionCard?: *null | {
text: string
title: string
hideAvatar: string
btnOrientation: string
singleTitle: string
singleURL: string
btns: *null | [...*null | {
title: string
actionURL: string
}]
}
feedCard?: *null | {
links: *null | [...*null | {
text?: string
title?: string
messageUrl?: string
picUrl?: string
}]
}
}

View File

@@ -1,4 +0,0 @@
#LarkMessage: {
msg_type: string
content: string
}

View File

@@ -1,60 +0,0 @@
#SlackMessage: {
text: string
blocks?: *null | [...#block]
attachments?: *null | {
blocks?: *null | [...#block]
color?: string
}
thread_ts?: string
mrkdwn?: *true | bool
}
#block: {
type: string
block_id?: string
elements?: [...{
type: string
action_id?: string
url?: string
value?: string
style?: string
text?: #textType
confirm?: {
title: #textType
text: #textType
confirm: #textType
deny: #textType
style?: string
}
options?: [...#option]
initial_options?: [...#option]
placeholder?: #textType
initial_date?: string
image_url?: string
alt_text?: string
option_groups?: [...#option]
max_selected_items?: int
initial_value?: string
multiline?: bool
min_length?: int
max_length?: int
dispatch_action_config?: {
trigger_actions_on?: [...string]
}
initial_time?: string
}]
}
#textType: {
type: string
text: string
emoji?: bool
verbatim?: bool
}
#option: {
text: #textType
value: string
description?: #textType
url?: string
}

View File

@@ -477,8 +477,11 @@ func (exec *executor) doSteps(ctx wfContext.Context, v *value.Value) error {
}
return v.StepByFields(func(fieldName string, in *value.Value) (bool, error) {
if in.CueValue().IncompleteKind() == cue.BottomKind {
// continue if the field is incomplete
return false, nil
errInfo, err := sets.ToString(in.CueValue())
if err != nil {
errInfo = "value is _|_"
}
return true, errors.New(errInfo + "(bottom kind)")
}
if retErr := in.CueValue().Err(); retErr != nil {
errInfo, err := sets.ToString(in.CueValue())

View File

@@ -317,6 +317,17 @@ var _ = Describe("Application Normal tests", func() {
verifyApplicationWorkflowTerminated(newApp.Namespace, newApp.Name)
})
It("Test app with notification and custom if", func() {
By("Apply an application")
var newApp v1beta1.Application
Expect(common.ReadYamlToObject("testdata/app/app12.yaml", &newApp)).Should(BeNil())
newApp.Namespace = namespaceName
Expect(k8sClient.Create(ctx, &newApp)).Should(BeNil())
By("check application status")
verifyWorkloadRunningExpected("comp-custom-if", 1, "crccheck/hello-world")
})
It("Test wait suspend", func() {
By("Apply wait suspend application")
var newApp v1beta1.Application

50
test/e2e-test/testdata/app/app12.yaml vendored Normal file
View File

@@ -0,0 +1,50 @@
apiVersion: core.oam.dev/v1beta1
kind: Application
metadata:
name: workflow-custom-if
namespace: default
spec:
components:
- name: comp-custom-if
type: webservice
properties:
image: crccheck/hello-world
port: 8000
traits:
workflow:
steps:
- name: apply
type: apply-component
properties:
component: comp-custom-if
outputs:
- name: comp-output
valueFrom: context.name
- name: notification
type: notification
inputs:
- from: comp-output
parameterKey: slack.message.text
if: inputs["comp-output"] == "custom-if"
properties:
slack:
url:
value: https://kubevela.io
- name: notification-skip
type: notification
if: status.notification.failed
properties:
slack:
url:
value: https://kubevela.io
message:
text: skip
- name: notification-succeeded
type: notification
if: status.notification.succeeded
properties:
slack:
url:
value: https://kubevela.io
message:
text: succeeded

View File

@@ -18,14 +18,14 @@ template: {
url: {
// +usage=the url address content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the message that you want to sent, refer to [Lark messaging](https://open.feishu.cn/document/ukTMukTMukTM/ucTM5YjL3ETO24yNxkjN#8b0f2a1b).
message: {
// +usage=msg_type can be text, post, image, interactive, share_chat, share_user, audio, media, file, sticker
@@ -40,56 +40,56 @@ template: {
url: {
// +usage=the url address content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +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)
message: {
// +usage=Specify the message content of dingtalk notification
text?: *null | {
text?: *null | close({
content: string
}
})
// +usage=msgType can be text, link, mardown, actionCard, feedCard
msgtype: *"text" | "link" | "markdown" | "actionCard" | "feedCard"
link?: *null | {
link?: *null | close({
text?: string
title?: string
messageUrl?: string
picUrl?: string
}
markdown?: *null | {
})
markdown?: *null | close({
text: string
title: string
}
at?: *null | {
})
at?: *null | close({
atMobiles?: *null | [...string]
isAtAll?: bool
}
actionCard?: *null | {
})
actionCard?: *null | close({
text: string
title: string
hideAvatar: string
btnOrientation: string
singleTitle: string
singleURL: string
btns: *null | [...*null | {
btns: *null | close([...*null | close({
title: string
actionURL: string
}]
}
feedCard?: *null | {
links: *null | [...*null | {
})])
})
feedCard?: *null | close({
links: *null | close([...*null | close({
text?: string
title?: string
messageUrl?: string
picUrl?: string
}]
}
})])
})
}
}
// +usage=Please fulfill its url and message if you want to send Slack messages
@@ -98,23 +98,23 @@ template: {
url: {
// +usage=the url address content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the message that you want to sent, refer to [slack messaging](https://api.slack.com/reference/messaging/payload)
message: {
// +usage=Specify the message text for slack notification
text: string
blocks?: *null | [...block]
attachments?: *null | {
blocks?: *null | close([...block])
attachments?: *null | close({
blocks?: *null | [...block]
color?: string
}
})
thread_ts?: string
// +usage=Specify the message text format in markdown for slack notification
mrkdwn?: *true | bool
@@ -132,14 +132,14 @@ template: {
password: {
// +usage=the password content in string
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the host of your email
host: string
// +usage=Specify the port of the email host, default to 587

View File

@@ -67,14 +67,14 @@ template: {
// +usage=Specify the webhook url
url: {
value: string
} | {
} | close({
secretRef: {
// +usage=name is the name of the secret
name: string
// +usage=key is the key in the secret
key: string
}
}
})
// +usage=Specify the data you want to send
data?: {...}
}