diff --git a/docs/integrations/gitlab/org.md b/docs/integrations/gitlab/org.md index 1d9da336ce..5fa2e229eb 100644 --- a/docs/integrations/gitlab/org.md +++ b/docs/integrations/gitlab/org.md @@ -242,7 +242,7 @@ catalog: orgEnabled: true group: org/teams # Required for gitlab.com when `orgEnabled: true`. Optional for self managed. Must not end with slash. Accepts only groups under the provided path (which will be stripped) restrictUsersToGroup: true # Optional: Backstage will ingest only users directly assigned to org/teams. - includeUsersWithoutSeat: true # Optional: Include users without paid seat, only valid for SaaS + includeUsersWithoutSeat: false # Optional: Set to true to include users without paid seat, only applicable for SaaS ``` ### Limiting `User` and `Group` entity ingestion in the provider diff --git a/plugins/catalog-backend-module-gitlab/src/lib/client.ts b/plugins/catalog-backend-module-gitlab/src/lib/client.ts index 6ff39fc708..f2ce3d18f8 100644 --- a/plugins/catalog-backend-module-gitlab/src/lib/client.ts +++ b/plugins/catalog-backend-module-gitlab/src/lib/client.ts @@ -139,6 +139,8 @@ export class GitLabClient { options?: CommonListOptions, includeUsersWithoutSeat?: boolean, ): Promise> { + const botFilterRegex = /^(?:project|group)_(\w+)_bot_(\w+)$/; + return this.listGroupMembers(groupPath, { ...options, active: true, // Users with seat are always active but for users without seat we need to filter @@ -148,9 +150,8 @@ export class GitLabClient { // https://github.com/backstage/backstage/issues/26438 // Filter out API tokens https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html#bot-users-for-projects if (includeUsersWithoutSeat) { - const regex = /^(?:project|group)_(\w+)_bot_(\w+)$/; resp.items = resp.items.filter(user => { - return !regex.test(user.username); + return !botFilterRegex.test(user.username); }); } else { resp.items = resp.items.filter(user => user.is_using_seat);