Minor updates to the context system and also adding env vars to automation context.
This commit is contained in:
parent
10d1455b35
commit
5e68a4d814
|
@ -147,6 +147,7 @@ export async function preview(ctx: any) {
|
|||
parameters,
|
||||
transformer,
|
||||
queryId,
|
||||
// have to pass down to the thread runner - can't put into context now
|
||||
environmentVariables: envVars,
|
||||
ctx: {
|
||||
user: ctx.user,
|
||||
|
@ -233,6 +234,7 @@ async function execute(
|
|||
parameters: enrichedParameters,
|
||||
transformer: query.transformer,
|
||||
queryId: ctx.params.queryId,
|
||||
// have to pass down to the thread runner - can't put into context now
|
||||
environmentVariables: envVars,
|
||||
ctx: {
|
||||
user: ctx.user,
|
||||
|
|
|
@ -24,6 +24,7 @@ export interface TriggerOutput {
|
|||
|
||||
export interface AutomationContext extends AutomationResults {
|
||||
steps: any[]
|
||||
env?: Record<string, string>
|
||||
trigger: any
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ async function enrichDatasourceWithValues(datasource: Datasource) {
|
|||
const processed = processObjectSync(cloned, env)
|
||||
return {
|
||||
datasource: processed as Datasource,
|
||||
envVars: env.env as Record<string, string>,
|
||||
envVars: env as Record<string, string>,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ export async function enrichContext(
|
|||
return enrichedQuery
|
||||
}
|
||||
const env = await getEnvironmentVariables()
|
||||
const parameters = { ...inputs, ...env }
|
||||
const parameters = { ...inputs, env }
|
||||
// enrich the fields with dynamic parameters
|
||||
for (let key of Object.keys(fields)) {
|
||||
if (fields[key] == null) {
|
||||
|
|
|
@ -12,5 +12,5 @@ export async function getEnvironmentVariables() {
|
|||
|
||||
envVars = await environmentVariables.fetchValues(appEnv)
|
||||
}
|
||||
return { env: envVars }
|
||||
return envVars
|
||||
}
|
||||
|
|
|
@ -16,7 +16,6 @@ import { storeLog } from "../automations/logging"
|
|||
import { Automation, AutomationStep, AutomationStatus } from "@budibase/types"
|
||||
import {
|
||||
LoopStep,
|
||||
LoopStepType,
|
||||
LoopInput,
|
||||
TriggerOutput,
|
||||
AutomationContext,
|
||||
|
@ -26,6 +25,7 @@ import { WorkerCallback } from "./definitions"
|
|||
import { context, logging } from "@budibase/backend-core"
|
||||
import { processObject } from "@budibase/string-templates"
|
||||
import { cloneDeep } from "lodash/fp"
|
||||
import * as sdkUtils from "../sdk/utils"
|
||||
import env from "../environment"
|
||||
const FILTER_STEP_ID = actions.ACTION_DEFINITIONS.FILTER.stepId
|
||||
const LOOP_STEP_ID = actions.ACTION_DEFINITIONS.LOOP.stepId
|
||||
|
@ -221,6 +221,8 @@ class Orchestrator {
|
|||
}
|
||||
|
||||
async execute() {
|
||||
// this will retrieve from context created at start of thread
|
||||
this._context.env = await sdkUtils.getEnvironmentVariables()
|
||||
let automation = this._automation
|
||||
let stopped = false
|
||||
let loopStep: AutomationStep | undefined = undefined
|
||||
|
@ -474,7 +476,11 @@ export const removeStalled = async (job: Job) => {
|
|||
throw new Error("Unable to execute, event doesn't contain app ID.")
|
||||
}
|
||||
await context.doInAppContext(appId, async () => {
|
||||
const automationOrchestrator = new Orchestrator(job)
|
||||
await automationOrchestrator.stopCron("stalled")
|
||||
const envVars = await sdkUtils.getEnvironmentVariables()
|
||||
// put into automation thread for whole context
|
||||
await context.doInEnvironmentContext(envVars, async () => {
|
||||
const automationOrchestrator = new Orchestrator(job)
|
||||
await automationOrchestrator.stopCron("stalled")
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue