chore: reworking redacting of secrets and updating deprecated use of logStream

Signed-off-by: blam <ben@blam.sh>
This commit is contained in:
blam
2024-03-08 14:18:09 +01:00
parent 4522e6ef02
commit 98e369c316
4 changed files with 17 additions and 6 deletions
@@ -25,7 +25,7 @@ import { ScmIntegrations } from '@backstage/integration';
import commandExists from 'command-exists';
import fs from 'fs-extra';
import path, { resolve as resolvePath } from 'path';
import { Writable } from 'stream';
import { PassThrough, Writable } from 'stream';
import {
createTemplateAction,
fetchContents,
@@ -245,10 +245,15 @@ export function createFetchCookiecutterAction(options: {
_extensions: ctx.input.extensions,
};
const logStream = new PassThrough();
logStream.on('data', chunk => {
ctx.logger.info(chunk.toString());
});
// Will execute the template in ./template and put the result in ./result
await cookiecutter.run({
workspacePath: workDir,
logStream: ctx.logStream,
logStream,
values: values,
imageName: ctx.input.imageName,
templateDir: templateDir,
@@ -26,6 +26,7 @@ import {
import { resolve as resolvePath } from 'path';
import { RailsNewRunner } from './railsNewRunner';
import { PassThrough } from 'stream';
/**
* Creates the `fetch:rails` Scaffolder action.
@@ -215,10 +216,15 @@ export function createFetchRailsAction(options: {
throw new Error(`Image ${imageName} is not allowed`);
}
const logStream = new PassThrough();
logStream.on('data', chunk => {
ctx.logger.info(chunk.toString());
});
// Will execute the template in ./template and put the result in ./result
await templateRunner.run({
workspacePath: workDir,
logStream: ctx.logStream,
logStream,
values: { ...ctx.input.values, imageName },
});
@@ -49,7 +49,7 @@ export function createCatalogWriteAction() {
examples,
supportsDryRun: true,
async handler(ctx) {
ctx.logStream.write(`Writing catalog-info.yaml`);
ctx.logger.info(`Writing catalog-info.yaml`);
const { filePath, entity } = ctx.input;
const path = filePath ?? 'catalog-info.yaml';
@@ -60,12 +60,12 @@ export function createDebugLogAction() {
ctx.logger.info(JSON.stringify(ctx.input, null, 2));
if (ctx.input?.message) {
ctx.logStream.write(ctx.input.message);
ctx.logger.info(ctx.input.message);
}
if (ctx.input?.listWorkspace) {
const files = await recursiveReadDir(ctx.workspacePath);
ctx.logStream.write(
ctx.logger.info(
`Workspace:\n${files
.map(f => ` - ${relative(ctx.workspacePath, f)}`)
.join('\n')}`,