@backstage/plugin-scaffolder-backend 1.22.0-next.1 → 1.22.0-next.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/alpha/package.json +1 -1
- package/dist/alpha.cjs.js +1 -1
- package/dist/cjs/{router-1665319e.cjs.js → router-52d79583.cjs.js} +154 -12
- package/dist/cjs/router-52d79583.cjs.js.map +1 -0
- package/dist/index.cjs.js +1 -1
- package/package.json +48 -47
- package/dist/cjs/router-1665319e.cjs.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,41 @@
|
|
|
1
1
|
# @backstage/plugin-scaffolder-backend
|
|
2
2
|
|
|
3
|
+
## 1.22.0-next.2
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- e9663a9: Move away from using `ctx.logStream`
|
|
8
|
+
- e9663a9: Enable the redaction of secrets using the redacting logger and the secrets from the `TaskSpec`
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- 703ebc9: Fix support for unauthenticated requests to create scaffolder tasks
|
|
13
|
+
- Updated dependencies
|
|
14
|
+
- @backstage/plugin-scaffolder-node@0.4.0-next.2
|
|
15
|
+
- @backstage/plugin-scaffolder-backend-module-azure@0.1.6-next.2
|
|
16
|
+
- @backstage/plugin-scaffolder-backend-module-bitbucket-cloud@0.1.4-next.2
|
|
17
|
+
- @backstage/plugin-scaffolder-backend-module-bitbucket-server@0.1.4-next.2
|
|
18
|
+
- @backstage/plugin-scaffolder-backend-module-bitbucket@0.2.4-next.2
|
|
19
|
+
- @backstage/integration@1.9.1-next.2
|
|
20
|
+
- @backstage/plugin-scaffolder-backend-module-gitlab@0.3.0-next.2
|
|
21
|
+
- @backstage/plugin-scaffolder-backend-module-gitea@0.1.4-next.2
|
|
22
|
+
- @backstage/catalog-client@1.6.1-next.1
|
|
23
|
+
- @backstage/plugin-scaffolder-backend-module-gerrit@0.1.6-next.2
|
|
24
|
+
- @backstage/plugin-scaffolder-backend-module-github@0.2.4-next.2
|
|
25
|
+
- @backstage/backend-common@0.21.4-next.2
|
|
26
|
+
- @backstage/plugin-auth-node@0.4.9-next.2
|
|
27
|
+
- @backstage/plugin-catalog-node@1.8.0-next.2
|
|
28
|
+
- @backstage/backend-plugin-api@0.6.14-next.2
|
|
29
|
+
- @backstage/backend-tasks@0.5.19-next.2
|
|
30
|
+
- @backstage/catalog-model@1.4.5-next.0
|
|
31
|
+
- @backstage/config@1.2.0-next.1
|
|
32
|
+
- @backstage/errors@1.2.4-next.0
|
|
33
|
+
- @backstage/types@1.1.1
|
|
34
|
+
- @backstage/plugin-catalog-backend-module-scaffolder-entity-model@0.1.11-next.2
|
|
35
|
+
- @backstage/plugin-permission-common@0.7.13-next.1
|
|
36
|
+
- @backstage/plugin-permission-node@0.7.25-next.2
|
|
37
|
+
- @backstage/plugin-scaffolder-common@1.5.1-next.1
|
|
38
|
+
|
|
3
39
|
## 1.22.0-next.1
|
|
4
40
|
|
|
5
41
|
### Minor Changes
|
package/alpha/package.json
CHANGED
package/dist/alpha.cjs.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var alpha = require('@backstage/plugin-scaffolder-common/alpha');
|
|
6
6
|
var pluginPermissionNode = require('@backstage/plugin-permission-node');
|
|
7
|
-
var router = require('./cjs/router-
|
|
7
|
+
var router = require('./cjs/router-52d79583.cjs.js');
|
|
8
8
|
var backendPluginApi = require('@backstage/backend-plugin-api');
|
|
9
9
|
var backendCommon = require('@backstage/backend-common');
|
|
10
10
|
var integration = require('@backstage/integration');
|
|
@@ -274,7 +274,7 @@ function createCatalogWriteAction() {
|
|
|
274
274
|
examples: examples$8,
|
|
275
275
|
supportsDryRun: true,
|
|
276
276
|
async handler(ctx) {
|
|
277
|
-
ctx.
|
|
277
|
+
ctx.logger.info(`Writing catalog-info.yaml`);
|
|
278
278
|
const { filePath, entity } = ctx.input;
|
|
279
279
|
const path = filePath != null ? filePath : "catalog-info.yaml";
|
|
280
280
|
await fs__default["default"].writeFile(
|
|
@@ -465,11 +465,11 @@ function createDebugLogAction() {
|
|
|
465
465
|
var _a, _b;
|
|
466
466
|
ctx.logger.info(JSON.stringify(ctx.input, null, 2));
|
|
467
467
|
if ((_a = ctx.input) == null ? void 0 : _a.message) {
|
|
468
|
-
ctx.
|
|
468
|
+
ctx.logger.info(ctx.input.message);
|
|
469
469
|
}
|
|
470
470
|
if ((_b = ctx.input) == null ? void 0 : _b.listWorkspace) {
|
|
471
471
|
const files = await recursiveReadDir(ctx.workspacePath);
|
|
472
|
-
ctx.
|
|
472
|
+
ctx.logger.info(
|
|
473
473
|
`Workspace:
|
|
474
474
|
${files.map((f) => ` - ${path.relative(ctx.workspacePath, f)}`).join("\n")}`
|
|
475
475
|
);
|
|
@@ -2269,6 +2269,137 @@ const scaffolderActionRules = {
|
|
|
2269
2269
|
hasStringProperty
|
|
2270
2270
|
};
|
|
2271
2271
|
|
|
2272
|
+
var __accessCheck = (obj, member, msg) => {
|
|
2273
|
+
if (!member.has(obj))
|
|
2274
|
+
throw TypeError("Cannot " + msg);
|
|
2275
|
+
};
|
|
2276
|
+
var __privateGet = (obj, member, getter) => {
|
|
2277
|
+
__accessCheck(obj, member, "read from private field");
|
|
2278
|
+
return getter ? getter.call(obj) : member.get(obj);
|
|
2279
|
+
};
|
|
2280
|
+
var __privateAdd = (obj, member, value) => {
|
|
2281
|
+
if (member.has(obj))
|
|
2282
|
+
throw TypeError("Cannot add the same private member more than once");
|
|
2283
|
+
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
2284
|
+
};
|
|
2285
|
+
var __privateSet = (obj, member, value, setter) => {
|
|
2286
|
+
__accessCheck(obj, member, "write to private field");
|
|
2287
|
+
setter ? setter.call(obj, value) : member.set(obj, value);
|
|
2288
|
+
return value;
|
|
2289
|
+
};
|
|
2290
|
+
var _winston, _addRedactions;
|
|
2291
|
+
const escapeRegExp = (text) => {
|
|
2292
|
+
return text.replace(/[.*+?^${}(\)|[\]\\]/g, "\\$&");
|
|
2293
|
+
};
|
|
2294
|
+
const _WinstonLogger = class _WinstonLogger {
|
|
2295
|
+
constructor(winston, addRedactions) {
|
|
2296
|
+
__privateAdd(this, _winston, void 0);
|
|
2297
|
+
__privateAdd(this, _addRedactions, void 0);
|
|
2298
|
+
__privateSet(this, _winston, winston);
|
|
2299
|
+
__privateSet(this, _addRedactions, addRedactions);
|
|
2300
|
+
}
|
|
2301
|
+
/**
|
|
2302
|
+
* Creates a {@link WinstonLogger} instance.
|
|
2303
|
+
*/
|
|
2304
|
+
static create(options) {
|
|
2305
|
+
var _a;
|
|
2306
|
+
const redacter = _WinstonLogger.redacter();
|
|
2307
|
+
let logger = winston.createLogger({
|
|
2308
|
+
level: options.level,
|
|
2309
|
+
format: winston.format.combine(redacter.format, options.format),
|
|
2310
|
+
transports: (_a = options.transports) != null ? _a : new winston.transports.Console()
|
|
2311
|
+
});
|
|
2312
|
+
if (options.meta) {
|
|
2313
|
+
logger = logger.child(options.meta);
|
|
2314
|
+
}
|
|
2315
|
+
return new _WinstonLogger(logger, redacter.add);
|
|
2316
|
+
}
|
|
2317
|
+
/**
|
|
2318
|
+
* Creates a winston log formatter for redacting secrets.
|
|
2319
|
+
*/
|
|
2320
|
+
static redacter() {
|
|
2321
|
+
const redactionSet = /* @__PURE__ */ new Set();
|
|
2322
|
+
let redactionPattern = void 0;
|
|
2323
|
+
return {
|
|
2324
|
+
format: winston.format((info) => {
|
|
2325
|
+
if (redactionPattern && typeof info.message === "string") {
|
|
2326
|
+
info.message = info.message.replace(redactionPattern, "[REDACTED]");
|
|
2327
|
+
}
|
|
2328
|
+
if (redactionPattern && typeof info.stack === "string") {
|
|
2329
|
+
info.stack = info.stack.replace(redactionPattern, "[REDACTED]");
|
|
2330
|
+
}
|
|
2331
|
+
return info;
|
|
2332
|
+
})(),
|
|
2333
|
+
add(newRedactions) {
|
|
2334
|
+
let added = 0;
|
|
2335
|
+
for (const redactionToTrim of newRedactions) {
|
|
2336
|
+
const redaction = redactionToTrim.trim();
|
|
2337
|
+
if (redaction.length <= 1) {
|
|
2338
|
+
continue;
|
|
2339
|
+
}
|
|
2340
|
+
if (!redactionSet.has(redaction)) {
|
|
2341
|
+
redactionSet.add(redaction);
|
|
2342
|
+
added += 1;
|
|
2343
|
+
}
|
|
2344
|
+
}
|
|
2345
|
+
if (added > 0) {
|
|
2346
|
+
const redactions = Array.from(redactionSet).map((r) => escapeRegExp(r)).join("|");
|
|
2347
|
+
redactionPattern = new RegExp(`(${redactions})`, "g");
|
|
2348
|
+
}
|
|
2349
|
+
}
|
|
2350
|
+
};
|
|
2351
|
+
}
|
|
2352
|
+
/**
|
|
2353
|
+
* Creates a pretty printed winston log formatter.
|
|
2354
|
+
*/
|
|
2355
|
+
static colorFormat() {
|
|
2356
|
+
const colorizer = winston.format.colorize();
|
|
2357
|
+
return winston.format.combine(
|
|
2358
|
+
winston.format.timestamp(),
|
|
2359
|
+
winston.format.colorize({
|
|
2360
|
+
colors: {
|
|
2361
|
+
timestamp: "dim",
|
|
2362
|
+
prefix: "blue",
|
|
2363
|
+
field: "cyan",
|
|
2364
|
+
debug: "grey"
|
|
2365
|
+
}
|
|
2366
|
+
}),
|
|
2367
|
+
winston.format.printf((info) => {
|
|
2368
|
+
const { timestamp, level, message, plugin, service, ...fields } = info;
|
|
2369
|
+
const prefix = plugin || service;
|
|
2370
|
+
const timestampColor = colorizer.colorize("timestamp", timestamp);
|
|
2371
|
+
const prefixColor = colorizer.colorize("prefix", prefix);
|
|
2372
|
+
const extraFields = Object.entries(fields).map(
|
|
2373
|
+
([key, value]) => `${colorizer.colorize("field", `${key}`)}=${value}`
|
|
2374
|
+
).join(" ");
|
|
2375
|
+
return `${timestampColor} ${prefixColor} ${level} ${message} ${extraFields}`;
|
|
2376
|
+
})
|
|
2377
|
+
);
|
|
2378
|
+
}
|
|
2379
|
+
error(message, meta) {
|
|
2380
|
+
__privateGet(this, _winston).error(message, meta);
|
|
2381
|
+
}
|
|
2382
|
+
warn(message, meta) {
|
|
2383
|
+
__privateGet(this, _winston).warn(message, meta);
|
|
2384
|
+
}
|
|
2385
|
+
info(message, meta) {
|
|
2386
|
+
__privateGet(this, _winston).info(message, meta);
|
|
2387
|
+
}
|
|
2388
|
+
debug(message, meta) {
|
|
2389
|
+
__privateGet(this, _winston).debug(message, meta);
|
|
2390
|
+
}
|
|
2391
|
+
child(meta) {
|
|
2392
|
+
return new _WinstonLogger(__privateGet(this, _winston).child(meta));
|
|
2393
|
+
}
|
|
2394
|
+
addRedactions(redactions) {
|
|
2395
|
+
var _a;
|
|
2396
|
+
(_a = __privateGet(this, _addRedactions)) == null ? void 0 : _a.call(this, redactions);
|
|
2397
|
+
}
|
|
2398
|
+
};
|
|
2399
|
+
_winston = new WeakMap();
|
|
2400
|
+
_addRedactions = new WeakMap();
|
|
2401
|
+
let WinstonLogger = _WinstonLogger;
|
|
2402
|
+
|
|
2272
2403
|
var __defProp$1 = Object.defineProperty;
|
|
2273
2404
|
var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
2274
2405
|
var __publicField$1 = (obj, key, value) => {
|
|
@@ -2282,23 +2413,33 @@ const createStepLogger = ({
|
|
|
2282
2413
|
task,
|
|
2283
2414
|
step
|
|
2284
2415
|
}) => {
|
|
2285
|
-
|
|
2286
|
-
const
|
|
2416
|
+
var _a;
|
|
2417
|
+
const stepLogStream = new stream.PassThrough();
|
|
2418
|
+
stepLogStream.on("data", async (data) => {
|
|
2419
|
+
const message = data.toString().trim();
|
|
2420
|
+
if ((message == null ? void 0 : message.length) > 1) {
|
|
2421
|
+
await task.emitLog(message, { stepId: step.id });
|
|
2422
|
+
}
|
|
2423
|
+
});
|
|
2424
|
+
const taskLogger = WinstonLogger.create({
|
|
2287
2425
|
level: process.env.LOG_LEVEL || "info",
|
|
2288
2426
|
format: winston__namespace.format.combine(
|
|
2289
2427
|
winston__namespace.format.colorize(),
|
|
2290
2428
|
winston__namespace.format.simple()
|
|
2291
2429
|
),
|
|
2292
|
-
|
|
2430
|
+
transports: [
|
|
2431
|
+
new winston__namespace.transports.Console(),
|
|
2432
|
+
new winston__namespace.transports.Stream({ stream: stepLogStream })
|
|
2433
|
+
]
|
|
2293
2434
|
});
|
|
2435
|
+
taskLogger.addRedactions(Object.values((_a = task.secrets) != null ? _a : {}));
|
|
2294
2436
|
const streamLogger = new stream.PassThrough();
|
|
2295
2437
|
streamLogger.on("data", async (data) => {
|
|
2296
2438
|
const message = data.toString().trim();
|
|
2297
2439
|
if ((message == null ? void 0 : message.length) > 1) {
|
|
2298
|
-
|
|
2440
|
+
taskLogger.info(message);
|
|
2299
2441
|
}
|
|
2300
2442
|
});
|
|
2301
|
-
taskLogger.add(new winston__namespace.transports.Stream({ stream: streamLogger }));
|
|
2302
2443
|
return { taskLogger, streamLogger };
|
|
2303
2444
|
};
|
|
2304
2445
|
const isActionAuthorized = pluginPermissionNode.createConditionAuthorizer(
|
|
@@ -2472,7 +2613,8 @@ class NunjucksWorkflowRunner {
|
|
|
2472
2613
|
await action.handler({
|
|
2473
2614
|
input: iteration.input,
|
|
2474
2615
|
secrets: (_f = task.secrets) != null ? _f : {},
|
|
2475
|
-
|
|
2616
|
+
// TODO(blam): move to LoggerService and away from Winston
|
|
2617
|
+
logger: backendCommon.loggerToWinstonLogger(taskLogger),
|
|
2476
2618
|
logStream: streamLogger,
|
|
2477
2619
|
workspacePath,
|
|
2478
2620
|
async checkpoint(keySuffix, fn) {
|
|
@@ -3218,12 +3360,12 @@ async function createRouter(options) {
|
|
|
3218
3360
|
const { kind, namespace, name } = catalogModel.parseEntityRef(templateRef, {
|
|
3219
3361
|
defaultKind: "template"
|
|
3220
3362
|
});
|
|
3221
|
-
const credentials = await httpAuth.credentials(req
|
|
3363
|
+
const credentials = await httpAuth.credentials(req);
|
|
3222
3364
|
const { token } = await auth.getPluginRequestToken({
|
|
3223
3365
|
onBehalfOf: credentials,
|
|
3224
3366
|
targetPluginId: "catalog"
|
|
3225
3367
|
});
|
|
3226
|
-
const userEntityRef = credentials.principal.userEntityRef;
|
|
3368
|
+
const userEntityRef = auth.isPrincipal(credentials, "user") ? credentials.principal.userEntityRef : void 0;
|
|
3227
3369
|
const userEntity = userEntityRef ? await catalogClient.getEntityByRef(userEntityRef, { token }) : void 0;
|
|
3228
3370
|
let auditLog = `Scaffolding task for ${templateRef}`;
|
|
3229
3371
|
if (userEntityRef) {
|
|
@@ -3490,4 +3632,4 @@ exports.createRouter = createRouter;
|
|
|
3490
3632
|
exports.createWaitAction = createWaitAction;
|
|
3491
3633
|
exports.scaffolderActionRules = scaffolderActionRules;
|
|
3492
3634
|
exports.scaffolderTemplateRules = scaffolderTemplateRules;
|
|
3493
|
-
//# sourceMappingURL=router-
|
|
3635
|
+
//# sourceMappingURL=router-52d79583.cjs.js.map
|