message: scaffolder-backend: add support for deep templating in task steps
diff: @@ -94,22 +94,20 @@ export class TaskWorker {
  throw new Error(`Action '${step.action}' does not exist`);
  }
  - const parameters: { [name: string]: JsonValue } = {};
  - for (const [name, maybeTemplateStr] of Object.entries(
  - step.parameters ?? {},
  - )) {
  - if (typeof maybeTemplateStr === 'string') {
  - const value = handlebars.compile(maybeTemplateStr, {
  + const parameters = JSON.parse(
  + JSON.stringify(step.parameters),
  + (_key, value) => {
  + if (typeof value === 'string') {
  + return handlebars.compile(value, {
  noEscape: true,
  strict: true,
  data: false,
  preventIndent: true,
  })(templateCtx);
  - parameters[name] = value;
  - } else {
  - parameters[name] = maybeTemplateStr;
  - }
  }
  + return value;
  + },
  + );
  const stepOutputs: { [name: string]: JsonValue } = {};
  @@ -138,16 +136,19 @@ export class TaskWorker {
  }
  }
  - const output = Object.fromEntries(
  - Object.entries(task.spec.output).map(([name, templateStr]) => {
  - const value = handlebars.compile(templateStr, {
  + const output = JSON.parse(
  + JSON.stringify(task.spec.output),
  + (_key, value) => {
  + if (typeof value === 'string') {
  + return handlebars.compile(value, {
  noEscape: true,
  strict: true,
  data: false,
  preventIndent: true,
  })(templateCtx);
  - return [name, value];
  - }),
  + }
  + return value;
  + },
  );
  await task.complete('completed', { output });
  