From 8dd0a906da9adfc124751f17ac05de993893cd96 Mon Sep 17 00:00:00 2001 From: Oliver Sand Date: Tue, 8 Dec 2020 16:59:20 +0100 Subject: [PATCH] Import picture and display name by the GitHubOrgReaderProcessor --- .changeset/odd-mugs-build.md | 6 ++++++ .../processors/github/github.test.ts | 12 ++++++++++- .../src/ingestion/processors/github/github.ts | 20 +++++++++++++++++-- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 .changeset/odd-mugs-build.md diff --git a/.changeset/odd-mugs-build.md b/.changeset/odd-mugs-build.md new file mode 100644 index 0000000000..bf95d23410 --- /dev/null +++ b/.changeset/odd-mugs-build.md @@ -0,0 +1,6 @@ +--- +'@backstage/plugin-catalog-backend': patch +--- + +Support `profile` of groups including `displayName` and `picture` in +`GithubOrgReaderProcessor`. Fixes the import of `description` for groups. diff --git a/plugins/catalog-backend/src/ingestion/processors/github/github.test.ts b/plugins/catalog-backend/src/ingestion/processors/github/github.test.ts index d10aba8acb..8911e84d99 100644 --- a/plugins/catalog-backend/src/ingestion/processors/github/github.test.ts +++ b/plugins/catalog-backend/src/ingestion/processors/github/github.test.ts @@ -78,6 +78,9 @@ describe('github', () => { { slug: 'team', combinedSlug: 'blah/team', + name: 'Team', + description: 'The one and only team', + avatarUrl: 'http://example.com/team.jpeg', parentTeam: { slug: 'parent', combinedSlug: '', @@ -96,9 +99,16 @@ describe('github', () => { const output = { groups: [ expect.objectContaining({ - metadata: expect.objectContaining({ name: 'team' }), + metadata: expect.objectContaining({ + name: 'team', + description: 'The one and only team', + }), spec: { type: 'team', + profile: { + displayName: 'Team', + picture: 'http://example.com/team.jpeg', + }, parent: 'parent', children: [], }, diff --git a/plugins/catalog-backend/src/ingestion/processors/github/github.ts b/plugins/catalog-backend/src/ingestion/processors/github/github.ts index 8be96c41de..2b33d72f65 100644 --- a/plugins/catalog-backend/src/ingestion/processors/github/github.ts +++ b/plugins/catalog-backend/src/ingestion/processors/github/github.ts @@ -45,7 +45,9 @@ export type User = { export type Team = { slug: string; combinedSlug: string; + name?: string; description?: string; + avatarUrl?: string; parentTeam?: Team; members: Connection; }; @@ -137,6 +139,9 @@ export async function getOrganizationTeams( nodes { slug combinedSlug + name + description + avatarUrl parentTeam { slug } members(first: 100, membership: IMMEDIATE) { pageInfo { hasNextPage } @@ -162,12 +167,23 @@ export async function getOrganizationTeams( }, spec: { type: 'team', + profile: {}, children: [], }, }; - if (team.description) entity.metadata.description = team.description; - if (team.parentTeam) entity.spec.parent = team.parentTeam.slug; + if (team.description) { + entity.metadata.description = team.description; + } + if (team.name) { + entity.spec.profile!.displayName = team.name; + } + if (team.avatarUrl) { + entity.spec.profile!.picture = team.avatarUrl; + } + if (team.parentTeam) { + entity.spec.parent = team.parentTeam.slug; + } const memberNames: string[] = []; groupMemberUsers.set(team.slug, memberNames);