feat(config-refs): introduce config reference parsing and resolution
- Added a new module for parsing and resolving configuration references, supporting `$SECRET_`, `$KV_`, and `$CONTEXT_` prefixes. - Implemented functions to handle the resolution of these references within workflow contexts, enhancing the flexibility of configuration management. - Updated existing workflows and scripts to utilize the new config reference resolution, improving data handling and context management. - Introduced a smoke test to validate the functionality of the config reference system, ensuring robustness and reliability. This update significantly enhances the ability to manage dynamic configurations within workflows, improving overall usability and maintainability.
This commit is contained in:
@@ -30,6 +30,7 @@ import {
|
||||
sendHttpPageOrJson,
|
||||
sendSuccessPage,
|
||||
} from "./http-trigger-auth.js";
|
||||
import { resolveConfigRefs } from "./config-refs.js";
|
||||
|
||||
/**
|
||||
* @typedef {{ owner: string, file: string, workflow: any }} WorkflowEntry
|
||||
@@ -137,9 +138,12 @@ export function createRegistry(server) {
|
||||
|
||||
const onDisk = fsStore.listOwnerYamlFiles(owner);
|
||||
for (const file of onDisk) {
|
||||
if (!workflowFiles.includes(file)) {
|
||||
log.warn(`Workflow file not in registers.yaml: ${owner}/${file}`);
|
||||
if (workflowFiles.includes(file)) continue;
|
||||
if (file.startsWith("dev-")) {
|
||||
workflowFiles.push(file);
|
||||
continue;
|
||||
}
|
||||
log.warn(`Workflow file not in registers.yaml: ${owner}/${file}`);
|
||||
}
|
||||
|
||||
for (const file of workflowFiles) {
|
||||
@@ -572,21 +576,26 @@ export function createRegistry(server) {
|
||||
depth,
|
||||
) {
|
||||
const script = parsed.kind === "set" ? SET_STEP_SCRIPT : parsed.script;
|
||||
const config = parsed.config;
|
||||
const unresolvedConfig = parsed.config;
|
||||
const incomingContext = normalizeContext(ctx.context);
|
||||
const stepCtx = {
|
||||
data: ctx.data,
|
||||
context: incomingContext,
|
||||
config,
|
||||
};
|
||||
const step = await store.startStep({
|
||||
runId,
|
||||
index,
|
||||
script,
|
||||
config,
|
||||
config: unresolvedConfig,
|
||||
});
|
||||
const stepLog = runLog.child({ stepId: step.id, script });
|
||||
try {
|
||||
const config = await resolveConfigRefs(unresolvedConfig, {
|
||||
owner,
|
||||
workflowKey: key,
|
||||
context: incomingContext,
|
||||
});
|
||||
const stepCtx = {
|
||||
data: ctx.data,
|
||||
context: incomingContext,
|
||||
config,
|
||||
};
|
||||
if (parsed.when) {
|
||||
const whenResult = await evaluateJsonata(parsed.when, stepCtx);
|
||||
if (!isJsonataTruthy(whenResult)) {
|
||||
|
||||
Reference in New Issue
Block a user