diff --git a/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts b/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts index d4dfb2dd17..8453f793b5 100644 --- a/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts +++ b/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts @@ -36,12 +36,12 @@ import { resolveSafeChildPath } from '@backstage/backend-common'; interface DryRunInput { spec: TaskSpec; secrets?: TaskSecrets; - content: SerializedFile[]; + directoryContents: SerializedFile[]; } interface DryRunResult { log: JsonObject[]; - content: SerializedFile[]; + directoryContents: SerializedFile[]; output: JsonObject; } @@ -88,7 +88,7 @@ export function createDryRunner(options: TemplateTesterCreateOptions) { ); try { - await deserializeDirectoryContents(contentsPath, input.content); + await deserializeDirectoryContents(contentsPath, input.directoryContents); const result = await workflowRunner.execute({ spec: { @@ -130,11 +130,11 @@ export function createDryRunner(options: TemplateTesterCreateOptions) { if (!contentPromise) { throw new Error('Content extraction step was skipped'); } - const content = await contentPromise; + const directoryContents = await contentPromise; return { log, - content, + directoryContents, output: result.output, }; } finally { diff --git a/plugins/scaffolder-backend/src/service/router.ts b/plugins/scaffolder-backend/src/service/router.ts index 01a6bbb235..61035c71fe 100644 --- a/plugins/scaffolder-backend/src/service/router.ts +++ b/plugins/scaffolder-backend/src/service/router.ts @@ -341,7 +341,7 @@ export async function createRouter( template: z.unknown(), values: z.record(z.unknown()), secrets: z.record(z.string()), - content: z.array( + directoryContents: z.array( z.object({ path: z.string(), base64Content: z.string() }), ), }); @@ -377,7 +377,7 @@ export async function createRouter( output: template.spec.output ?? {}, parameters: body.values as JsonObject, }, - content: (body.content ?? []).map(file => ({ + directoryContents: (body.directoryContents ?? []).map(file => ({ path: file.path, content: Buffer.from(file.base64Content, 'base64'), })), @@ -390,7 +390,7 @@ export async function createRouter( res.status(200).json({ ...result, steps, - content: result.content.map(file => ({ + directoryContents: result.directoryContents.map(file => ({ path: file.path, executable: file.executable, base64Content: file.content.toString('base64'), diff --git a/plugins/scaffolder/src/api.ts b/plugins/scaffolder/src/api.ts index 763d08b60a..f31bdf70b9 100644 --- a/plugins/scaffolder/src/api.ts +++ b/plugins/scaffolder/src/api.ts @@ -187,7 +187,7 @@ export class ScaffolderClient implements ScaffolderApi { template: options.template, values: options.values, secrets: options.secrets, - content: options.content, + directoryContents: options.directoryContents, }), }); diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx index 97112f75df..b1fe8a19ff 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunContext.tsx @@ -108,7 +108,7 @@ export function DryRunProvider(props: DryRunProviderProps) { template: parsed, values: options.values, secrets: {}, - content: options.files.map(file => ({ + directoryContents: options.files.map(file => ({ path: file.path, base64Content: btoa(file.content), })), diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResults.test.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResults.test.tsx index 7b08544736..bc3354cc46 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResults.test.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResults.test.tsx @@ -51,7 +51,12 @@ function DryRunRemote({ } const mockScaffolderApi = { - dryRun: async () => ({ content: [], log: [], output: {}, steps: [] }), + dryRun: async () => ({ + directoryContents: [], + log: [], + output: {}, + steps: [], + }), }; describe('DryRunResults', () => { diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.test.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.test.tsx index ca35f71e95..65eb59c84a 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.test.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.test.tsx @@ -40,7 +40,12 @@ function DryRunRemote({ execute }: { execute?: number }) { } const mockScaffolderApi = { - dryRun: async () => ({ content: [], log: [], output: {}, steps: [] }), + dryRun: async () => ({ + directoryContents: [], + log: [], + output: {}, + steps: [], + }), }; describe('DryRunResultsList', () => { diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx index a26d6e3803..3a6bf0aff8 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.test.tsx @@ -55,7 +55,7 @@ describe('DryRunResultsView', () => { scaffolderApiRef, { dryRun: async () => ({ - content: [ + directoryContents: [ { path: 'foo.txt', base64Content: btoa('Foo Content'), diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.tsx index f854f504ce..275a1b9902 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.tsx @@ -61,13 +61,13 @@ function FilesContent() { const classes = useStyles(); const { selectedResult } = useDryRun(); const [selectedPath, setSelectedPath] = useState(''); - const selectedFile = selectedResult?.content.find( + const selectedFile = selectedResult?.directoryContents.find( f => f.path === selectedPath, ); useEffect(() => { if (selectedResult) { - const [firstFile] = selectedResult.content; + const [firstFile] = selectedResult.directoryContents; if (firstFile) { setSelectedPath(firstFile.path); } else { @@ -85,7 +85,7 @@ function FilesContent() { file.path)} + filePaths={selectedResult.directoryContents.map(file => file.path)} />