From e8bbda8a5b7f74c2f0cd661083089143733bc5ce Mon Sep 17 00:00:00 2001 From: Ruben Fiszel Date: Sun, 30 Oct 2022 17:28:59 +0100 Subject: [PATCH] fix input transforms for resource and variable --- backend/windmill-api/openapi.yaml | 18 +++++++++++++++++- backend/windmill-worker/src/worker.rs | 14 +++++--------- 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/backend/windmill-api/openapi.yaml b/backend/windmill-api/openapi.yaml index 06b1edb4ea..f14e1b443d 100644 --- a/backend/windmill-api/openapi.yaml +++ b/backend/windmill-api/openapi.yaml @@ -1321,12 +1321,28 @@ paths: - $ref: "#/components/parameters/Path" responses: "200": - description: resource deleted + description: resource content: application/json: schema: $ref: "#/components/schemas/Resource" + /w/{workspace}/resources/get_value/{path}: + get: + summary: get resource value + operationId: getResourceValue + tags: + - resource + parameters: + - $ref: "#/components/parameters/WorkspaceId" + - $ref: "#/components/parameters/Path" + responses: + "200": + description: resource value + content: + application/json: + schema: {} + /w/{workspace}/resources/exists/{path}: get: summary: does resource exists diff --git a/backend/windmill-worker/src/worker.rs b/backend/windmill-worker/src/worker.rs index a0aa6f70a3..5630676529 100644 --- a/backend/windmill-worker/src/worker.rs +++ b/backend/windmill-worker/src/worker.rs @@ -734,7 +734,7 @@ async fn transform_json_value( Value::String(y) if y.starts_with("$var:") => { let path = y.strip_prefix("$var:").unwrap(); let v = client - .get_variable(workspace, path, None) + .get_variable(workspace, path, Some(true)) .await .map_err(to_anyhow) .map(|v| v.into_inner())? @@ -753,15 +753,11 @@ async fn transform_json_value( )); } let v = client - .get_resource(workspace, path) + .get_resource_value(workspace, path) .await - .map_err(to_anyhow)?; - transform_json_value( - client, - workspace, - serde_json::to_value(v.into_inner()).map_err(to_anyhow)?, - ) - .await + .map_err(to_anyhow)? + .into_inner(); + transform_json_value(client, workspace, v).await } Value::Object(mut m) => { for (a, b) in m.clone().into_iter() {