@pagerduty/backstage-plugin-entity-processor 0.1.0-next.10 → 0.1.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/dist/index.cjs.js +13 -42
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.cjs.js
CHANGED
|
@@ -12,14 +12,12 @@ var __publicField = (obj, key, value) => {
|
|
|
12
12
|
return value;
|
|
13
13
|
};
|
|
14
14
|
class PagerDutyEntityProcessor {
|
|
15
|
-
|
|
15
|
+
// private shouldProcessEntity: ShouldProcessEntity = (entity: Entity) => {
|
|
16
|
+
// return entity.kind === 'Component';
|
|
17
|
+
// }
|
|
18
|
+
constructor(logger) {
|
|
16
19
|
__publicField(this, "logger");
|
|
17
|
-
__publicField(this, "store");
|
|
18
|
-
__publicField(this, "shouldProcessEntity", (entity) => {
|
|
19
|
-
return entity.kind === "Component";
|
|
20
|
-
});
|
|
21
20
|
this.logger = logger;
|
|
22
|
-
this.store = store;
|
|
23
21
|
}
|
|
24
22
|
getProcessorName() {
|
|
25
23
|
return "PagerDutyEntityProcessor";
|
|
@@ -27,41 +25,18 @@ class PagerDutyEntityProcessor {
|
|
|
27
25
|
// static fromConfig(): PagerDutyEntityProcessor {
|
|
28
26
|
// return new PagerDutyEntityProcessor();
|
|
29
27
|
// }
|
|
30
|
-
async
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if (mapping) {
|
|
38
|
-
this.logger.info(`Found mapping for entity: ${entity.metadata.name}`);
|
|
39
|
-
entity.metadata.annotations["pagerduty.com/service-id"] = mapping.serviceId;
|
|
40
|
-
} else {
|
|
41
|
-
this.logger.info(`No mapping found for entity: ${entity.metadata.name}`);
|
|
42
|
-
}
|
|
43
|
-
} catch (error) {
|
|
44
|
-
this.logger.error(`Error processing entity: ${entity.metadata.name}`);
|
|
45
|
-
this.logger.error(JSON.stringify(error));
|
|
46
|
-
}
|
|
28
|
+
async preProcessEntity(entity) {
|
|
29
|
+
this.logger.info(`Processing entity: ${entity.metadata.name}`);
|
|
30
|
+
if (entity.metadata.annotations) {
|
|
31
|
+
entity.metadata.annotations = {
|
|
32
|
+
"pagerduty.com/integration-key": "123",
|
|
33
|
+
"pagerduty.com/service-id": "123"
|
|
34
|
+
};
|
|
47
35
|
}
|
|
48
36
|
return entity;
|
|
49
37
|
}
|
|
50
38
|
}
|
|
51
39
|
|
|
52
|
-
class PagerDutyBackendDatabase {
|
|
53
|
-
constructor(db) {
|
|
54
|
-
this.db = db;
|
|
55
|
-
}
|
|
56
|
-
static async create(knex) {
|
|
57
|
-
return new PagerDutyBackendDatabase(knex);
|
|
58
|
-
}
|
|
59
|
-
async findEntityMappingByEntityRef(entityRef) {
|
|
60
|
-
const rawEntity = await this.db("pagerduty_entity_mapping").where("entityRef", entityRef).first();
|
|
61
|
-
return rawEntity;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
40
|
const pagerDutyEntityProcessor = backendPluginApi.createBackendModule({
|
|
66
41
|
pluginId: "catalog",
|
|
67
42
|
moduleId: "pagerduty-entity-processor",
|
|
@@ -69,14 +44,10 @@ const pagerDutyEntityProcessor = backendPluginApi.createBackendModule({
|
|
|
69
44
|
env.registerInit({
|
|
70
45
|
deps: {
|
|
71
46
|
logger: backendPluginApi.coreServices.logger,
|
|
72
|
-
database: backendPluginApi.coreServices.database,
|
|
73
47
|
catalog: alpha.catalogProcessingExtensionPoint
|
|
74
48
|
},
|
|
75
|
-
async init({ logger,
|
|
76
|
-
|
|
77
|
-
await database.getClient()
|
|
78
|
-
);
|
|
79
|
-
catalog.addProcessor(new PagerDutyEntityProcessor({ logger, store }));
|
|
49
|
+
async init({ logger, catalog }) {
|
|
50
|
+
catalog.addProcessor(new PagerDutyEntityProcessor(logger));
|
|
80
51
|
}
|
|
81
52
|
});
|
|
82
53
|
}
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/processor/PagerDutyEntityProcessor.ts","../src/
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/processor/PagerDutyEntityProcessor.ts","../src/module.ts"],"sourcesContent":["import { LoggerService } from \"@backstage/backend-plugin-api\";\nimport { Entity } from \"@backstage/catalog-model\";\nimport { CatalogProcessor } from \"@backstage/plugin-catalog-node\";\n\n/**\n * A function which given an entity, determines if it should be processed for linguist tags.\n * @public\n */\n// export type ShouldProcessEntity = (entity: Entity) => boolean;\n\nexport class PagerDutyEntityProcessor implements CatalogProcessor {\n private logger: LoggerService;\n // private shouldProcessEntity: ShouldProcessEntity = (entity: Entity) => {\n // return entity.kind === 'Component';\n // }\n\n constructor(logger: LoggerService) {\n this.logger = logger;\n }\n\n getProcessorName(): string {\n return \"PagerDutyEntityProcessor\";\n }\n\n // static fromConfig(): PagerDutyEntityProcessor {\n // return new PagerDutyEntityProcessor();\n // }\n\n async preProcessEntity(entity: Entity): Promise<Entity> {\n // if (this.shouldProcessEntity(entity)) {\n this.logger.info(`Processing entity: ${entity.metadata.name}`);\n if(entity.metadata.annotations){\n entity.metadata.annotations = {\n \"pagerduty.com/integration-key\": \"123\",\n \"pagerduty.com/service-id\": \"123\",\n } \n }\n // }\n\n return entity;\n }\n}","import { coreServices, createBackendModule } from \"@backstage/backend-plugin-api\";\nimport { catalogProcessingExtensionPoint } from '@backstage/plugin-catalog-node/alpha';\nimport { PagerDutyEntityProcessor } from \"./processor\";\n\n\n\n/** @public */\nexport const pagerDutyEntityProcessor = createBackendModule({\n pluginId: 'catalog',\n moduleId: 'pagerduty-entity-processor',\n register(env) {\n env.registerInit({\n deps: {\n logger: coreServices.logger,\n catalog: catalogProcessingExtensionPoint,\n },\n async init({ logger, catalog }) {\n catalog.addProcessor(new PagerDutyEntityProcessor(logger));\n },\n });\n },\n});\n"],"names":["createBackendModule","coreServices","cat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@
|
|
|
1
1
|
import * as _backstage_backend_plugin_api from '@backstage/backend-plugin-api';
|
|
2
2
|
|
|
3
3
|
/** @public */
|
|
4
|
-
declare const pagerDutyEntityProcessor: _backstage_backend_plugin_api.
|
|
4
|
+
declare const pagerDutyEntityProcessor: () => _backstage_backend_plugin_api.BackendFeature;
|
|
5
5
|
|
|
6
6
|
export { pagerDutyEntityProcessor as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pagerduty/backstage-plugin-entity-processor",
|
|
3
|
-
"version": "0.1.0-next.
|
|
3
|
+
"version": "0.1.0-next.2",
|
|
4
4
|
"main": "dist/index.cjs.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -24,10 +24,10 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@backstage/backend-common": "^0.21.6",
|
|
26
26
|
"@backstage/backend-defaults": "^0.2.16",
|
|
27
|
-
"@backstage/backend-plugin-api": "^0.6.
|
|
27
|
+
"@backstage/backend-plugin-api": "^0.6.16",
|
|
28
28
|
"@backstage/config": "^1.2.0",
|
|
29
29
|
"@backstage/plugin-catalog-node": "^1.12.2",
|
|
30
|
-
"@pagerduty/backstage-plugin-common": "0.1.
|
|
30
|
+
"@pagerduty/backstage-plugin-common": "^0.1.4",
|
|
31
31
|
"@rjsf/core": "^5.14.3",
|
|
32
32
|
"node-fetch": "^2.6.7",
|
|
33
33
|
"winston": "^3.2.1",
|