From ad48d743b77ba49c60c9bc54772093b792e5eb7e Mon Sep 17 00:00:00 2001 From: Diego Figueroa Date: Fri, 8 Dec 2023 18:14:59 -0400 Subject: [PATCH 1/3] feat: add tags to reports --- src/core/access-key-collector.ts | 2 ++ src/core/multisigs-collector.ts | 8 +++++--- src/core/rbac-collector.ts | 2 ++ src/types.ts | 3 +++ templates/backstage/access-keys.md.hbs | 4 ++-- templates/backstage/multisigs.md.hbs | 4 ++-- templates/backstage/rbac.md.hbs | 4 ++-- templates/backstage/unknown.md.hbs | 4 ++-- 8 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/core/access-key-collector.ts b/src/core/access-key-collector.ts index f5d4593..426b14a 100644 --- a/src/core/access-key-collector.ts +++ b/src/core/access-key-collector.ts @@ -64,6 +64,7 @@ export class AccessKeyCollector extends BaseCollector { title: component.metadata.title || component.metadata.name, component, contracts, + tags: component.metadata.tags?.join(", ") || "None", }, ]; } @@ -90,6 +91,7 @@ export class AccessKeyCollector extends BaseCollector { .map((entity) => ({ entity, keys: this.collectKeys(entity), + tags: entity.metadata.tags?.join(", "), })); } diff --git a/src/core/multisigs-collector.ts b/src/core/multisigs-collector.ts index 07d0df3..1aee6f6 100644 --- a/src/core/multisigs-collector.ts +++ b/src/core/multisigs-collector.ts @@ -77,6 +77,7 @@ export class MultisigsCollector extends BaseCollector { title: component.metadata.title || component.metadata.name, component, multisigs: this.collectMultisigs(componentRef), + tags: component.metadata.tags?.join(", ") || "None", }, ]; }, []) @@ -94,9 +95,10 @@ export class MultisigsCollector extends BaseCollector { r.targetRef === componentRef.targetRef, ), ) - .map((ms) => ({ - entity: ms, - signers: this.collectSigners(ms), + .map((entity) => ({ + entity: entity, + signers: this.collectSigners(entity), + tags: entity.metadata.tags?.join(", "), })); } diff --git a/src/core/rbac-collector.ts b/src/core/rbac-collector.ts index f44ce1b..e513deb 100644 --- a/src/core/rbac-collector.ts +++ b/src/core/rbac-collector.ts @@ -65,6 +65,7 @@ export class RbacCollector extends BaseCollector { title: component.metadata.title || component.metadata.name, component, contracts, + tags: component.metadata.tags?.join(", ") || "None", }, ]; } @@ -92,6 +93,7 @@ export class RbacCollector extends BaseCollector { entity, admins: this.collectAdmins(entity), roles: this.collectRoles(entity), + tags: entity.metadata.tags?.join(", "), })); } diff --git a/src/types.ts b/src/types.ts index 9ce2cbf..4e6f79d 100644 --- a/src/types.ts +++ b/src/types.ts @@ -20,6 +20,7 @@ export type ComponentInfo = { component: Entity; contracts?: ContractInfo[]; multisigs?: MultisigInfo[]; + tags?: string; }; export type ContractInfo = { @@ -27,11 +28,13 @@ export type ContractInfo = { keys?: KeyInfo[]; admins?: AdminInfo[]; roles?: RoleInfo[]; + tags?: string; }; export type MultisigInfo = { entity: Entity; signers: SignerInfo[]; + tags?: string; }; export type AdminInfo = { diff --git a/templates/backstage/access-keys.md.hbs b/templates/backstage/access-keys.md.hbs index aa08645..02d8f48 100644 --- a/templates/backstage/access-keys.md.hbs +++ b/templates/backstage/access-keys.md.hbs @@ -9,14 +9,14 @@ {{/if}} {{#each components~}} - ### [{{title}}]({{backstageLink component}}) + ### [{{title}}]({{backstageLink component}}) (Tags: {{tags}}) {{#if component.metadata.description~}} {{component.metadata.description}} {{/if}} {{#each contracts~}} - #### [{{entity.metadata.title}}]({{backstageLink entity}}) + #### [{{entity.metadata.title}}]({{backstageLink entity}}) (Tags: {{tags}}) {{#if entity.metadata.description~}} {{entity.metadata.description}} diff --git a/templates/backstage/multisigs.md.hbs b/templates/backstage/multisigs.md.hbs index 210eaec..dc4bdb6 100644 --- a/templates/backstage/multisigs.md.hbs +++ b/templates/backstage/multisigs.md.hbs @@ -9,14 +9,14 @@ {{/if}} {{#each components~}} - ### [{{component.metadata.title}}]({{backstageLink component}}) + ### [{{component.metadata.title}}]({{backstageLink component}}) (Tags: {{tags}}) {{#if component.metadata.description~}} {{component.metadata.description}} {{/if}} {{#each multisigs~}} - #### [{{entity.metadata.title}}]({{backstageLink entity}}) + #### [{{entity.metadata.title}}]({{backstageLink entity}}) (Tags: {{tags}}) {{#if entity.metadata.description~}} {{entity.metadata.description}} diff --git a/templates/backstage/rbac.md.hbs b/templates/backstage/rbac.md.hbs index cfb9fe5..ab42607 100644 --- a/templates/backstage/rbac.md.hbs +++ b/templates/backstage/rbac.md.hbs @@ -9,14 +9,14 @@ {{/if}} {{#each components~}} - ### [{{component.metadata.name}}]({{backstageLink component}}) + ### [{{component.metadata.name}}]({{backstageLink component}}) (Tags: {{tags}}) {{#if component.metadata.description~}} {{component.metadata.description}} {{/if}} {{#each contracts~}} - #### [{{entity.metadata.title}}]({{backstageLink entity}}) + #### [{{entity.metadata.title}}]({{backstageLink entity}}) (Tags: {{tags}}) {{#if entity.metadata.description~}} {{entity.metadata.description}} diff --git a/templates/backstage/unknown.md.hbs b/templates/backstage/unknown.md.hbs index e9f6b0e..773c134 100644 --- a/templates/backstage/unknown.md.hbs +++ b/templates/backstage/unknown.md.hbs @@ -9,7 +9,7 @@ {{/if}} {{#each components~}} -### [{{title}}]({{backstageLink component}}) +### [{{title}}]({{backstageLink component}}) (Tags: {{tags}}) {{#if component.metadata.description}} {{component.metadata.description}} @@ -18,7 +18,7 @@ {{#if contracts}} {{#each contracts}} -#### [{{entity.metadata.title}}]({{backstageLink entity}}) +#### [{{entity.metadata.title}}]({{backstageLink entity}}) (Tags: {{tags}}) {{#if entity.metadata.description}} {{entity.metadata.description}} From 4ed919a9ef9d99b5607f705c55e7d697afabd233 Mon Sep 17 00:00:00 2001 From: Diego Figueroa Date: Fri, 8 Dec 2023 18:21:20 -0400 Subject: [PATCH 2/3] feat: add tags for signers --- src/core/multisigs-collector.ts | 1 + src/types.ts | 1 + templates/backstage/multisigs.md.hbs | 2 +- 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/core/multisigs-collector.ts b/src/core/multisigs-collector.ts index 1aee6f6..0110970 100644 --- a/src/core/multisigs-collector.ts +++ b/src/core/multisigs-collector.ts @@ -115,6 +115,7 @@ export class MultisigsCollector extends BaseCollector { return { signer, owner, + tags: signer.metadata.tags?.join(", ") || "None", }; }) .sort((a, b) => diff --git a/src/types.ts b/src/types.ts index 4e6f79d..4bd9c94 100644 --- a/src/types.ts +++ b/src/types.ts @@ -58,6 +58,7 @@ export type KeyInfo = OwnedEntity<{ export type SignerInfo = OwnedEntity<{ signer: Entity; keys?: Entity[]; + tags?: string; }>; type OwnedEntity = { diff --git a/templates/backstage/multisigs.md.hbs b/templates/backstage/multisigs.md.hbs index dc4bdb6..5ab38df 100644 --- a/templates/backstage/multisigs.md.hbs +++ b/templates/backstage/multisigs.md.hbs @@ -38,7 +38,7 @@ ##### Signers {{#each signers~}} - - [{{owner.metadata.name}}]({{backstageLink owner}}) ([{{signer.metadata.name}}]({{backstageLink signer}})) + - [{{owner.metadata.name}}]({{backstageLink owner}}) ([{{signer.metadata.name}}]({{backstageLink signer}})) (Tags: {{tags}}) {{/each}} {{/if}} From 89d541ecd58b8d9fd386573af3f933c25eaed75b Mon Sep 17 00:00:00 2001 From: Diego Figueroa Date: Fri, 8 Dec 2023 18:25:12 -0400 Subject: [PATCH 3/3] chore: add changeset for tags support --- .changeset/gold-humans-peel.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/gold-humans-peel.md diff --git a/.changeset/gold-humans-peel.md b/.changeset/gold-humans-peel.md new file mode 100644 index 0000000..69bdee6 --- /dev/null +++ b/.changeset/gold-humans-peel.md @@ -0,0 +1,5 @@ +--- +"backstage-blockchain-actions": patch +--- + +feat: add tags to reports