Skip to content

Commit

Permalink
Import picture and display name by the GitHubOrgReaderProcessor
Browse files Browse the repository at this point in the history
  • Loading branch information
Fox32 committed Dec 15, 2020
1 parent c5297ba commit 8dd0a90
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/odd-mugs-build.md
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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: '',
Expand All @@ -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: [],
},
Expand Down
20 changes: 18 additions & 2 deletions plugins/catalog-backend/src/ingestion/processors/github/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ export type User = {
export type Team = {
slug: string;
combinedSlug: string;
name?: string;
description?: string;
avatarUrl?: string;
parentTeam?: Team;
members: Connection<User>;
};
Expand Down Expand Up @@ -137,6 +139,9 @@ export async function getOrganizationTeams(
nodes {
slug
combinedSlug
name
description
avatarUrl
parentTeam { slug }
members(first: 100, membership: IMMEDIATE) {
pageInfo { hasNextPage }
Expand All @@ -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);
Expand Down

0 comments on commit 8dd0a90

Please sign in to comment.