@backstage/plugin-catalog-backend 1.0.0 → 1.0.1-next.0
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 +17 -0
- package/alpha/package.json +1 -1
- package/dist/index.cjs.js +53 -38
- package/dist/index.cjs.js.map +1 -1
- package/package.json +13 -13
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @backstage/plugin-catalog-backend
|
|
2
2
|
|
|
3
|
+
## 1.0.1-next.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 9fe24b0fc8: Adjust the error messages when entities fail validation, to clearly state what entity that failed it
|
|
8
|
+
- 95408dbe99: Enable internal batching of very large deletions, to not run into SQL binding limits
|
|
9
|
+
- ffec894ed0: add gitlab to AnnotateScmSlugEntityProcessor
|
|
10
|
+
- Updated dependencies
|
|
11
|
+
- @backstage/catalog-model@1.0.1-next.0
|
|
12
|
+
- @backstage/plugin-search-common@0.3.3-next.0
|
|
13
|
+
- @backstage/backend-common@0.13.2-next.0
|
|
14
|
+
- @backstage/integration@1.0.1-next.0
|
|
15
|
+
- @backstage/catalog-client@1.0.1-next.0
|
|
16
|
+
- @backstage/plugin-scaffolder-common@1.0.1-next.0
|
|
17
|
+
- @backstage/plugin-permission-node@0.5.6-next.0
|
|
18
|
+
- @backstage/plugin-catalog-common@1.0.1-next.0
|
|
19
|
+
|
|
3
20
|
## 1.0.0
|
|
4
21
|
|
|
5
22
|
### Major Changes
|
package/alpha/package.json
CHANGED
package/dist/index.cjs.js
CHANGED
|
@@ -237,6 +237,7 @@ class AnnotateLocationEntityProcessor {
|
|
|
237
237
|
}
|
|
238
238
|
|
|
239
239
|
const GITHUB_ACTIONS_ANNOTATION = "github.com/project-slug";
|
|
240
|
+
const GITLAB_ACTIONS_ANNOTATION = "gitlab.com/project-slug";
|
|
240
241
|
class AnnotateScmSlugEntityProcessor {
|
|
241
242
|
constructor(opts) {
|
|
242
243
|
this.opts = opts;
|
|
@@ -255,18 +256,29 @@ class AnnotateScmSlugEntityProcessor {
|
|
|
255
256
|
return entity;
|
|
256
257
|
}
|
|
257
258
|
const scmIntegration = this.opts.scmIntegrationRegistry.byUrl(location.target);
|
|
258
|
-
if (!scmIntegration
|
|
259
|
+
if (!scmIntegration) {
|
|
259
260
|
return entity;
|
|
260
261
|
}
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
262
|
+
let annotation;
|
|
263
|
+
switch (scmIntegration.type) {
|
|
264
|
+
case "github":
|
|
265
|
+
annotation = GITHUB_ACTIONS_ANNOTATION;
|
|
266
|
+
break;
|
|
267
|
+
case "gitlab":
|
|
268
|
+
annotation = GITLAB_ACTIONS_ANNOTATION;
|
|
269
|
+
break;
|
|
270
|
+
default:
|
|
271
|
+
return entity;
|
|
272
|
+
}
|
|
273
|
+
let projectSlug = (_a = entity.metadata.annotations) == null ? void 0 : _a[annotation];
|
|
274
|
+
if (!projectSlug) {
|
|
275
|
+
const gitUrl = parseGitUrl__default["default"](location.target);
|
|
276
|
+
projectSlug = `${gitUrl.owner}/${gitUrl.name}`;
|
|
265
277
|
}
|
|
266
278
|
return lodash.merge({
|
|
267
279
|
metadata: {
|
|
268
280
|
annotations: lodash.pickBy({
|
|
269
|
-
[
|
|
281
|
+
[annotation]: projectSlug
|
|
270
282
|
}, lodash.identity)
|
|
271
283
|
}
|
|
272
284
|
}, entity);
|
|
@@ -1230,37 +1242,40 @@ class DefaultProcessingDatabase {
|
|
|
1230
1242
|
const tx = txOpaque;
|
|
1231
1243
|
const { toAdd, toUpsert, toRemove } = await this.createDelta(tx, options);
|
|
1232
1244
|
if (toRemove.length) {
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1245
|
+
let removedCount = 0;
|
|
1246
|
+
for (const refs of lodash__default["default"].chunk(toRemove, 1e3)) {
|
|
1247
|
+
removedCount += await tx("refresh_state").whereIn("entity_ref", function orphanedEntityRefs(orphans) {
|
|
1248
|
+
return orphans.withRecursive("descendants", function descendants(outer) {
|
|
1249
|
+
return outer.select({ root_id: "id", entity_ref: "target_entity_ref" }).from("refresh_state_references").where("source_key", options.sourceKey).whereIn("target_entity_ref", refs).union(function recursive(inner) {
|
|
1250
|
+
return inner.select({
|
|
1251
|
+
root_id: "descendants.root_id",
|
|
1252
|
+
entity_ref: "refresh_state_references.target_entity_ref"
|
|
1253
|
+
}).from("descendants").join("refresh_state_references", {
|
|
1254
|
+
"descendants.entity_ref": "refresh_state_references.source_entity_ref"
|
|
1255
|
+
});
|
|
1241
1256
|
});
|
|
1242
|
-
})
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1257
|
+
}).withRecursive("ancestors", function ancestors(outer) {
|
|
1258
|
+
return outer.select({
|
|
1259
|
+
root_id: tx.raw("CAST(NULL as INT)", []),
|
|
1260
|
+
via_entity_ref: "entity_ref",
|
|
1261
|
+
to_entity_ref: "entity_ref"
|
|
1262
|
+
}).from("descendants").union(function recursive(inner) {
|
|
1263
|
+
return inner.select({
|
|
1264
|
+
root_id: tx.raw("CASE WHEN source_key IS NOT NULL THEN id ELSE NULL END", []),
|
|
1265
|
+
via_entity_ref: "source_entity_ref",
|
|
1266
|
+
to_entity_ref: "ancestors.to_entity_ref"
|
|
1267
|
+
}).from("ancestors").join("refresh_state_references", {
|
|
1268
|
+
target_entity_ref: "ancestors.via_entity_ref"
|
|
1269
|
+
});
|
|
1255
1270
|
});
|
|
1256
|
-
})
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
}).
|
|
1262
|
-
|
|
1263
|
-
|
|
1271
|
+
}).select("descendants.entity_ref").from("descendants").leftOuterJoin("ancestors", function keepaliveRoots() {
|
|
1272
|
+
this.on("ancestors.to_entity_ref", "=", "descendants.entity_ref");
|
|
1273
|
+
this.andOnNotNull("ancestors.root_id");
|
|
1274
|
+
this.andOn("ancestors.root_id", "!=", "descendants.root_id");
|
|
1275
|
+
}).whereNull("ancestors.root_id");
|
|
1276
|
+
}).delete();
|
|
1277
|
+
await tx("refresh_state_references").where("source_key", "=", options.sourceKey).whereIn("target_entity_ref", refs).delete();
|
|
1278
|
+
}
|
|
1264
1279
|
this.options.logger.debug(`removed, ${removedCount} entities: ${JSON.stringify(toRemove)}`);
|
|
1265
1280
|
}
|
|
1266
1281
|
if (toAdd.length) {
|
|
@@ -2297,7 +2312,7 @@ class DefaultCatalogProcessingOrchestrator {
|
|
|
2297
2312
|
try {
|
|
2298
2313
|
validateEntity(entity);
|
|
2299
2314
|
} catch (e) {
|
|
2300
|
-
throw new errors.ConflictError(`Entity envelope failed validation after preprocessing`, e);
|
|
2315
|
+
throw new errors.ConflictError(`Entity envelope for ${context.entityRef} failed validation after preprocessing`, e);
|
|
2301
2316
|
}
|
|
2302
2317
|
let foundKind = false;
|
|
2303
2318
|
for (const processor of this.options.processors) {
|
|
@@ -2308,12 +2323,12 @@ class DefaultCatalogProcessingOrchestrator {
|
|
|
2308
2323
|
break;
|
|
2309
2324
|
}
|
|
2310
2325
|
} catch (e) {
|
|
2311
|
-
throw new errors.InputError(`Processor ${processor.constructor.name} threw an error while validating the entity`, e);
|
|
2326
|
+
throw new errors.InputError(`Processor ${processor.constructor.name} threw an error while validating the entity ${context.entityRef}`, e);
|
|
2312
2327
|
}
|
|
2313
2328
|
}
|
|
2314
2329
|
}
|
|
2315
2330
|
if (!foundKind) {
|
|
2316
|
-
throw new errors.InputError(
|
|
2331
|
+
throw new errors.InputError(`No processor recognized the entity ${context.entityRef} as valid, possibly caused by a foreign kind or apiVersion`);
|
|
2317
2332
|
}
|
|
2318
2333
|
}
|
|
2319
2334
|
async runSpecialLocationStep(entity, context) {
|