mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-20 08:13:23 +00:00
* Fix: update duration format handling and enhance StringParam with enum string support Signed-off-by: Anaswara Suresh M K <anaswarasuresh2212@gmail.com> Signed-off-by: vishal210893 <vishal210893@gmail.com> * date build-push-image workflow and improve image handlinggp Signed-off-by: Anaswara Suresh M K <anaswarasuresh2212@gmail.com> * chore: commit to re run pipeline Signed-off-by: Anaswara Suresh M K <anaswarasuresh2212@gmail.com> * Feat: add deduplication and field order tracking in collections and array elements Signed-off-by: Vaibhav Agrawal <vaibhav.agrawal0096@gmail.com> * Fix: update test expectation for parameter data count in workflow step Signed-off-by: Vaibhav Agrawal <vaibhav.agrawal0096@gmail.com> * Feat: add tests for label handling and template body in workflow steps Signed-off-by: Vaibhav Agrawal <vaibhav.agrawal0096@gmail.com> * Feat: add tests for label handling and template body in workflow steps Signed-off-by: Vaibhav Agrawal <vaibhav.agrawal0096@gmail.com> * Refactor: rename AllowString to OpenEnum for clarity in enum handling Signed-off-by: Vaibhav Agrawal <vaibhav.agrawal0096@gmail.com> * Chore: format StringParam struct for improved readability Signed-off-by: Vaibhav Agrawal <vaibhav.agrawal0096@gmail.com> --------- Signed-off-by: Anaswara Suresh M K <anaswarasuresh2212@gmail.com> Signed-off-by: vishal210893 <vishal210893@gmail.com> Signed-off-by: Vaibhav Agrawal <vaibhav.agrawal0096@gmail.com>
95 lines
1.9 KiB
CUE
95 lines
1.9 KiB
CUE
import (
|
|
"vela/http"
|
|
"vela/kube"
|
|
"vela/util"
|
|
"encoding/json"
|
|
"encoding/base64"
|
|
)
|
|
|
|
"webhook": {
|
|
type: "workflow-step"
|
|
annotations: {
|
|
"category": "External Intergration"
|
|
}
|
|
labels: {}
|
|
description: "Send a POST request to the specified Webhook URL. If no request body is specified, the current Application body will be sent by default."
|
|
}
|
|
template: {
|
|
data: {
|
|
if parameter.data == _|_ {
|
|
read: kube.#Read & {
|
|
$params: {
|
|
value: {
|
|
apiVersion: "core.oam.dev/v1beta1"
|
|
kind: "Application"
|
|
metadata: {
|
|
name: context.name
|
|
namespace: context.namespace
|
|
}
|
|
}
|
|
}
|
|
}
|
|
value: json.Marshal(read.$returns.value)
|
|
}
|
|
if parameter.data != _|_ {
|
|
value: json.Marshal(parameter.data)
|
|
}
|
|
}
|
|
webhook: {
|
|
if parameter.url.value != _|_ {
|
|
req: http.#HTTPDo & {
|
|
$params: {
|
|
method: "POST"
|
|
url: parameter.url.value
|
|
request: {
|
|
body: data.value
|
|
header: "Content-Type": "application/json"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if parameter.url.secretRef != _|_ && parameter.url.value == _|_ {
|
|
read: kube.#Read & {
|
|
$params: {
|
|
value: {
|
|
apiVersion: "v1"
|
|
kind: "Secret"
|
|
metadata: {
|
|
name: parameter.url.secretRef.name
|
|
namespace: context.namespace
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
stringValue: util.#ConvertString & {$params: bt: base64.Decode(null, read.$returns.value.data[parameter.url.secretRef.key])}
|
|
req: http.#HTTPDo & {
|
|
$params: {
|
|
method: "POST"
|
|
url: stringValue.$returns.str
|
|
request: {
|
|
body: data.value
|
|
header: "Content-Type": "application/json"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
parameter: {
|
|
// +usage=Specify the webhook url
|
|
url: close({
|
|
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?: {...}
|
|
}
|
|
}
|