From ca68255c3f6868003fc30cea587b276f6fe9fa71 Mon Sep 17 00:00:00 2001 From: Tiago Barbosa Date: Fri, 12 Jul 2024 23:08:05 +0100 Subject: [PATCH 1/3] chore: :arrow_up: upgrade pagerduty/backstage-plugin-common to latest Signed-off-by: Tiago Barbosa --- package.json | 2 +- yarn.lock | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 2df3b64..03abb72 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "@backstage/catalog-model": "^1.5.0", "@backstage/config": "^1.2.0", "@backstage/plugin-catalog-node": "^1.12.2", - "@pagerduty/backstage-plugin-common": "0.1.5", + "@pagerduty/backstage-plugin-common": "0.2.0", "@rjsf/core": "^5.14.3", "node-fetch": "^2.6.7", "winston": "^3.2.1", diff --git a/yarn.lock b/yarn.lock index 0faffef..1fa707c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5068,10 +5068,10 @@ __metadata: languageName: node linkType: hard -"@pagerduty/backstage-plugin-common@npm:0.1.5": - version: 0.1.5 - resolution: "@pagerduty/backstage-plugin-common@npm:0.1.5" - checksum: 07d527c07aee79d5bb6bf7f310827b11534922c1f817b2cea5cf672ebe393b2def07293b2d42241a033f257139f8d935114edd5e9385dbbc427f8720f20265b6 +"@pagerduty/backstage-plugin-common@npm:0.2.0": + version: 0.2.0 + resolution: "@pagerduty/backstage-plugin-common@npm:0.2.0" + checksum: d7243ef9c11408eee046be351346455316dcd8984c33a61d773fec292843d3df9eb9906dfc5ce0ed4fc0c17a60b9b3ebbfe1a8f4a25b8ecc003ffa8d4304db77 languageName: node linkType: hard @@ -5086,7 +5086,7 @@ __metadata: "@backstage/cli": ^0.24.0 "@backstage/config": ^1.2.0 "@backstage/plugin-catalog-node": ^1.12.2 - "@pagerduty/backstage-plugin-common": 0.1.5 + "@pagerduty/backstage-plugin-common": 0.2.0 "@rjsf/core": ^5.14.3 "@types/node": ^20.9.2 "@types/node-fetch": 2.6.11 From a2f1ad85c011e22f9396d8ca55b015b8a5853560 Mon Sep 17 00:00:00 2001 From: Tiago Barbosa Date: Fri, 12 Jul 2024 23:08:21 +0100 Subject: [PATCH 2/3] feat: add support for multi-account Signed-off-by: Tiago Barbosa --- src/apis/client.ts | 3 ++- src/processor/PagerDutyEntityProcessor.ts | 9 ++++++++- src/types.ts | 1 + 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/apis/client.ts b/src/apis/client.ts index c21dbe8..314f9fb 100644 --- a/src/apis/client.ts +++ b/src/apis/client.ts @@ -60,7 +60,8 @@ export class PagerDutyClient { return { serviceId: foundMapping.mapping.serviceId, integrationKey: foundMapping.mapping.integrationKey, - entityRef: foundMapping.mapping.entityRef + entityRef: foundMapping.mapping.entityRef, + account: foundMapping.mapping.account, } } } catch (error) { diff --git a/src/processor/PagerDutyEntityProcessor.ts b/src/processor/PagerDutyEntityProcessor.ts index bf1e246..9c96617 100644 --- a/src/processor/PagerDutyEntityProcessor.ts +++ b/src/processor/PagerDutyEntityProcessor.ts @@ -57,7 +57,14 @@ export class PagerDutyEntityProcessor implements CatalogProcessor { delete entity.metadata.annotations!["pagerduty.com/integration-key"]; } - this.logger.debug(`Added annotations to entity ${entity.metadata.name} with service id: ${mapping.serviceId} and integration key: ${mapping.integrationKey}`); + if (mapping.account && mapping.account !== "") { + entity.metadata.annotations!["pagerduty.com/account"] = mapping.account; + } + else { + delete entity.metadata.annotations!["pagerduty.com/account"]; + } + + this.logger.debug(`Added annotations to entity ${entity.metadata.name} with service id: ${mapping.serviceId}, integration key: ${mapping.integrationKey} and account: ${mapping.account}`); } else { this.logger.debug(`No mapping found for entity: ${entity.metadata.name}`); } diff --git a/src/types.ts b/src/types.ts index 0d6a747..b90b628 100644 --- a/src/types.ts +++ b/src/types.ts @@ -16,4 +16,5 @@ export type EntityMapping = { serviceId?: string; integrationKey?: string; entityRef?: string; + account?: string; } \ No newline at end of file From 2367333a14b989bd983b9551ed9bc453e5122894 Mon Sep 17 00:00:00 2001 From: Tiago Barbosa Date: Fri, 12 Jul 2024 23:09:58 +0100 Subject: [PATCH 3/3] chore: :coffin: remove plugin config schema from module Signed-off-by: Tiago Barbosa --- config.d.ts | 46 ---------------------------------------------- 1 file changed, 46 deletions(-) delete mode 100644 config.d.ts diff --git a/config.d.ts b/config.d.ts deleted file mode 100644 index 14ade1e..0000000 --- a/config.d.ts +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2023 The Backstage Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import { PagerDutyOAuthConfig } from '@pagerduty/backstage-plugin-common'; - -export interface Config { - /** - * Configuration for the PagerDuty plugin - * @visibility frontend - */ - pagerDuty?: { - /** - * Optional Events Base URL to override the default. - * @visibility frontend - */ - eventsBaseUrl?: string; - /** - * Optional API Base URL to override the default. - * @visibility frontend - */ - apiBaseUrl?: string; - /** - * Optional PagerDuty API Token used in API calls from the backend component. - * @visibility secret - */ - apiToken?: string; - /** - * Optional PagerDuty Scoped OAuth Token used in API calls from the backend component. - * @deepVisibility secret - */ - oauth?: PagerDutyOAuthConfig; - }; -}