From 718c024cf54b63d70b9028b5e88733ec70be35e8 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Wed, 25 May 2022 10:36:07 +0100 Subject: [PATCH 1/4] add edit url annotation to the github teams entity Signed-off-by: Brian Fletcher --- plugins/catalog-backend-module-github/src/lib/github.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugins/catalog-backend-module-github/src/lib/github.ts b/plugins/catalog-backend-module-github/src/lib/github.ts index b3dae26091..a6933421a5 100644 --- a/plugins/catalog-backend-module-github/src/lib/github.ts +++ b/plugins/catalog-backend-module-github/src/lib/github.ts @@ -52,6 +52,7 @@ export type Team = { name?: string; description?: string; avatarUrl?: string; + editTeamUrl: string; parentTeam?: Team; members: Connection; }; @@ -165,6 +166,7 @@ export async function getOrganizationTeams( name description avatarUrl + editTeamUrl parentTeam { slug } members(first: 100, membership: IMMEDIATE) { pageInfo { hasNextPage } @@ -186,6 +188,7 @@ export async function getOrganizationTeams( name: team.slug, annotations: { 'github.com/team-slug': team.combinedSlug, + 'backstage.io/edit-url': team.editTeamUrl, }, }, spec: { From 8335a6f6f3498a0be11a5500c974c3f2f7c92f7d Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Wed, 25 May 2022 10:39:07 +0100 Subject: [PATCH 2/4] add changeset Signed-off-by: Brian Fletcher --- .changeset/modern-pandas-agree.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/modern-pandas-agree.md diff --git a/.changeset/modern-pandas-agree.md b/.changeset/modern-pandas-agree.md new file mode 100644 index 0000000000..98360cc6d9 --- /dev/null +++ b/.changeset/modern-pandas-agree.md @@ -0,0 +1,5 @@ +--- +'@backstage/plugin-catalog-backend-module-github': patch +--- + +Adds an edit url to the GitHub Teams Group entities. From be4aff4ac919af0b25f889fdc97e707b04a3264c Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Wed, 25 May 2022 10:45:07 +0100 Subject: [PATCH 3/4] adds tests and handling if edit url is unset Signed-off-by: Brian Fletcher --- .../src/lib/github.test.ts | 6 ++++++ .../src/lib/github.ts | 15 ++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/plugins/catalog-backend-module-github/src/lib/github.test.ts b/plugins/catalog-backend-module-github/src/lib/github.test.ts index fb4caa42c0..40dec0a297 100644 --- a/plugins/catalog-backend-module-github/src/lib/github.test.ts +++ b/plugins/catalog-backend-module-github/src/lib/github.test.ts @@ -86,6 +86,7 @@ describe('github', () => { name: 'Team', description: 'The one and only team', avatarUrl: 'http://example.com/team.jpeg', + editTeamUrl: 'http://example.com/orgs/blah/teams/team/edit', parentTeam: { slug: 'parent', combinedSlug: '', @@ -109,6 +110,11 @@ describe('github', () => { metadata: expect.objectContaining({ name: 'team', description: 'The one and only team', + annotations: { + 'github.com/team-slug': 'blah/team', + 'backstage.io/edit-url': + 'http://example.com/orgs/blah/teams/team/edit', + }, }), spec: { type: 'team', diff --git a/plugins/catalog-backend-module-github/src/lib/github.ts b/plugins/catalog-backend-module-github/src/lib/github.ts index a6933421a5..888df380f8 100644 --- a/plugins/catalog-backend-module-github/src/lib/github.ts +++ b/plugins/catalog-backend-module-github/src/lib/github.ts @@ -52,7 +52,7 @@ export type Team = { name?: string; description?: string; avatarUrl?: string; - editTeamUrl: string; + editTeamUrl?: string; parentTeam?: Team; members: Connection; }; @@ -181,15 +181,20 @@ export async function getOrganizationTeams( const groupMemberUsers = new Map(); const mapper = async (team: Team) => { + const annotations: { [annotationName: string]: string } = { + 'github.com/team-slug': team.combinedSlug, + }; + + if (team.editTeamUrl) { + annotations['backstage.io/edit-url'] = team.editTeamUrl; + } + const entity: GroupEntity = { apiVersion: 'backstage.io/v1alpha1', kind: 'Group', metadata: { name: team.slug, - annotations: { - 'github.com/team-slug': team.combinedSlug, - 'backstage.io/edit-url': team.editTeamUrl, - }, + annotations, }, spec: { type: 'team', From acb4e2110e12a4bc8f4b0f56da03d508eea435b6 Mon Sep 17 00:00:00 2001 From: Brian Fletcher Date: Wed, 25 May 2022 10:49:55 +0100 Subject: [PATCH 4/4] fix casing of URL in changeset Signed-off-by: Brian Fletcher --- .changeset/modern-pandas-agree.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/modern-pandas-agree.md b/.changeset/modern-pandas-agree.md index 98360cc6d9..9c3f95aef2 100644 --- a/.changeset/modern-pandas-agree.md +++ b/.changeset/modern-pandas-agree.md @@ -2,4 +2,4 @@ '@backstage/plugin-catalog-backend-module-github': patch --- -Adds an edit url to the GitHub Teams Group entities. +Adds an edit URL to the GitHub Teams Group entities.