diff --git a/charts/vela-core/templates/defwithtemplate/notification.yaml b/charts/vela-core/templates/defwithtemplate/notification.yaml index 2073e8549..bf25ac5a8 100644 --- a/charts/vela-core/templates/defwithtemplate/notification.yaml +++ b/charts/vela-core/templates/defwithtemplate/notification.yaml @@ -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 diff --git a/charts/vela-core/templates/defwithtemplate/webhook.yaml b/charts/vela-core/templates/defwithtemplate/webhook.yaml index 57a61f73f..982f5e643 100644 --- a/charts/vela-core/templates/defwithtemplate/webhook.yaml +++ b/charts/vela-core/templates/defwithtemplate/webhook.yaml @@ -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?: {...} } diff --git a/charts/vela-minimal/templates/defwithtemplate/notification.yaml b/charts/vela-minimal/templates/defwithtemplate/notification.yaml index 2073e8549..bf25ac5a8 100644 --- a/charts/vela-minimal/templates/defwithtemplate/notification.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/notification.yaml @@ -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 diff --git a/charts/vela-minimal/templates/defwithtemplate/webhook.yaml b/charts/vela-minimal/templates/defwithtemplate/webhook.yaml index 57a61f73f..982f5e643 100644 --- a/charts/vela-minimal/templates/defwithtemplate/webhook.yaml +++ b/charts/vela-minimal/templates/defwithtemplate/webhook.yaml @@ -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?: {...} } diff --git a/pkg/cue/model/value/value.go b/pkg/cue/model/value/value.go index 1610c3160..3c2fba1e0 100644 --- a/pkg/cue/model/value/value.go +++ b/pkg/cue/model/value/value.go @@ -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) diff --git a/pkg/stdlib/op.cue b/pkg/stdlib/op.cue index 02d00e767..ec9dfc95d 100644 --- a/pkg/stdlib/op.cue +++ b/pkg/stdlib/op.cue @@ -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" diff --git a/pkg/stdlib/pkgs/dingDing.cue b/pkg/stdlib/pkgs/dingDing.cue deleted file mode 100644 index 508bca0af..000000000 --- a/pkg/stdlib/pkgs/dingDing.cue +++ /dev/null @@ -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 - }] - } -} diff --git a/pkg/stdlib/pkgs/lark.cue b/pkg/stdlib/pkgs/lark.cue deleted file mode 100644 index 2edf8e0d0..000000000 --- a/pkg/stdlib/pkgs/lark.cue +++ /dev/null @@ -1,4 +0,0 @@ -#LarkMessage: { - msg_type: string - content: string -} diff --git a/pkg/stdlib/pkgs/slack.cue b/pkg/stdlib/pkgs/slack.cue deleted file mode 100644 index ee255772b..000000000 --- a/pkg/stdlib/pkgs/slack.cue +++ /dev/null @@ -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 -} diff --git a/pkg/workflow/tasks/custom/task.go b/pkg/workflow/tasks/custom/task.go index c5fb1c07d..f9497b4ea 100644 --- a/pkg/workflow/tasks/custom/task.go +++ b/pkg/workflow/tasks/custom/task.go @@ -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()) diff --git a/test/e2e-test/application_test.go b/test/e2e-test/application_test.go index 4a31604e1..312f99303 100644 --- a/test/e2e-test/application_test.go +++ b/test/e2e-test/application_test.go @@ -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 diff --git a/test/e2e-test/testdata/app/app12.yaml b/test/e2e-test/testdata/app/app12.yaml new file mode 100644 index 000000000..b9dcb0d79 --- /dev/null +++ b/test/e2e-test/testdata/app/app12.yaml @@ -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 \ No newline at end of file diff --git a/vela-templates/definitions/internal/workflowstep/notification.cue b/vela-templates/definitions/internal/workflowstep/notification.cue index aa6de7878..97c405b24 100644 --- a/vela-templates/definitions/internal/workflowstep/notification.cue +++ b/vela-templates/definitions/internal/workflowstep/notification.cue @@ -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 diff --git a/vela-templates/definitions/internal/workflowstep/webhook.cue b/vela-templates/definitions/internal/workflowstep/webhook.cue index d094f2b4c..4ee690fee 100644 --- a/vela-templates/definitions/internal/workflowstep/webhook.cue +++ b/vela-templates/definitions/internal/workflowstep/webhook.cue @@ -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?: {...} }