diff --git a/plugins/catalog-backend-module-github/src/providers/GithubMultiOrgEntityProvider.ts b/plugins/catalog-backend-module-github/src/providers/GithubMultiOrgEntityProvider.ts index 1465857092..8387a91e3a 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubMultiOrgEntityProvider.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubMultiOrgEntityProvider.ts @@ -248,75 +248,67 @@ export class GithubMultiOrgEntityProvider implements EntityProvider { : await this.getAllOrgs(this.options.gitHubConfig); for (const org of orgsToProcess) { - try { - const { headers, type: tokenType } = - await this.options.githubCredentialsProvider.getCredentials({ - url: `${this.options.githubUrl}/${org}`, - }); - const client = graphql.defaults({ - baseUrl: this.options.gitHubConfig.apiBaseUrl, - headers, + const { headers, type: tokenType } = + await this.options.githubCredentialsProvider.getCredentials({ + url: `${this.options.githubUrl}/${org}`, }); + const client = graphql.defaults({ + baseUrl: this.options.gitHubConfig.apiBaseUrl, + headers, + }); - logger.info(`Reading GitHub users and teams for org: ${org}`); + logger.info(`Reading GitHub users and teams for org: ${org}`); - const { users } = await getOrganizationUsers( - client, - org, - tokenType, - this.options.userTransformer, - ); + const { users } = await getOrganizationUsers( + client, + org, + tokenType, + this.options.userTransformer, + ); - const { teams } = await getOrganizationTeams( - client, - org, - this.defaultMultiOrgTeamTransformer.bind(this), - ); + const { teams } = await getOrganizationTeams( + client, + org, + this.defaultMultiOrgTeamTransformer.bind(this), + ); - // Grab current users from `allUsersMap` if they already exist in our - // pending users so we can append to their group membership relations - const pendingUsers = users.map(u => { - const userRef = stringifyEntityRef(u); - if (!allUsersMap.has(userRef)) { - allUsersMap.set(userRef, u); - } - - return allUsersMap.get(userRef); - }); - - if (areGroupEntities(teams)) { - buildOrgHierarchy(teams); - if (areUserEntities(pendingUsers)) { - assignGroupsToUsers(pendingUsers, teams); - } + // Grab current users from `allUsersMap` if they already exist in our + // pending users so we can append to their group membership relations + const pendingUsers = users.map(u => { + const userRef = stringifyEntityRef(u); + if (!allUsersMap.has(userRef)) { + allUsersMap.set(userRef, u); } - allTeams.push(...teams); - } catch (e) { - logger.error(`Failed to read GitHub org data for ${org}: ${e}`); + return allUsersMap.get(userRef); + }); + + if (areGroupEntities(teams)) { + buildOrgHierarchy(teams); + if (areUserEntities(pendingUsers)) { + assignGroupsToUsers(pendingUsers, teams); + } } + + allTeams.push(...teams); } const allUsers = Array.from(allUsersMap.values()); - if (allUsers.length > 0 || allTeams.length > 0) { - const { markCommitComplete } = markReadComplete({ allUsers, allTeams }); + const { markCommitComplete } = markReadComplete({ allUsers, allTeams }); - await this.connection.applyMutation({ - type: 'full', - entities: [...allUsers, ...allTeams].map(entity => ({ - locationKey: `github-multi-org-provider:${this.options.id}`, - entity: withLocations( - `https://${this.options.gitHubConfig.host}`, - entity, - ), - })), - }); + await this.connection.applyMutation({ + type: 'full', + entities: [...allUsers, ...allTeams].map(entity => ({ + locationKey: `github-multi-org-provider:${this.options.id}`, + entity: withLocations( + `https://${this.options.gitHubConfig.host}`, + entity, + ), + })), + }); - markCommitComplete(); - } else { - logger.info('No users or teams to process'); - } + markCommitComplete(); } private supportsEventTopics(): string[] { diff --git a/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts b/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts index a3ff980fd6..0fe61aa229 100644 --- a/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts +++ b/plugins/catalog-backend-module-github/src/providers/GithubOrgEntityProvider.ts @@ -229,25 +229,21 @@ export class GithubOrgEntityProvider } } - if (users.length > 0 || teams.length > 0) { - const { markCommitComplete } = markReadComplete({ users, teams }); + const { markCommitComplete } = markReadComplete({ users, teams }); - await this.connection.applyMutation({ - type: 'full', - entities: [...users, ...teams].map(entity => ({ - locationKey: `github-org-provider:${this.options.id}`, - entity: withLocations( - `https://${this.options.gitHubConfig.host}`, - org, - entity, - ), - })), - }); + await this.connection.applyMutation({ + type: 'full', + entities: [...users, ...teams].map(entity => ({ + locationKey: `github-org-provider:${this.options.id}`, + entity: withLocations( + `https://${this.options.gitHubConfig.host}`, + org, + entity, + ), + })), + }); - markCommitComplete(); - } else { - logger.info('No users or teams to process'); - } + markCommitComplete(); } /** {@inheritdoc @backstage/plugin-events-node#EventSubscriber.onEvent} */ diff --git a/plugins/catalog-backend-module-ldap/src/processors/LdapOrgEntityProvider.ts b/plugins/catalog-backend-module-ldap/src/processors/LdapOrgEntityProvider.ts index ced28face8..1a35852a8d 100644 --- a/plugins/catalog-backend-module-ldap/src/processors/LdapOrgEntityProvider.ts +++ b/plugins/catalog-backend-module-ldap/src/processors/LdapOrgEntityProvider.ts @@ -192,21 +192,17 @@ export class LdapOrgEntityProvider implements EntityProvider { logger, }, ); - if (users.length > 0 || groups.length > 0) { - const { markCommitComplete } = markReadComplete({ users, groups }); + const { markCommitComplete } = markReadComplete({ users, groups }); - await this.connection.applyMutation({ - type: 'full', - entities: [...users, ...groups].map(entity => ({ - locationKey: `ldap-org-provider:${this.options.id}`, - entity: withLocations(this.options.id, entity), - })), - }); + await this.connection.applyMutation({ + type: 'full', + entities: [...users, ...groups].map(entity => ({ + locationKey: `ldap-org-provider:${this.options.id}`, + entity: withLocations(this.options.id, entity), + })), + }); - markCommitComplete(); - } else { - logger.info('No users or teams to process'); - } + markCommitComplete(); } private schedule(schedule: LdapOrgEntityProviderOptions['schedule']) { diff --git a/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.ts b/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.ts index 3a3d5c29c4..7c4c41996b 100644 --- a/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.ts +++ b/plugins/catalog-backend-module-msgraph/src/processors/MicrosoftGraphOrgEntityProvider.ts @@ -323,21 +323,17 @@ export class MicrosoftGraphOrgEntityProvider implements EntityProvider { logger: logger, }, ); - if (users.length > 0 || groups.length > 0) { - const { markCommitComplete } = markReadComplete({ users, groups }); + const { markCommitComplete } = markReadComplete({ users, groups }); - await this.connection.applyMutation({ - type: 'full', - entities: [...users, ...groups].map(entity => ({ - locationKey: `msgraph-org-provider:${this.options.id}`, - entity: withLocations(this.options.id, entity), - })), - }); + await this.connection.applyMutation({ + type: 'full', + entities: [...users, ...groups].map(entity => ({ + locationKey: `msgraph-org-provider:${this.options.id}`, + entity: withLocations(this.options.id, entity), + })), + }); - markCommitComplete(); - } else { - logger.info('No users or teams to process'); - } + markCommitComplete(); } private schedule(taskRunner: TaskRunner) {