scaffolder-backend: move v1 templater value injection into template converter
Signed-off-by: Johan Haals <johan.haals@gmail.com>
This commit is contained in:
committed by
Johan Haals
parent
b90767926f
commit
86fc6a0360
@@ -16,6 +16,7 @@
|
||||
|
||||
import { resolve as resolvePath, dirname } from 'path';
|
||||
import { TemplateEntityV1alpha1 } from '@backstage/catalog-model';
|
||||
import parseGitUrl from 'git-url-parse';
|
||||
import { TaskSpec } from './types';
|
||||
import {
|
||||
getTemplaterKey,
|
||||
@@ -26,7 +27,7 @@ import {
|
||||
|
||||
export function templateEntityToSpec(
|
||||
template: TemplateEntityV1alpha1,
|
||||
values: TemplaterValues,
|
||||
inputValues: TemplaterValues,
|
||||
): TaskSpec {
|
||||
const steps: TaskSpec['steps'] = [];
|
||||
|
||||
@@ -42,6 +43,13 @@ export function templateEntityToSpec(
|
||||
}
|
||||
const templater = getTemplaterKey(template);
|
||||
|
||||
const values = {
|
||||
...inputValues,
|
||||
destination: {
|
||||
git: parseGitUrl(inputValues.storePath),
|
||||
},
|
||||
} as TemplaterValues;
|
||||
|
||||
steps.push({
|
||||
id: 'prepare',
|
||||
name: 'Prepare',
|
||||
@@ -81,6 +89,7 @@ export function templateEntityToSpec(
|
||||
});
|
||||
|
||||
return {
|
||||
baseUrl: undefined, // not used by legacy actions
|
||||
values: {},
|
||||
steps,
|
||||
output: {
|
||||
|
||||
@@ -328,12 +328,7 @@ export async function createRouter(
|
||||
)
|
||||
.post('/v2/tasks', async (req, res) => {
|
||||
const templateName: string = req.body.templateName;
|
||||
const values: TemplaterValues = {
|
||||
...req.body.values,
|
||||
destination: {
|
||||
git: parseGitUrl(req.body.values.storePath),
|
||||
},
|
||||
};
|
||||
const values: TemplaterValues = req.body.values;
|
||||
const template = await entityClient.findTemplate(templateName);
|
||||
|
||||
let taskSpec;
|
||||
|
||||
Reference in New Issue
Block a user