Skip to content
Snippets Groups Projects
Commit 81d44c03 authored by Martin Lowe's avatar Martin Lowe :flag_ca:
Browse files

feat: Add non-project managed orgs to static GH team sync

To resolves this issue, the already existing org to API wrapper for installation mapping is used. We extract the keys from the mapping, and pass them along to the static team sync. This allows non-project managed organizations like eclipse-ide to still have EF service teams added.

Resolves #291
parent 637b9b18
No related branches found
No related tags found
1 merge request!335feat: Add non-project managed orgs to static GH team sync
Pipeline #73774 passed
......@@ -492,6 +492,15 @@ module.exports = class {
}
}
/**
* Using the installation instances mapping, fetch all known organizations that have the app installed.
*
* @returns the list of org names with the sync app installed, or an empty list.
*/
getOrganizationSlugsForAppInstallations() {
return Object.keys(octokitAppInstallationInstances) || [];
}
/**
* Retrieve all team members associated with a team, using multiple calls if
* necessary to get all users on a team.
......
......@@ -246,10 +246,11 @@ const GithubSync = class {
if (this.argv.V) {
this.logger.info(`Number of custom teams discovered: ${teams.length}`);
}
const allKnownOrgs = this.getAllKnownOrganizations(uniqueOrgs);
for (const tIdx in teams) {
const team = teams[tIdx];
// process each team individually
await this.processStaticTeam(team, uniqueOrgs);
await this.processStaticTeam(team, allKnownOrgs);
}
// log how long it took to do this stuff
......@@ -885,6 +886,18 @@ const GithubSync = class {
return false;
}
/**
* Using a set as an inbetween for simple deduplication, fetch all known organizations that have been sync'd or are at least known
* through the presence of the custom GH sync application. This is needed as not all project organizations will necessarily have the app
* installed, and not all managed organizations are related to projects.
*
* @param {string[]} uniqueOrgs list of unique orgs discovered through normal sync operations
* @returns {string[]} list of all known org slugs, using project related organizations and app installation organizations.
*/
getAllKnownOrganizations(uniqueOrgs) {
return [...new Set([...this.wrap.getOrganizationSlugsForAppInstallations(), ...uniqueOrgs])];
}
/**
* Using the org and repo fields in each of the Eclipse project repository objects, check that each of the repos in the list are unique
* to deduplicate bad inputs or mixed manual and org setting repos.
......
......@@ -7,7 +7,7 @@ chai.should();
chai.use(ChaiAsPromised);
const Wrapper = require('../src/GitWrapper.js');
const { GithubSync,NOT_FOUND_MESSAGE } = require('../src/Sync.js');
const { GithubSync, NOT_FOUND_MESSAGE } = require('../src/Sync.js');
const { UserPermissionsOverride } = require('../src/teams/UserPermissionsOverride.js');
const { StaticTeamManager, ServiceTypes } = require('../src/teams/StaticTeamManager.js');
const { HttpWrapper } = require('../src/HttpWrapper.js');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment