Update error handling and documentation

Signed-off-by: angom1 <angom@poppulo.com>
This commit is contained in:
angom1
2023-07-14 16:11:43 +01:00
parent a0b80e7bce
commit d2f13494d8
3 changed files with 10 additions and 14 deletions
+3 -1
View File
@@ -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
```
@@ -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;
}
@@ -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}.`,