From 73e427c4054770c46a2550144bab447526b1938d Mon Sep 17 00:00:00 2001 From: Patrik Oldsberg Date: Tue, 31 May 2022 13:03:55 +0200 Subject: [PATCH] scaffolder: wrap dry-run log body in an outer object Signed-off-by: Patrik Oldsberg --- .../src/scaffolder/dryrun/createDryRunner.ts | 10 ++++++---- .../DryRunResults/DryRunResultsList.tsx | 2 +- .../DryRunResults/DryRunResultsView.test.tsx | 2 +- .../DryRunResults/DryRunResultsView.tsx | 8 +++++--- plugins/scaffolder/src/types.ts | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts b/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts index 8453f793b5..f2c3c13509 100644 --- a/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts +++ b/plugins/scaffolder-backend/src/scaffolder/dryrun/createDryRunner.ts @@ -40,7 +40,7 @@ interface DryRunInput { } interface DryRunResult { - log: JsonObject[]; + log: Array<{ body: JsonObject }>; directoryContents: SerializedFile[]; output: JsonObject; } @@ -81,7 +81,7 @@ export function createDryRunner(options: TemplateTesterCreateOptions) { }); const dryRunId = uuid(); - const log = new Array(); + const log = new Array<{ body: JsonObject }>(); const contentsPath = resolveSafeChildPath( options.workingDirectory, `dry-run-content-${dryRunId}`, @@ -118,8 +118,10 @@ export function createDryRunner(options: TemplateTesterCreateOptions) { return; } log.push({ - ...logMetadata, - message, + body: { + ...logMetadata, + message, + }, }); }, async complete() { diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx index 920f767cf8..462c3b58fd 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsList.tsx @@ -52,7 +52,7 @@ export function DryRunResultsList() { return ( {dryRun.results.map(result => { - const failed = result.log.some(l => l.status === 'failed'); + const failed = result.log.some(l => l.body.status === 'failed'); return ( { executable: false, }, ], - log: [{ message: 'Foo Message', stepId: 'foo' }], + log: [{ body: { message: 'Foo Message', stepId: 'foo' } }], output: { links: [{ title: 'Foo Link', url: 'http://example.com' }], }, diff --git a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.tsx b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.tsx index 275a1b9902..9c56039808 100644 --- a/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.tsx +++ b/plugins/scaffolder/src/components/TemplateEditorPage/DryRunResults/DryRunResultsView.tsx @@ -110,12 +110,14 @@ function LogContent() { } return ( selectedResult.steps.map(step => { - const stepLog = selectedResult.log.filter(l => l.stepId === step.id); + const stepLog = selectedResult.log.filter( + l => l.body.stepId === step.id, + ); return { id: step.id, name: step.name, - logString: stepLog.map(l => l.message).join('\n'), - status: stepLog[stepLog.length - 1]?.status ?? 'completed', + logString: stepLog.map(l => l.body.message).join('\n'), + status: stepLog[stepLog.length - 1]?.body.status ?? 'completed', }; }) ?? [] ); diff --git a/plugins/scaffolder/src/types.ts b/plugins/scaffolder/src/types.ts index c0b828314b..efdfcaff93 100644 --- a/plugins/scaffolder/src/types.ts +++ b/plugins/scaffolder/src/types.ts @@ -165,7 +165,7 @@ export interface ScaffolderDryRunResponse { base64Content: string; executable: boolean; }>; - log: Array; + log: Array>; steps: TaskStep[]; output: ScaffolderTaskOutput; }