From 721c75e44ada1c4895d19da1642831873ee5db6f Mon Sep 17 00:00:00 2001 From: Brian Kane Date: Wed, 13 Aug 2025 23:21:50 +0100 Subject: [PATCH] Fix: Fixes the request workflowstep (#6804) * Fix: Fixes the request workflowstep Signed-off-by: Brian Kane * Fix: Fixes the request workflowstep Signed-off-by: Brian Kane --------- Signed-off-by: Brian Kane --- app.yaml | 0 .../templates/defwithtemplate/request.yaml | 22 +++++++++++++------ .../internal/workflowstep/request.cue | 22 +++++++++++++------ 3 files changed, 30 insertions(+), 14 deletions(-) create mode 100644 app.yaml diff --git a/app.yaml b/app.yaml new file mode 100644 index 000000000..e69de29bb diff --git a/charts/vela-core/templates/defwithtemplate/request.yaml b/charts/vela-core/templates/defwithtemplate/request.yaml index 7f8387aa0..8461dfc01 100644 --- a/charts/vela-core/templates/defwithtemplate/request.yaml +++ b/charts/vela-core/templates/defwithtemplate/request.yaml @@ -4,7 +4,7 @@ apiVersion: core.oam.dev/v1beta1 kind: WorkflowStepDefinition metadata: annotations: - custom.definition.oam.dev/category: External Intergration + custom.definition.oam.dev/category: External Integration definition.oam.dev/alias: "" definition.oam.dev/description: Send request to the url name: request @@ -14,8 +14,8 @@ spec: cue: template: | import ( + "vela/op" "vela/http" - "vela/builtin" "encoding/json" ) @@ -33,14 +33,22 @@ spec: } } } - fail: { - if http.$returns.response.statusCode > 400 { - requestFail: builtin.#Fail & { - $params: message: "request of \(parameter.url) is fail: \(http.response.statusCode)" + + 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(http.$returns.response.body) + + response: json.Unmarshal(req.$returns.body) + parameter: { url: string method: *"GET" | "POST" | "PUT" | "DELETE" diff --git a/vela-templates/definitions/internal/workflowstep/request.cue b/vela-templates/definitions/internal/workflowstep/request.cue index b14562930..6d0aaa7b9 100644 --- a/vela-templates/definitions/internal/workflowstep/request.cue +++ b/vela-templates/definitions/internal/workflowstep/request.cue @@ -1,6 +1,6 @@ import ( + "vela/op" "vela/http" - "vela/builtin" "encoding/json" ) @@ -9,7 +9,7 @@ request: { attributes: {} description: "Send request to the url" annotations: { - "category": "External Intergration" + "category": "External Integration" } labels: {} type: "workflow-step" @@ -30,14 +30,22 @@ template: { } } } - fail: { - if http.$returns.response.statusCode > 400 { - requestFail: builtin.#Fail & { - $params: message: "request of \(parameter.url) is fail: \(http.response.statusCode)" + + 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(http.$returns.response.body) + + response: json.Unmarshal(req.$returns.body) + parameter: { url: string method: *"GET" | "POST" | "PUT" | "DELETE"