Skip to content

Commit

Permalink
feat: static source locations for RoleGroup entities
Browse files Browse the repository at this point in the history
  • Loading branch information
diegofigs committed May 31, 2024
1 parent 0f4fd0c commit 1266555
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/metal-radios-flash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@aurora-is-near/backstage-plugin-blockchainradar-backend': patch
---

feat: use static source location for RoleGroup entities
17 changes: 14 additions & 3 deletions plugins/blockchainradar-backend/src/entities/RoleGroup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import { Entity, stringifyEntityRef } from '@backstage/catalog-model';
import {
Entity,
EntityMeta,
stringifyEntityRef,
} from '@backstage/catalog-model';
import * as crypto from 'crypto';
import * as bs58 from 'bs58';

Expand All @@ -11,6 +15,8 @@ function base58EncodeSha256(str: string): string {
}

const ROLE = 'role-group';
const ACCESS_CONTROL_SOURCE =
'https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/access/AccessControl.sol';

export class RoleGroup extends BlockchainAddress {
roleId: string;
Expand Down Expand Up @@ -73,13 +79,18 @@ export class RoleGroup extends BlockchainAddress {
return `${super.entityTitle()} ${this.roleName}`;
}

entityMetadata() {
entityMetadata(): EntityMeta {
const tags = ['role-group', this.network];
if (this.stub) tags.push('stub');
const meta = super.entityMetadata();
return {
...super.entityMetadata(),
...meta,
description: `${this.address} (${this.role})`,
tags,
annotations: {
...meta.annotations,
'backstage.io/source-location': ACCESS_CONTROL_SOURCE,
},
};
}

Expand Down

0 comments on commit 1266555

Please sign in to comment.