adds tests and handling if edit url is unset
Signed-off-by: Brian Fletcher <brian@roadie.io>
This commit is contained in:
@@ -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',
|
||||
|
||||
@@ -52,7 +52,7 @@ export type Team = {
|
||||
name?: string;
|
||||
description?: string;
|
||||
avatarUrl?: string;
|
||||
editTeamUrl: string;
|
||||
editTeamUrl?: string;
|
||||
parentTeam?: Team;
|
||||
members: Connection<User>;
|
||||
};
|
||||
@@ -181,15 +181,20 @@ export async function getOrganizationTeams(
|
||||
const groupMemberUsers = new Map<string, string[]>();
|
||||
|
||||
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',
|
||||
|
||||
Reference in New Issue
Block a user