diff --git a/docs/integrations/gitlab/org.md b/docs/integrations/gitlab/org.md index d022641ab6..6c154938ee 100644 --- a/docs/integrations/gitlab/org.md +++ b/docs/integrations/gitlab/org.md @@ -58,6 +58,8 @@ amount of data, this can take significant time and resources. The token used must have the `read_api` scope, and the Users and Groups fetched will be those visible to the account which provisioned the token. +**NOTE**: If any groups that are being ingested are empty groups and the account which provisioned the token is shared at a higher level group via group sharing and you don't see the expected number of Groups in the catalog you may be hitting this [GitLab issue](https://gitlab.com/gitlab-org/gitlab/-/issues/267996). + ```yaml catalog: providers: @@ -65,7 +67,7 @@ catalog: yourProviderId: host: gitlab.com orgEnabled: true - group: org/teams # Optional. Must not end with slash. Accepts only groups under the provided path (which will be stripped) + group: org/teams # Required for gitlab.com. Optional for self managed. Must not end with slash. Accepts only groups under the provided path (which will be stripped) groupPattern: '[\s\S]*' # Optional. Filters found groups based on provided pattern. Defaults to `[\s\S]*`, which means to not filter anything ``` diff --git a/plugins/catalog-backend-module-gitlab/src/lib/client.ts b/plugins/catalog-backend-module-gitlab/src/lib/client.ts index d2a3fa01e0..1e5e3ea32b 100644 --- a/plugins/catalog-backend-module-gitlab/src/lib/client.ts +++ b/plugins/catalog-backend-module-gitlab/src/lib/client.ts @@ -102,12 +102,6 @@ export class GitLabClient { let hasNextPage: boolean = false; let endCursor: string | null = null; - if (!groupPath) { - throw new Error( - `Missing required 'group' value in gitlab provider config.`, - ); - } - do { const response: GitLabSaasUsersResponse = await fetch( `${this.config.baseUrl}/api/graphql`, @@ -181,12 +175,6 @@ export class GitLabClient { let hasNextPage: boolean = false; let endCursor: string | null = null; - if (!groupPath) { - throw new Error( - `Missing required 'group' value in gitlab provider config.`, - ); - } - do { const response: GitLabSaasGroupsResponse = await fetch( `${this.config.baseUrl}/api/graphql`, @@ -226,7 +214,7 @@ export class GitLabClient { if (!response.data.group?.descendantGroups.nodes) { this.logger.warn( - `Could not get groups under ${groupPath}. The provided token might not have sufficient permissions`, + `Couldn't get groups under ${groupPath}. The provided token might not have sufficient permissions`, ); continue; } diff --git a/plugins/catalog-backend-module-gitlab/src/providers/GitlabOrgDiscoveryEntityProvider.ts b/plugins/catalog-backend-module-gitlab/src/providers/GitlabOrgDiscoveryEntityProvider.ts index 5fd5094943..94d3e64a02 100644 --- a/plugins/catalog-backend-module-gitlab/src/providers/GitlabOrgDiscoveryEntityProvider.ts +++ b/plugins/catalog-backend-module-gitlab/src/providers/GitlabOrgDiscoveryEntityProvider.ts @@ -89,6 +89,12 @@ export class GitlabOrgDiscoveryEntityProvider implements EntityProvider { ); } + if (!providerConfig.group && providerConfig.host === 'gitlab.com') { + throw new Error( + `Missing 'group' value for GitlabOrgDiscoveryEntityProvider:${providerConfig.id}.`, + ); + } + if (!options.schedule && !providerConfig.schedule) { throw new Error( `No schedule provided neither via code nor config for GitlabOrgDiscoveryEntityProvider:${providerConfig.id}.`,