mirror of
https://github.com/kubevela/kubevela.git
synced 2026-05-17 06:46:47 +00:00
* Fix: Fixes the request workflowstep Signed-off-by: Brian Kane <briankane1@gmail.com> * Fix: Fixes the request workflowstep Signed-off-by: Brian Kane <briankane1@gmail.com> --------- Signed-off-by: Brian Kane <briankane1@gmail.com>
56 lines
972 B
CUE
56 lines
972 B
CUE
import (
|
|
"vela/op"
|
|
"vela/http"
|
|
"encoding/json"
|
|
)
|
|
|
|
request: {
|
|
alias: ""
|
|
attributes: {}
|
|
description: "Send request to the url"
|
|
annotations: {
|
|
"category": "External Integration"
|
|
}
|
|
labels: {}
|
|
type: "workflow-step"
|
|
}
|
|
|
|
template: {
|
|
req: http.#HTTPDo & {
|
|
$params: {
|
|
method: parameter.method
|
|
url: parameter.url
|
|
request: {
|
|
if parameter.body != _|_ {
|
|
body: json.Marshal(parameter.body)
|
|
}
|
|
if parameter.header != _|_ {
|
|
header: parameter.header
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
wait: op.#ConditionalWait & {
|
|
continue: req.$returns != _|_
|
|
message?: "Waiting for response from \(parameter.url)"
|
|
}
|
|
|
|
fail: op.#Steps & {
|
|
if req.$returns.statusCode > 400 {
|
|
requestFail: op.#Fail & {
|
|
message: "request of \(parameter.url) is fail: \(req.$returns.statusCode)"
|
|
}
|
|
}
|
|
}
|
|
|
|
response: json.Unmarshal(req.$returns.body)
|
|
|
|
parameter: {
|
|
url: string
|
|
method: *"GET" | "POST" | "PUT" | "DELETE"
|
|
body?: {...}
|
|
header?: [string]: string
|
|
}
|
|
}
|