Merge pull request #22889 from markussiebert/feat/gitlab-group-visibility
feat: Add gitlab group visibility to group entity via annotation
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/plugin-catalog-backend-module-gitlab': patch
|
||||
---
|
||||
|
||||
Add GitLab `visibility` to group entity annotations.
|
||||
@@ -63,6 +63,7 @@ export type GitLabGroup = {
|
||||
name: string;
|
||||
full_path: string;
|
||||
description?: string;
|
||||
visibility?: string;
|
||||
parent_id?: number;
|
||||
};
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ export class GitLabClient {
|
||||
name
|
||||
description
|
||||
fullPath
|
||||
visibility
|
||||
parent {
|
||||
id
|
||||
}
|
||||
@@ -170,6 +171,7 @@ export class GitLabClient {
|
||||
name: groupItem.name,
|
||||
description: groupItem.description,
|
||||
full_path: groupItem.fullPath,
|
||||
visibility: groupItem.visibility,
|
||||
parent_id: Number(
|
||||
groupItem.parent.id.replace(/^gid:\/\/gitlab\/Group\//, ''),
|
||||
),
|
||||
|
||||
@@ -49,6 +49,10 @@ export function defaultGroupEntitiesTransformer(
|
||||
const annotations: { [annotationName: string]: string } = {};
|
||||
|
||||
annotations[`${options.providerConfig.host}/team-path`] = group.full_path;
|
||||
if (group.visibility !== undefined) {
|
||||
annotations[`${options.providerConfig.host}/visibility`] =
|
||||
group.visibility;
|
||||
}
|
||||
|
||||
const entity: GroupEntity = {
|
||||
apiVersion: 'backstage.io/v1alpha1',
|
||||
|
||||
@@ -76,6 +76,7 @@ export type GitLabGroup = {
|
||||
name: string;
|
||||
full_path: string;
|
||||
description?: string;
|
||||
visibility?: string;
|
||||
parent_id?: number;
|
||||
};
|
||||
|
||||
@@ -115,6 +116,7 @@ export type GitLabDescendantGroupsResponse = {
|
||||
name: string;
|
||||
description: string;
|
||||
fullPath: string;
|
||||
visibility: string;
|
||||
parent: {
|
||||
id: string;
|
||||
};
|
||||
|
||||
+5
@@ -452,6 +452,7 @@ describe('GitlabOrgDiscoveryEntityProvider', () => {
|
||||
'backstage.io/managed-by-origin-location':
|
||||
'url:https://test-gitlab/group1/group2',
|
||||
'test-gitlab/team-path': 'group1/group2',
|
||||
'test-gitlab/visibility': 'internal',
|
||||
},
|
||||
description: 'Group2',
|
||||
name: 'group1-group2',
|
||||
@@ -525,6 +526,7 @@ describe('GitlabOrgDiscoveryEntityProvider', () => {
|
||||
name: 'group2',
|
||||
description: 'Group2',
|
||||
fullPath: 'group1/group2',
|
||||
visibility: 'private',
|
||||
parent: {
|
||||
id: 'gid://gitlab/Group/123',
|
||||
},
|
||||
@@ -534,6 +536,7 @@ describe('GitlabOrgDiscoveryEntityProvider', () => {
|
||||
name: 'group3',
|
||||
description: 'Group3',
|
||||
fullPath: 'group1/group3',
|
||||
visibility: 'public',
|
||||
parent: {
|
||||
id: 'gid://gitlab/Group/123',
|
||||
},
|
||||
@@ -703,6 +706,7 @@ describe('GitlabOrgDiscoveryEntityProvider', () => {
|
||||
'backstage.io/managed-by-origin-location':
|
||||
'url:https://gitlab.com/group1/group2',
|
||||
'gitlab.com/team-path': 'group1/group2',
|
||||
'gitlab.com/visibility': 'private',
|
||||
},
|
||||
description: 'Group2',
|
||||
name: 'group2',
|
||||
@@ -728,6 +732,7 @@ describe('GitlabOrgDiscoveryEntityProvider', () => {
|
||||
'backstage.io/managed-by-origin-location':
|
||||
'url:https://gitlab.com/group1/group3',
|
||||
'gitlab.com/team-path': 'group1/group3',
|
||||
'gitlab.com/visibility': 'public',
|
||||
},
|
||||
description: 'Group3',
|
||||
name: 'group3',
|
||||
|
||||
Reference in New Issue
Block a user