Skip to content

Commit

Permalink
release: 0.3.1 (#14)
Browse files Browse the repository at this point in the history
### Description

Release
[0.3.0](https://github.com/PagerDuty/backstage-plugin-entity-processor/releases/tag/0.3.0)
had a limitation that prevented users from enabling PagerDuty as their
main source for syncing service dependencies.

With the help of the Backstage team, we were able to implement a few
changes that overcome this limitation. With this release, users can now
set PagerDuty as their main source for service dependencies and get
their dependencies sync to Backstage for all mapped entities.

## Acknowledgement

By submitting this pull request, I confirm that you can use, modify,
copy, and redistribute this contribution, under the terms of your
choice.

**Disclaimer:** We value your time and bandwidth. As such, any pull
requests created on non-triaged issues might not be successful.
  • Loading branch information
t1agob committed Aug 21, 2024
2 parents 7c075bf + 42fbd65 commit 0896385
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/apis/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,16 @@ export class PagerDutyClient {
throw new Error(`Failed to remove service relation from service ${serviceId}. PagerDuty API returned a server error. Retrying with the same arguments will not work.`);
}

if (response.status === 404) {
throw new Error(`Service ${serviceId} or dependencies not found.`);
}

if (!response.ok) {
throw new Error(await response.text());
}
} catch (error) {
this.logger.error(`Failed to remove dependencies: ${error}`);
throw new Error(`Failed to remove dependencies: ${error}`);
this.logger.error(`Failed to remove dependencies from ${serviceId}: ${error}`);
throw new Error(`Failed to remove dependencies from ${serviceId}: ${error}`);
}
}

Expand Down
17 changes: 16 additions & 1 deletion src/processor/PagerDutyEntityProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,21 @@ export class PagerDutyEntityProcessor implements CatalogProcessor {
return "PagerDutyEntityProcessor";
}

async preProcessEntity(entity: Entity): Promise<Entity> {
if (this.shouldProcessEntity(entity)) {
const strategySetting = await client.getServiceDependencyStrategySetting();

if (strategySetting && strategySetting === "pagerduty") {
if (entity.spec?.dependsOn){
// empty the dependsOn array
entity.spec.dependsOn = [];
}
}
}

return entity;
}

async postProcessEntity(entity: Entity, _location: LocationSpec, emit: CatalogProcessorEmit): Promise<Entity> {
if (this.shouldProcessEntity(entity)) {
try {
Expand Down Expand Up @@ -197,7 +212,7 @@ export class PagerDutyEntityProcessor implements CatalogProcessor {
// set on the entity configuration file
// !!!

// entity.spec!.dependsOn = refreshServiceDependencyAnnotations(entity, mappings, dependencyIds, emit);
entity.spec!.dependsOn = refreshServiceDependencyAnnotations(entity, mappings, dependencyIds, emit);

break;
case "both":
Expand Down

0 comments on commit 0896385

Please sign in to comment.