mirror of
https://github.com/windmill-labs/windmill.git
synced 2026-08-25 16:02:11 +00:00
feat(cli): add resolveDefaultResource
This commit is contained in:
@@ -80,6 +80,19 @@ export async function getResource(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolve a resource value in case the default value was picked because the input payload was undefined
|
||||
* @param obj resource value or path of the resource under the format `$res:path`
|
||||
* @returns resource value
|
||||
*/
|
||||
export async function resolveDefaultResource(obj: any): Promise<any> {
|
||||
if (typeof obj === "string" && obj.startsWith("$res:")) {
|
||||
return await getResource(obj.substring(5), true);
|
||||
} else {
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full resource value by path
|
||||
* @param path path of the resource, default to internal state path
|
||||
|
||||
Reference in New Issue
Block a user