addded condition to prevent previous users and groups from being wiped if sync request fails
Signed-off-by: José Costa <jose.j.costa@shell.com>
This commit is contained in:
+16
-13
@@ -298,21 +298,24 @@ export class GithubMultiOrgEntityProvider implements EntityProvider {
|
||||
}
|
||||
|
||||
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();
|
||||
markCommitComplete();
|
||||
} else {
|
||||
logger.info('No users or teams to process');
|
||||
}
|
||||
}
|
||||
|
||||
private supportsEventTopics(): string[] {
|
||||
|
||||
@@ -229,21 +229,25 @@ export class GithubOrgEntityProvider
|
||||
}
|
||||
}
|
||||
|
||||
const { markCommitComplete } = markReadComplete({ users, teams });
|
||||
if (users.length > 0 || teams.length > 0) {
|
||||
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();
|
||||
markCommitComplete();
|
||||
} else {
|
||||
logger.info('No users or teams to process');
|
||||
}
|
||||
}
|
||||
|
||||
/** {@inheritdoc @backstage/plugin-events-node#EventSubscriber.onEvent} */
|
||||
|
||||
@@ -192,18 +192,21 @@ 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();
|
||||
markCommitComplete();
|
||||
} else {
|
||||
logger.info('No users or teams to process');
|
||||
}
|
||||
}
|
||||
|
||||
private schedule(schedule: LdapOrgEntityProviderOptions['schedule']) {
|
||||
|
||||
+13
-10
@@ -323,18 +323,21 @@ 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();
|
||||
markCommitComplete();
|
||||
} else {
|
||||
logger.info('No users or teams to process');
|
||||
}
|
||||
}
|
||||
|
||||
private schedule(taskRunner: TaskRunner) {
|
||||
|
||||
Reference in New Issue
Block a user